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

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

Issue 2374513002: Add ui devtools server (Closed)
Patch Set: Add comments 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 bool UiDevToolsClient::connected() const {
30 return connection_id_ != kNotConnected;
31 }
32
33 void UiDevToolsClient::set_connection_id(int connection_id) {
34 connection_id_ = connection_id;
35 }
36
37 std::string UiDevToolsClient::name() const {
38 return name_;
39 }
40
41 void UiDevToolsClient::sendProtocolResponse(int callId, const String& message) {
42 if (connected())
43 server_->SendOverWebSocket(connection_id_, message);
44 }
45
46 void UiDevToolsClient::sendProtocolNotification(const String& message) {
47 if (connected())
48 server_->SendOverWebSocket(connection_id_, message);
49 }
50
51 void UiDevToolsClient::flushProtocolNotifications() {
52 NOTIMPLEMENTED();
53 }
54
55 void UiDevToolsClient::Dispatch(const String& data) {
56 dispatcher_.dispatch(protocol::parseJSON(data));
57 }
58
59 } // namespace devtools
60 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698