• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef HIVIEW_FRAMEWORK_NATIVE_UNIFIED_COLLECTION_TRACE_COLLECTOR_IMPL_H
17 #define HIVIEW_FRAMEWORK_NATIVE_UNIFIED_COLLECTION_TRACE_COLLECTOR_IMPL_H
18 
19 #include "ffrt.h"
20 #include "trace_collector.h"
21 
22 namespace OHOS::HiviewDFX::UCollectUtil {
23 using namespace UCollect;
24 class TraceCollectorImpl : public TraceCollector {
25 public:
26     ~TraceCollectorImpl() override = default;
27 
28 public:
29     CollectResult<std::vector<std::string>> DumpTrace(TraceCaller caller) override;
30     CollectResult<std::vector<std::string>> DumpTraceWithDuration(
31         TraceCaller caller, uint32_t maxDuration, uint64_t happenTime) override;
32     CollectResult<std::vector<std::string>> DumpTraceWithFilter(TeleModule module,
33         uint32_t maxDuration, uint64_t happenTime) override;
34     CollectResult<int32_t> FilterTraceOn(TeleModule module, uint64_t postTime) override;
35     CollectResult<int32_t> FilterTraceOff(TeleModule module) override;
36     bool RecoverTmpTrace() override;
37 
38 private:
39     CollectResult<std::vector<std::string>> StartDumpTrace(TraceCaller &caller, uint32_t timeLimit,
40         uint64_t happenTime = 0);
41 
42     std::unique_ptr<ffrt::queue> ffrtQueue_;
43     ffrt::task_handle handle_;
44     std::mutex postMutex_;
45 };
46 } // namespace OHOS::HiviewDFX::UCollectUtil
47 
48 
49 #endif // HIVIEW_FRAMEWORK_NATIVE_UNIFIED_COLLECTION_TRACE_COLLECTOR_IMPL_H
50