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.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(TraceCaller caller) 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> Recover() override; 37 virtual CollectResult<int32_t> CaptureDurationTrace(AppCaller &appCaller) override; 38 }; 39 Create()40std::shared_ptr<TraceCollector> TraceCollector::Create() 41 { 42 return std::make_shared<TraceCollectorImpl>(); 43 } 44 OpenSnapshot(const std::vector<std::string> & tagGroups)45CollectResult<int32_t> TraceCollectorImpl::OpenSnapshot(const std::vector<std::string>& tagGroups) 46 { 47 return HiViewServiceTraceDelegate::OpenSnapshot(tagGroups); 48 } 49 DumpSnapshot(TraceCaller caller)50CollectResult<std::vector<std::string>> TraceCollectorImpl::DumpSnapshot(TraceCaller caller) 51 { 52 return HiViewServiceTraceDelegate::DumpSnapshot(caller); 53 } 54 OpenRecording(const std::string & tags)55CollectResult<int32_t> TraceCollectorImpl::OpenRecording(const std::string& tags) 56 { 57 return HiViewServiceTraceDelegate::OpenRecording(tags); 58 } 59 RecordingOn()60CollectResult<int32_t> TraceCollectorImpl::RecordingOn() 61 { 62 return HiViewServiceTraceDelegate::RecordingOn(); 63 } 64 RecordingOff()65CollectResult<std::vector<std::string>> TraceCollectorImpl::RecordingOff() 66 { 67 return HiViewServiceTraceDelegate::RecordingOff(); 68 } 69 Close()70CollectResult<int32_t> TraceCollectorImpl::Close() 71 { 72 return HiViewServiceTraceDelegate::Close(); 73 } 74 Recover()75CollectResult<int32_t> TraceCollectorImpl::Recover() 76 { 77 return HiViewServiceTraceDelegate::Recover(); 78 } 79 CaptureDurationTrace(AppCaller & appCaller)80CollectResult<int32_t> TraceCollectorImpl::CaptureDurationTrace(AppCaller &appCaller) 81 { 82 return HiViewServiceTraceDelegate::CaptureDurationTrace(appCaller); 83 } 84 } // UCollectClient 85 } // HiViewDFX 86 } // OHOS 87