1 /* 2 * Copyright (c) 2022 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 NWEB_JAVASCRIPT_RESULT_CALLBACK_H 17 #define NWEB_JAVASCRIPT_RESULT_CALLBACK_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "nweb_export.h" 24 #include "nweb_hap_value.h" 25 #include "nweb_value.h" 26 27 namespace OHOS::NWeb { 28 29 class OHOS_NWEB_EXPORT NWebJavaScriptResultCallBack { 30 public: 31 NWebJavaScriptResultCallBack() = default; 32 33 virtual ~NWebJavaScriptResultCallBack() = default; 34 35 virtual std::shared_ptr<NWebValue> GetJavaScriptResult(std::vector<std::shared_ptr<NWebValue>> args, 36 const std::string& method, const std::string& object_name, int32_t routing_id, int32_t object_id) = 0; 37 38 virtual std::shared_ptr<NWebValue> GetJavaScriptResultFlowbuf(std::vector<std::shared_ptr<NWebValue>> args, 39 const std::string& method, const std::string& object_name, int fd, int32_t routing_id, int32_t object_id) = 0; 40 41 /* HasJavaScriptObjectMethods 42 * 43 * @param object_id: means the JavaScript object id 44 * @param object_id: means the method name 45 */ 46 virtual bool HasJavaScriptObjectMethods(int32_t object_id, const std::string& method_name) = 0; 47 48 /* GetJavaScriptObjectMethods 49 * 50 * @param object_id: means the JavaScript object id 51 */ 52 virtual std::shared_ptr<NWebValue> GetJavaScriptObjectMethods(int32_t object_id) = 0; 53 54 /* RemoveJavaScriptObjectHolder 55 * 56 * @param holder: means the JavaScript object is holded by 57 * it(routing_id) 58 * @param object_id: means the JavaScript object id 59 */ 60 virtual void RemoveJavaScriptObjectHolder(int32_t holder, int32_t object_id) = 0; 61 62 // Remove Transient JavaScript Object 63 virtual void RemoveTransientJavaScriptObject() = 0; 64 65 virtual void GetJavaScriptResultV2(const std::vector<std::shared_ptr<NWebHapValue>>& args, 66 const std::string& method, const std::string& object_name, int32_t routing_id, int32_t object_id, 67 std::shared_ptr<NWebHapValue> result) = 0; 68 69 virtual void GetJavaScriptResultFlowbufV2(const std::vector<std::shared_ptr<NWebHapValue>>& args, 70 const std::string& method, const std::string& object_name, int fd, int32_t routing_id, int32_t object_id, 71 std::shared_ptr<NWebHapValue> result) = 0; 72 73 virtual void GetJavaScriptObjectMethodsV2(int32_t object_id, std::shared_ptr<NWebHapValue> result) = 0; 74 }; 75 76 } // namespace OHOS::NWeb 77 #endif