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

Side by Side Diff: components/devtools_service/devtools_agent_host.cc

Issue 1635603002: Make use of CreateInterfacePtrAndBind() where appropriate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweaks Created 4 years, 10 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
« no previous file with comments | « components/arc/video/arc_video_bridge.cc ('k') | components/filesystem/files_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/devtools_service/devtools_agent_host.h" 5 #include "components/devtools_service/devtools_agent_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 namespace devtools_service { 9 namespace devtools_service {
10 10
11 DevToolsAgentHost::DevToolsAgentHost(const std::string& id, 11 DevToolsAgentHost::DevToolsAgentHost(const std::string& id,
12 DevToolsAgentPtr agent) 12 DevToolsAgentPtr agent)
13 : id_(id), agent_(std::move(agent)), binding_(this), delegate_(nullptr) {} 13 : id_(id), agent_(std::move(agent)), binding_(this), delegate_(nullptr) {}
14 14
15 DevToolsAgentHost::~DevToolsAgentHost() { 15 DevToolsAgentHost::~DevToolsAgentHost() {
16 if (delegate_) 16 if (delegate_)
17 delegate_->OnAgentHostClosed(this); 17 delegate_->OnAgentHostClosed(this);
18 } 18 }
19 19
20 void DevToolsAgentHost::SetDelegate(Delegate* delegate) { 20 void DevToolsAgentHost::SetDelegate(Delegate* delegate) {
21 delegate_ = delegate; 21 delegate_ = delegate;
22 if (delegate_) { 22 if (delegate_) {
23 if (binding_.is_bound()) 23 if (binding_.is_bound())
24 return; 24 return;
25 25
26 DevToolsAgentClientPtr client; 26 agent_->SetClient(binding_.CreateInterfacePtrAndBind());
27 binding_.Bind(&client);
28 agent_->SetClient(std::move(client));
29 } else { 27 } else {
30 if (!binding_.is_bound()) 28 if (!binding_.is_bound())
31 return; 29 return;
32 30
33 binding_.Close(); 31 binding_.Close();
34 } 32 }
35 } 33 }
36 34
37 void DevToolsAgentHost::SendProtocolMessageToAgent(const std::string& message) { 35 void DevToolsAgentHost::SendProtocolMessageToAgent(const std::string& message) {
38 agent_->DispatchProtocolMessage(message); 36 agent_->DispatchProtocolMessage(message);
39 } 37 }
40 38
41 void DevToolsAgentHost::DispatchProtocolMessage(int32_t call_id, 39 void DevToolsAgentHost::DispatchProtocolMessage(int32_t call_id,
42 const mojo::String& message, 40 const mojo::String& message,
43 const mojo::String& state) { 41 const mojo::String& state) {
44 delegate_->DispatchProtocolMessage(this, message); 42 delegate_->DispatchProtocolMessage(this, message);
45 } 43 }
46 44
47 } // namespace devtools_service 45 } // namespace devtools_service
OLDNEW
« no previous file with comments | « components/arc/video/arc_video_bridge.cc ('k') | components/filesystem/files_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698