• 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 OHOS_ABILITY_JS_ENVIRONMENT_JS_ENVIRONMENT_IMPL_H
17 #define OHOS_ABILITY_JS_ENVIRONMENT_JS_ENVIRONMENT_IMPL_H
18 
19 #include <string>
20 #include "event_handler.h"
21 #include "native_engine/native_engine.h"
22 
23 #include "native_engine/native_engine.h"
24 
25 namespace OHOS {
26 namespace JsEnv {
27 struct WorkerInfo {
28     std::string codePath;
29     bool isDebugVersion = false;
30     bool isBundle = true;
31     std::string packagePathStr;
32     std::vector<std::string> assetBasePathStr;
33     std::string hapPath;
34     bool isStageModel = true;
35     std::string moduleName;
36 };
37 
38 class JsEnvironmentImpl {
39 public:
JsEnvironmentImpl()40     JsEnvironmentImpl() {}
~JsEnvironmentImpl()41     virtual ~JsEnvironmentImpl() {}
42 
43     virtual void PostTask(const std::function<void()>& task, const std::string& name, int64_t delayTime) = 0;
44 
45     virtual void PostSyncTask(const std::function<void()>& task, const std::string& name) = 0;
46 
47     virtual void RemoveTask(const std::string& name) = 0;
48 
49     virtual void InitTimerModule(NativeEngine* engine) = 0;
50 
51     virtual void InitConsoleModule(NativeEngine* engine) = 0;
52 
53     virtual bool InitLoop(NativeEngine* engine) = 0;
54 
55     virtual void DeInitLoop(NativeEngine* engine) = 0;
56 
57     virtual void InitWorkerModule(NativeEngine* engine, std::shared_ptr<WorkerInfo> workerInfo) = 0;
58 
59     virtual void InitSyscapModule() = 0;
60 };
61 } // namespace JsEnv
62 } // namespace OHOS
63 #endif // OHOS_ABILITY_JS_ENVIRONMENT_JS_ENVIRONMENT_IMPL_H