• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 "app_caller_parcelable.h"
19 #include "hiview_service_ability_proxy.h"
20 
21 namespace OHOS {
22 namespace HiviewDFX {
OpenSnapshot(const std::vector<std::string> & tagGroups)23 CollectResult<int32_t> HiViewServiceTraceDelegate::OpenSnapshot(const std::vector<std::string>& tagGroups)
24 {
25     auto proxyHandler = [&tagGroups] (
26         const sptr<IRemoteObject>& remote, CollectResult<int32_t>& collectResult, int32_t& errNo) {
27         return HiviewServiceAbilityProxy(remote).OpenSnapshotTrace(tagGroups, errNo, collectResult.data);
28     };
29     return TraceCalling<int32_t>(proxyHandler);
30 }
31 
DumpSnapshot(int32_t client)32 CollectResult<std::vector<std::string>> HiViewServiceTraceDelegate::DumpSnapshot(int32_t client)
33 {
34     auto proxyHandler = [client] (
35         const sptr<IRemoteObject>& remote, CollectResult<std::vector<std::string>>& collectResult, int32_t& errNo) {
36         return HiviewServiceAbilityProxy(remote).DumpSnapshotTrace(client, errNo, collectResult.data);
37     };
38     return TraceCalling<std::vector<std::string>>(proxyHandler);
39 }
40 
OpenRecording(const std::string & tags)41 CollectResult<int32_t> HiViewServiceTraceDelegate::OpenRecording(const std::string& tags)
42 {
43     auto proxyHandler = [&tags] (
44         const sptr<IRemoteObject>& remote, CollectResult<int32_t>& collectResult, int32_t& errNo) {
45         return HiviewServiceAbilityProxy(remote).OpenRecordingTrace(tags, errNo, collectResult.data);
46     };
47     return TraceCalling<int32_t>(proxyHandler);
48 }
49 
RecordingOn()50 CollectResult<int32_t> HiViewServiceTraceDelegate::RecordingOn()
51 {
52     auto proxyHandler = [] (
53         const sptr<IRemoteObject>& remote, CollectResult<int32_t>& collectResult, int32_t& errNo) {
54         return HiviewServiceAbilityProxy(remote).RecordingTraceOn(errNo, collectResult.data);
55     };
56     return TraceCalling<int32_t>(proxyHandler);
57 }
58 
RecordingOff()59 CollectResult<std::vector<std::string>> HiViewServiceTraceDelegate::RecordingOff()
60 {
61     auto proxyHandler = [] (
62         const sptr<IRemoteObject>& remote, CollectResult<std::vector<std::string>>& collectResult, int32_t& errNo) {
63         return HiviewServiceAbilityProxy(remote).RecordingTraceOff(errNo, collectResult.data);
64     };
65     return TraceCalling<std::vector<std::string>>(proxyHandler);
66 }
67 
Close()68 CollectResult<int32_t> HiViewServiceTraceDelegate::Close()
69 {
70     auto proxyHandler = [] (
71         const sptr<IRemoteObject>& remote, CollectResult<int32_t>& collectResult, int32_t& errNo) {
72         return HiviewServiceAbilityProxy(remote).CloseTrace(errNo, collectResult.data);
73     };
74     return TraceCalling<int32_t>(proxyHandler);
75 }
76 
CaptureDurationTrace(UCollectClient::AppCaller & appCaller)77 CollectResult<int32_t> HiViewServiceTraceDelegate::CaptureDurationTrace(UCollectClient::AppCaller &appCaller)
78 {
79     AppCallerParcelable appCallerParcelable(appCaller);
80     auto proxyHandler = [&appCallerParcelable] (
81         const sptr<IRemoteObject>& remote, CollectResult<int32_t>& collectResult, int32_t& errNo) {
82         return HiviewServiceAbilityProxy(remote).CaptureDurationTrace(appCallerParcelable, errNo, collectResult.data);
83     };
84     return TraceCalling<int32_t>(proxyHandler);
85 }
86 } // namespace HiviewDFX
87 } // namespace OHOS
88