Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(877)

Side by Side Diff: ui/devtools/devtools_client.cc

Issue 2374513002: Add ui devtools server (Closed)
Patch Set: Fix all header if directives Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698