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