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 #include "components/ui_devtools/devtools_client.h" |
| 6 |
| 7 #include "components/ui_devtools/Protocol.h" |
| 8 #include "components/ui_devtools/devtools_server.h" |
| 9 |
| 10 namespace ui { |
| 11 namespace devtools { |
| 12 |
| 13 UiDevToolsClient::UiDevToolsClient(const std::string& name, |
| 14 UiDevToolsServer* server) |
| 15 : name_(name), |
| 16 connection_id_(kNotConnected), |
| 17 dispatcher_(this), |
| 18 server_(server) { |
| 19 DCHECK(server_); |
| 20 } |
| 21 |
| 22 UiDevToolsClient::~UiDevToolsClient() {} |
| 23 |
| 24 void UiDevToolsClient::AddDOMBackend( |
| 25 std::unique_ptr<protocol::DOM::Backend> dom_backend) { |
| 26 dom_backend_ = std::move(dom_backend); |
| 27 protocol::DOM::Dispatcher::wire(&dispatcher_, dom_backend_.get()); |
| 28 } |
| 29 |
| 30 void UiDevToolsClient::Dispatch(const std::string& data) { |
| 31 dispatcher_.dispatch(protocol::parseJSON(data)); |
| 32 } |
| 33 |
| 34 bool UiDevToolsClient::connected() const { |
| 35 return connection_id_ != kNotConnected; |
| 36 } |
| 37 |
| 38 void UiDevToolsClient::set_connection_id(int connection_id) { |
| 39 connection_id_ = connection_id; |
| 40 } |
| 41 |
| 42 const std::string& UiDevToolsClient::name() const { |
| 43 return name_; |
| 44 } |
| 45 |
| 46 void UiDevToolsClient::sendProtocolResponse(int callId, const String& message) { |
| 47 if (connected()) |
| 48 server_->SendOverWebSocket(connection_id_, message); |
| 49 } |
| 50 |
| 51 void UiDevToolsClient::sendProtocolNotification(const String& message) { |
| 52 if (connected()) |
| 53 server_->SendOverWebSocket(connection_id_, message); |
| 54 } |
| 55 |
| 56 void UiDevToolsClient::flushProtocolNotifications() { |
| 57 NOTIMPLEMENTED(); |
| 58 } |
| 59 |
| 60 } // namespace devtools |
| 61 } // namespace ui |
OLD | NEW |