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

Side by Side Diff: components/ui_devtools/devtools_client.cc

Issue 2374513002: Add ui devtools server (Closed)
Patch Set: Add inspector_protocol to DEPS Created 4 years, 1 month 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
« no previous file with comments | « components/ui_devtools/devtools_client.h ('k') | components/ui_devtools/devtools_server.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
OLDNEW
« no previous file with comments | « components/ui_devtools/devtools_client.h ('k') | components/ui_devtools/devtools_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698