1 /* 2 * Copyright (c) 2023-2024 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 #include "trace_collector_client.h" 16 17 #include "hiview_service_trace_delegate.h" 18 19 using namespace OHOS::HiviewDFX::UCollect; 20 21 namespace OHOS { 22 namespace HiviewDFX { 23 namespace UCollectClient { 24 class TraceCollectorImpl : public TraceCollector { 25 public: 26 TraceCollectorImpl() = default; 27 virtual ~TraceCollectorImpl() = default; 28 29 public: 30 virtual CollectResult<int32_t> OpenSnapshot(const std::vector<std::string>& tagGroups) override; 31 virtual CollectResult<std::vector<std::string>> DumpSnapshot(TraceClient client) override; 32 virtual CollectResult<int32_t> OpenRecording(const std::string& tags) override; 33 virtual CollectResult<int32_t> RecordingOn() override; 34 virtual CollectResult<std::vector<std::string>> RecordingOff() override; 35 virtual CollectResult<int32_t> Close() override; 36 virtual CollectResult<int32_t> CaptureDurationTrace(AppCaller &appCaller) override; 37 }; 38 Create()39std::shared_ptr<TraceCollector> TraceCollector::Create() 40 { 41 return std::make_shared<TraceCollectorImpl>(); 42 } 43 OpenSnapshot(const std::vector<std::string> & tagGroups)44CollectResult<int32_t> TraceCollectorImpl::OpenSnapshot(const std::vector<std::string>& tagGroups) 45 { 46 return HiViewServiceTraceDelegate::OpenSnapshot(tagGroups); 47 } 48 DumpSnapshot(TraceClient client)49CollectResult<std::vector<std::string>> TraceCollectorImpl::DumpSnapshot(TraceClient client) 50 { 51 return HiViewServiceTraceDelegate::DumpSnapshot(client); 52 } 53 OpenRecording(const std::string & tags)54CollectResult<int32_t> TraceCollectorImpl::OpenRecording(const std::string& tags) 55 { 56 return HiViewServiceTraceDelegate::OpenRecording(tags); 57 } 58 RecordingOn()59CollectResult<int32_t> TraceCollectorImpl::RecordingOn() 60 { 61 return HiViewServiceTraceDelegate::RecordingOn(); 62 } 63 RecordingOff()64CollectResult<std::vector<std::string>> TraceCollectorImpl::RecordingOff() 65 { 66 return HiViewServiceTraceDelegate::RecordingOff(); 67 } 68 Close()69CollectResult<int32_t> TraceCollectorImpl::Close() 70 { 71 return HiViewServiceTraceDelegate::Close(); 72 } 73 CaptureDurationTrace(AppCaller & appCaller)74CollectResult<int32_t> TraceCollectorImpl::CaptureDurationTrace(AppCaller &appCaller) 75 { 76 return HiViewServiceTraceDelegate::CaptureDurationTrace(appCaller); 77 } 78 } // UCollectClient 79 } // HiViewDFX 80 } // OHOS 81