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

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

Issue 2374513002: Add ui devtools server (Closed)
Patch Set: Move everything to components/ui_devtools 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 "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 bool UiDevToolsClient::connected() const {
31 return connection_id_ != kNotConnected;
32 }
33
34 void UiDevToolsClient::set_connection_id(int connection_id) {
35 connection_id_ = connection_id;
36 }
37
38 const std::string& UiDevToolsClient::name() const {
39 return name_;
40 }
41
42 void UiDevToolsClient::sendProtocolResponse(int callId, const String& message) {
43 if (connected())
44 server_->SendOverWebSocket(connection_id_, message);
45 }
46
47 void UiDevToolsClient::sendProtocolNotification(const String& message) {
48 if (connected())
49 server_->SendOverWebSocket(connection_id_, message);
50 }
51
52 void UiDevToolsClient::flushProtocolNotifications() {
53 NOTIMPLEMENTED();
54 }
55
56 void UiDevToolsClient::Dispatch(const String& data) {
57 dispatcher_.dispatch(protocol::parseJSON(data));
58 }
sadrul 2016/10/20 16:56:29 The order should be the same as the order in the h
Sarmad Hashmi 2016/10/20 21:49:22 Done.
59
60 } // namespace devtools
61 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698