• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 RES_SCHED_CLIENT_ADAPTER_H
17 #define RES_SCHED_CLIENT_ADAPTER_H
18 
19 #include <cstdint>
20 #include <unistd.h>
21 
22 namespace OHOS::NWeb {
23 enum class ResSchedTypeAdapter : int32_t {
24     RES_TYPE_KEY_THREAD = 0,
25     RES_TYPE_WEB_STATUS_CHANGE,
26     RES_TYPE_WEB_SCENE,
27     RES_TYPE_WEBVIEW_AUDIO_STATUS_CHANGE,
28 };
29 
30 enum class ResSchedStatusAdapter : int32_t {
31     THREAD_CREATED = 0,
32     THREAD_DESTROYED,
33     WEB_ACTIVE,
34     WEB_INACTIVE,
35     WEB_SCENE_ENTER,
36     WEB_SCENE_EXIT,
37     AUDIO_STATUS_START,
38     AUDIO_STATUS_STOP,
39 };
40 
41 enum class ResSchedRoleAdapter : int32_t {
42     USER_INTERACT = 0,
43     NORMAL_DISPLAY,
44     IMPORTANT_DISPLAY,
45     NORMAL_AUDIO,
46     IMPORTANT_AUDIO,
47 };
48 
49 enum class ResSchedSceneAdapter : int32_t {
50     LOAD_URL = 0,
51     CLICK,
52     SLIDE,
53     RESIZE,
54     VISIBLE,
55     KEYBOARD_CLICK,
56 };
57 
58 class ResSchedClientAdapter {
59 public:
60     ResSchedClientAdapter() = default;
61 
62     virtual ~ResSchedClientAdapter() = default;
63 
64     static bool ReportKeyThread(
65         ResSchedStatusAdapter statusAdapter, pid_t pid, pid_t tid, ResSchedRoleAdapter roleAdapter);
66     static bool ReportWindowStatus(
67         ResSchedStatusAdapter statusAdapter, pid_t pid, uint32_t windowId, int32_t nwebId = -1);
68     static bool ReportScene(
69         ResSchedStatusAdapter statusAdapter, ResSchedSceneAdapter sceneAdapter, int32_t nwebId = -1);
70     static bool ReportAudioData(ResSchedStatusAdapter statusAdapter, pid_t pid, pid_t tid);
71     static void ReportWindowId(int32_t windowId, int32_t nwebId = -1);
72     static void ReportNWebInit(ResSchedStatusAdapter statusAdapter, int32_t nwebId);
73 };
74 } // namespace OHOS::NWeb
75 
76 #endif // RES_SCHED_CLIENT_ADAPTER_H
77