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