/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_HIVIEWDFX_ADAPTER_SERVICE_IDL_INCLUDE_TRACE_DELEGATE_H #define OHOS_HIVIEWDFX_ADAPTER_SERVICE_IDL_INCLUDE_TRACE_DELEGATE_H #include #include "collect_result.h" #include "hiview_service_ability_proxy.h" #include "hiview_remote_service.h" #include "parcel.h" #include "client/trace_collector.h" namespace OHOS { namespace HiviewDFX { class HiViewServiceTraceDelegate { public: static CollectResult OpenSnapshot(const std::vector& tagGroups); static CollectResult> DumpSnapshot(int32_t caller); static CollectResult OpenRecording(const std::string& tags); static CollectResult RecordingOn(); static CollectResult> RecordingOff(); static CollectResult Close(); static CollectResult Recover(); static CollectResult CaptureDurationTrace(UCollectClient::AppCaller &appCaller); private: template static CollectResult TraceCalling( std::function(HiviewServiceAbilityProxy&)> proxyHandler) { CollectResult ret; if (proxyHandler == nullptr) { return ret; } auto service = RemoteService::GetHiViewRemoteService(); if (service == nullptr) { return ret; } HiviewServiceAbilityProxy proxy(service); auto traceRet = proxyHandler(proxy); return traceRet.result_; } }; } // namespace HiviewDFX } // namespace OHOS #endif // OHOS_HIVIEWDFX_ADAPTER_SERVICE_IDL_INCLUDE_TRACE_DELEGATE_H