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

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

Issue 2456643002: Create a base agent class for ui_devtools (Closed)
Patch Set: Add comments and fix header 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ui_devtools/devtools_client.h" 5 #include "components/ui_devtools/devtools_client.h"
6 6
7 #include "components/ui_devtools/Protocol.h"
8 #include "components/ui_devtools/devtools_server.h" 7 #include "components/ui_devtools/devtools_server.h"
9 8
10 namespace ui { 9 namespace ui {
11 namespace devtools { 10 namespace devtools {
12 11
13 UiDevToolsClient::UiDevToolsClient(const std::string& name, 12 UiDevToolsClient::UiDevToolsClient(const std::string& name,
14 UiDevToolsServer* server) 13 UiDevToolsServer* server)
15 : name_(name), 14 : name_(name),
16 connection_id_(kNotConnected), 15 connection_id_(kNotConnected),
17 dispatcher_(this), 16 dispatcher_(this),
18 server_(server) { 17 server_(server) {
19 DCHECK(server_); 18 DCHECK(server_);
20 } 19 }
21 20
22 UiDevToolsClient::~UiDevToolsClient() {} 21 UiDevToolsClient::~UiDevToolsClient() {}
23 22
23 void UiDevToolsClient::AddAgent(std::unique_ptr<UiDevToolsAgent> agent) {
24 agent->init(&dispatcher_);
25 agents_.push_back(std::move(agent));
26 }
27
24 void UiDevToolsClient::AddDOMBackend( 28 void UiDevToolsClient::AddDOMBackend(
25 std::unique_ptr<protocol::DOM::Backend> dom_backend) { 29 std::unique_ptr<protocol::DOM::Backend> dom_backend) {
26 dom_backend_ = std::move(dom_backend); 30 dom_backend_ = std::move(dom_backend);
27 protocol::DOM::Dispatcher::wire(&dispatcher_, dom_backend_.get()); 31 protocol::DOM::Dispatcher::wire(&dispatcher_, dom_backend_.get());
28 } 32 }
29 33
30 void UiDevToolsClient::Dispatch(const std::string& data) { 34 void UiDevToolsClient::Dispatch(const std::string& data) {
31 dispatcher_.dispatch(protocol::parseJSON(data)); 35 dispatcher_.dispatch(protocol::parseJSON(data));
32 } 36 }
33 37
(...skipping 18 matching lines...) Expand all
52 if (connected()) 56 if (connected())
53 server_->SendOverWebSocket(connection_id_, message); 57 server_->SendOverWebSocket(connection_id_, message);
54 } 58 }
55 59
56 void UiDevToolsClient::flushProtocolNotifications() { 60 void UiDevToolsClient::flushProtocolNotifications() {
57 NOTIMPLEMENTED(); 61 NOTIMPLEMENTED();
58 } 62 }
59 63
60 } // namespace devtools 64 } // namespace devtools
61 } // namespace ui 65 } // namespace ui
OLDNEW
« components/ui_devtools/devtools_base_agent.h ('K') | « components/ui_devtools/devtools_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698