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 }; 36 class JsEnvironmentImpl { 37 public: JsEnvironmentImpl()38 JsEnvironmentImpl() {} ~JsEnvironmentImpl()39 virtual ~JsEnvironmentImpl() {} 40 41 virtual void PostTask(const std::function<void()>& task, const std::string& name, int64_t delayTime) = 0; 42 43 virtual void PostSyncTask(const std::function<void()>& task, const std::string& name) = 0; 44 45 virtual void RemoveTask(const std::string& name) = 0; 46 47 virtual void InitTimerModule(NativeEngine* engine) = 0; 48 49 virtual void InitConsoleModule(NativeEngine *engine) = 0; 50 51 virtual bool InitLoop(NativeEngine *engine) = 0; 52 53 virtual void DeInitLoop(NativeEngine *engine) = 0; 54 55 virtual void InitWorkerModule(NativeEngine& engine, std::shared_ptr<WorkerInfo> workerInfo) = 0; 56 57 virtual void InitSyscapModule() = 0; 58 }; 59 } // namespace JsEnv 60 } // namespace OHOS 61 #endif // OHOS_ABILITY_JS_ENVIRONMENT_JS_ENVIRONMENT_IMPL_H