1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "hiview_service_trace_delegate.h" 17 18 #include "hiview_err_code.h" 19 #include "iservice_registry.h" 20 #include "hiview_logger.h" 21 #include "system_ability_definition.h" 22 23 namespace OHOS { 24 namespace HiviewDFX { OpenSnapshot(const std::vector<std::string> & tagGroups)25CollectResult<int32_t> HiViewServiceTraceDelegate::OpenSnapshot(const std::vector<std::string>& tagGroups) 26 { 27 auto proxyHandler = [&tagGroups] (HiviewServiceAbilityProxy& proxy) { 28 return proxy.OpenSnapshotTrace(tagGroups); 29 }; 30 return TraceCalling<int32_t>(proxyHandler); 31 } 32 DumpSnapshot(int32_t caller)33CollectResult<std::vector<std::string>> HiViewServiceTraceDelegate::DumpSnapshot(int32_t caller) 34 { 35 auto proxyHandler = [caller] (HiviewServiceAbilityProxy& proxy) { 36 return proxy.DumpSnapshotTrace(caller); 37 }; 38 return TraceCalling<std::vector<std::string>>(proxyHandler); 39 } 40 OpenRecording(const std::string & tags)41CollectResult<int32_t> HiViewServiceTraceDelegate::OpenRecording(const std::string& tags) 42 { 43 auto proxyHandler = [&tags] (HiviewServiceAbilityProxy& proxy) { 44 return proxy.OpenRecordingTrace(tags); 45 }; 46 return TraceCalling<int32_t>(proxyHandler); 47 } 48 RecordingOn()49CollectResult<int32_t> HiViewServiceTraceDelegate::RecordingOn() 50 { 51 auto proxyHandler = [] (HiviewServiceAbilityProxy& proxy) { 52 return proxy.RecordingTraceOn(); 53 }; 54 return TraceCalling<int32_t>(proxyHandler); 55 } 56 RecordingOff()57CollectResult<std::vector<std::string>> HiViewServiceTraceDelegate::RecordingOff() 58 { 59 auto proxyHandler = [] (HiviewServiceAbilityProxy& proxy) { 60 return proxy.RecordingTraceOff(); 61 }; 62 return TraceCalling<std::vector<std::string>>(proxyHandler); 63 } 64 Close()65CollectResult<int32_t> HiViewServiceTraceDelegate::Close() 66 { 67 auto proxyHandler = [] (HiviewServiceAbilityProxy& proxy) { 68 return proxy.CloseTrace(); 69 }; 70 return TraceCalling<int32_t>(proxyHandler); 71 } 72 Recover()73CollectResult<int32_t> HiViewServiceTraceDelegate::Recover() 74 { 75 auto proxyHandler = [] (HiviewServiceAbilityProxy& proxy) { 76 return proxy.RecoverTrace(); 77 }; 78 return TraceCalling<int32_t>(proxyHandler); 79 } 80 CaptureDurationTrace(UCollectClient::AppCaller & appCaller)81CollectResult<int32_t> HiViewServiceTraceDelegate::CaptureDurationTrace(UCollectClient::AppCaller &appCaller) 82 { 83 auto proxyHandler = [&appCaller] (HiviewServiceAbilityProxy& proxy) { 84 return proxy.CaptureDurationTrace(appCaller); 85 }; 86 return TraceCalling<int32_t>(proxyHandler); 87 } 88 } // namespace HiviewDFX 89 } // namespace OHOS 90