1 /*
2  * Copyright (c) 2022 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 FOUNDATION_ACE_ADAPTER_OHOS_OSAL_FRAME_TRACE_ADAPTER_IMPL_H
17 #define FOUNDATION_ACE_ADAPTER_OHOS_OSAL_FRAME_TRACE_ADAPTER_IMPL_H
18 
19 #include <functional>
20 #include "base/thread/frame_trace_adapter.h"
21 
22 namespace OHOS::Ace {
23 class FrameTraceAdapterImpl : public FrameTraceAdapter {
24 public:
25     FrameTraceAdapterImpl() = default;
26     ~FrameTraceAdapterImpl() override = default;
27     void QuickExecute(std::function<void()>&& func) override;
28     void SlowExecute(std::function<void()>&& func) override;
29     bool EnableFrameTrace(const std::string& traceTag) override;
30     bool IsEnabled() override;
31     void SetFrameTraceLimit() override;
32 
33 private:
34     bool AccessFrameTrace();
35 };
36 
37 class FrameTraceAdapterFakeImpl : public FrameTraceAdapter {
38 public:
39     FrameTraceAdapterFakeImpl() = default;
40     ~FrameTraceAdapterFakeImpl() override = default;
41     void QuickExecute(std::function<void()>&& func) override;
42     void SlowExecute(std::function<void()>&& func) override;
43     bool EnableFrameTrace(const std::string& traceTag) override;
44     bool IsEnabled() override;
45 };
46 }
47 #endif
48 
49