1 /*
2  * Copyright (c) 2021 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_BRIDGE_JS_FRONTEND_ENGINE_COMMON_GROUP_JS_BRIDGE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_JS_FRONTEND_ENGINE_COMMON_GROUP_JS_BRIDGE_H
18 
19 #include <string>
20 #include <vector>
21 
22 #if defined(PREVIEW)
23 #include "adapter/preview/osal/fetch_manager.h"
24 #endif
25 #include "base/memory/ace_type.h"
26 
27 namespace OHOS::Ace {
28 
29 class GroupJsBridge : public virtual AceType {
30     DECLARE_ACE_TYPE(GroupJsBridge, AceType)
31 public:
32     virtual void TriggerModuleJsCallback(int32_t callbackId, int32_t code,
33         std::vector<uint8_t>&& messageData) = 0;
34 #if defined(PREVIEW)
35     virtual void TriggerModuleJsCallbackPreview(int32_t callbackId, int32_t code, ResponseData responseData) = 0;
36 #endif
37 
38     virtual void TriggerModulePluginGetErrorCallback(
39         int32_t callbackId, int32_t errorCode, std::string&& errorMessage) = 0;
40 
41     virtual void TriggerEventJsCallback(int32_t callbackId, int32_t code, std::vector<uint8_t>&& eventData) = 0;
42 
LoadPluginJsCode(std::string && jsCode)43     virtual void LoadPluginJsCode(std::string&& jsCode) {}
44 
LoadPluginJsByteCode(std::vector<uint8_t> && jsCode,std::vector<int32_t> && jsCodeLen)45     virtual void LoadPluginJsByteCode(std::vector<uint8_t>&& jsCode, std::vector<int32_t>&& jsCodeLen) {}
46 
ForwardToWorker(int32_t callbackId)47     virtual bool ForwardToWorker(int32_t callbackId)
48     {
49         return false;
50     }
51 
Destroy()52     virtual void Destroy() {}
53 };
54 
55 } // namespace OHOS::Ace
56 
57 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_JS_FRONTEND_ENGINE_COMMON_GROUP_JS_BRIDGE_H
58