1 /* 2 * Copyright (c) 2024 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 AAFWK_BROWSER_CLIENT_ADAPTER_IMPL_H 17 #define AAFWK_BROWSER_CLIENT_ADAPTER_IMPL_H 18 19 #include <memory> 20 #include "aafwk_render_scheduler_host_adapter.h" 21 #include "aafwk_browser_client_adapter.h" 22 #include "ibrowser.h" 23 #include "iconsumer_surface.h" 24 #include "irender_scheduler.h" 25 #include "iremote_proxy.h" 26 27 namespace OHOS::NWeb { 28 class BrowserClient : public IRemoteProxy<IBrowser> { 29 public: 30 explicit BrowserClient(const sptr<IRemoteObject> &impl); 31 32 virtual ~BrowserClient() = default; 33 34 virtual sptr<IRemoteObject> QueryRenderSurface(int32_t surface_id) override; 35 36 virtual void ReportThread(int32_t status, int32_t process_id, int32_t thread_id, int32_t role) override; 37 38 virtual void PassSurface(sptr<Surface> surface, int64_t surface_id) override; 39 40 virtual void DestroyRenderSurface(int32_t surface_id) override; 41 private: 42 bool WriteInterfaceToken(MessageParcel &data); 43 static inline BrokerDelegator<BrowserClient> delegator_; 44 }; 45 46 class AafwkBrowserClientAdapterImpl : public AafwkBrowserClientAdapter { 47 public: 48 explicit AafwkBrowserClientAdapterImpl(); 49 50 static AafwkBrowserClientAdapterImpl& GetInstance(); 51 52 ~AafwkBrowserClientAdapterImpl() override = default; 53 54 void* QueryRenderSurface(int32_t surface_id) override; 55 56 void ReportThread(ResSchedStatusAdapter status, int32_t process_id, int32_t thread_id, 57 ResSchedRoleAdapter role) override; 58 59 void PassSurface(int64_t surface_id) override; 60 61 void DestroyRenderSurface(int32_t surface_id) override; 62 63 sptr<IBrowser> browserHost_; 64 private: 65 std::map<int32_t, OHNativeWindow*> window_map_; 66 std::mutex window_map_mutex_; 67 }; 68 } // namespace content 69 #endif // AAFWK_BROWSER_CLIENT_ADAPTER_IMPL_H