OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_UI_DEVTOOLS_DEVTOOLS_CLIENT_H_ |
| 6 #define COMPONENTS_UI_DEVTOOLS_DEVTOOLS_CLIENT_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "components/ui_devtools/DOM.h" |
| 11 #include "components/ui_devtools/Forward.h" |
| 12 #include "components/ui_devtools/Protocol.h" |
| 13 |
| 14 namespace ui { |
| 15 namespace devtools { |
| 16 |
| 17 class UiDevToolsServer; |
| 18 |
| 19 // Every UI component that wants to be inspectable must instantiate |
| 20 // this class and attach the corresponding backends/frontends (i.e: DOM, CSS, |
| 21 // etc). This client is then attached to the UiDevToolsServer and all messages |
| 22 // from this client are sent over the web socket owned by the server. |
| 23 class UiDevToolsClient : public protocol::FrontendChannel { |
| 24 public: |
| 25 static const int kNotConnected = -1; |
| 26 |
| 27 UiDevToolsClient(const std::string& name, UiDevToolsServer* server); |
| 28 ~UiDevToolsClient() override; |
| 29 |
| 30 void AddDOMBackend(std::unique_ptr<protocol::DOM::Backend> dom_backend); |
| 31 void Dispatch(const std::string& data); |
| 32 |
| 33 bool connected() const; |
| 34 void set_connection_id(int connection_id); |
| 35 const std::string& name() const; |
| 36 |
| 37 private: |
| 38 // protocol::FrontendChannel |
| 39 void sendProtocolResponse(int callId, const String& message) override; |
| 40 void sendProtocolNotification(const String& message) override; |
| 41 void flushProtocolNotifications() override; |
| 42 |
| 43 std::string name_; |
| 44 int connection_id_; |
| 45 |
| 46 std::unique_ptr<protocol::DOM::Backend> dom_backend_; |
| 47 protocol::UberDispatcher dispatcher_; |
| 48 UiDevToolsServer* server_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(UiDevToolsClient); |
| 51 }; |
| 52 |
| 53 } // namespace devtools |
| 54 } // namespace ui |
| 55 |
| 56 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_CLIENT_H_ |
OLD | NEW |