• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef HIVIEWDFX_HIVIEW_TRACE_COMMON_STATE_H
16 #define HIVIEWDFX_HIVIEW_TRACE_COMMON_STATE_H
17 #include <memory>
18 
19 #include "trace_common.h"
20 #include "trace_base_state.h"
21 namespace OHOS::HiviewDFX {
22 class CommonState : public TraceBaseState {
23 public:
24     explicit CommonState(bool isCachOn, int32_t totalFileSize, int32_t sliceMaxDuration);
25     TraceRet OpenTrace(TraceScenario scenario, const std::vector<std::string> &tagGroups) override;
26     TraceRet OpenTrace(TraceScenario scenario, const std::string &args) override;
27     TraceRet DumpTrace(TraceScenario scenario, uint32_t maxDuration, uint64_t happenTime, TraceRetInfo &info) override;
28     TraceRet DumpTraceAsync(const DumpTraceArgs &args, int64_t fileSizeLimit,
29         TraceRetInfo &info, DumpTraceCallback callback) override;
30     TraceRet TraceDropOn(TraceScenario scenario) override;
31     TraceRet TraceCacheOn() override;
32     TraceRet TraceCacheOff() override;
33     TraceRet SetCacheParams(int32_t totalFileSize, int32_t sliceMaxDuration) override;
34     TraceRet CloseTrace(TraceScenario scenario) override;
35 
36 protected:
GetTag()37     std::string GetTag() override
38     {
39         return "CommonState";
40     }
41 
42 private:
43     int32_t totalFileSize_ ;
44     int32_t sliceMaxDuration_;
45 };
46 
47 class CommonDropState : public TraceBaseState {
48 public:
49     TraceRet OpenTrace(TraceScenario scenario, const std::vector<std::string> &tagGroups) override;
50     TraceRet OpenTrace(TraceScenario scenario, const std::string &args) override;
51     TraceRet TraceDropOff(TraceScenario scenario, TraceRetInfo &info) override;
52     TraceRet CloseTrace(TraceScenario scenario) override;
53 
54 protected:
GetTag()55     std::string GetTag() override
56     {
57         return "CommonDropState";
58     }
59 };
60 }
61 #endif //HIVIEWDFX_HIVIEW_TRACE_COMMON_STATE_H
62