• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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_FRAMEWORKS_BASE_RESSCHED_RESSCHED_REPORT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_RESSCHED_RESSCHED_REPORT_H
18 
19 #include <string>
20 #include <unordered_map>
21 
22 #include "base/utils/macros.h"
23 #include "base/utils/noncopyable.h"
24 #include "core/event/touch_event.h"
25 
26 namespace OHOS::Ace {
27 namespace ResDefine {
28 constexpr int32_t LOAD_PAGE_START_EVENT = 0;
29 constexpr int32_t LOAD_PAGE_COMPLETE_EVENT = 1;
30 }
31 
32 using ReportDataFunc = void (*)(uint32_t resType, int64_t value,
33     const std::unordered_map<std::string, std::string>& payload);
34 
35 ReportDataFunc ACE_EXPORT LoadReportDataFunc();
36 
37 class ACE_EXPORT ResSchedReport final {
38 public:
39     static ResSchedReport& GetInstance();
40     void ResSchedDataReport(const char* name, const std::unordered_map<std::string, std::string>& param = {});
41     void ResSchedDataReport(uint32_t resType, int32_t value = 0,
42         const std::unordered_map<std::string, std::string>& payload = {});
43     void OnTouchEvent(const TouchType& touchType);
44     void LoadPageEvent(int32_t value);
45 
46 private:
ResSchedReport()47     ResSchedReport() {}
~ResSchedReport()48     ~ResSchedReport() {}
49     ReportDataFunc reportDataFunc_ = nullptr;
50     bool loadPageOn_ = false;
51 };
52 
53 class ACE_EXPORT ResSchedReportScope final {
54 public:
55     ACE_DISALLOW_COPY_AND_MOVE(ResSchedReportScope);
56 
57     explicit ResSchedReportScope(const std::string& name,
58         const std::unordered_map<std::string, std::string>& param = {});
59     ~ResSchedReportScope();
60 
61 private:
62     std::string name_;
63     std::unordered_map<std::string, std::string> payload_;
64 };
65 } // namespace OHOS::Ace
66 
67 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_RESSCHED_RESSCHED_REPORT_H
68