// Copyright 2022 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef FUCHSIA_WEB_WEBINSTANCE_HOST_FUCHSIA_WEB_DEBUG_PROXY_H_ #define FUCHSIA_WEB_WEBINSTANCE_HOST_FUCHSIA_WEB_DEBUG_PROXY_H_ #include #include #include // Proxies the fuchsia.web.Debug protocol to one or more registered // fuchsia.web.Debug implementations, allowing clients to use a single // fuchsia.web.Debug instance to observe DevTools availability across // multiple components (e.g. multiple web instances). class FuchsiaWebDebugProxy final : public fuchsia::web::Debug, public fuchsia::web::DevToolsListener { public: explicit FuchsiaWebDebugProxy(); ~FuchsiaWebDebugProxy() override; // Returns true if one or more clients are active. bool has_clients() const { return devtools_listeners_.size() != 0u; } // Registers a new fuchsia.web.Debug protocol to be proxied. void RegisterInstance(fidl::InterfaceHandle debug); // fuchsia::web::Debug implementation. void EnableDevTools( fidl::InterfaceHandle listener, EnableDevToolsCallback callback) override; private: // fuchsia::web::DevToolsListener implementation. void OnContextDevToolsAvailable( fidl::InterfaceRequest request) override; // DevToolsListeners registered by clients via the Debug interface. fidl::InterfacePtrSet devtools_listeners_; // DevToolsListener bindings, connected to active web instances. fidl::BindingSet instance_bindings_; }; #endif // FUCHSIA_WEB_WEBINSTANCE_HOST_FUCHSIA_WEB_DEBUG_PROXY_H_