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

Side by Side Diff: content/browser/devtools/forwarding_agent_host.cc

Issue 2874613003: [DevTools] Support multiple clients in DevToolsAgentHost (Closed)
Patch Set: Created 3 years, 7 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/devtools/forwarding_agent_host.h" 5 #include "content/browser/devtools/forwarding_agent_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/devtools/devtools_session.h" 8 #include "content/browser/devtools/devtools_session.h"
9 #include "content/browser/devtools/protocol/inspector_handler.h" 9 #include "content/browser/devtools/protocol/inspector_handler.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 ForwardingAgentHost::ForwardingAgentHost( 13 ForwardingAgentHost::ForwardingAgentHost(
14 const std::string& id, 14 const std::string& id,
15 std::unique_ptr<DevToolsExternalAgentProxyDelegate> delegate) 15 std::unique_ptr<DevToolsExternalAgentProxyDelegate> delegate)
16 : DevToolsAgentHostImpl(id), 16 : DevToolsAgentHostImpl(id),
17 delegate_(std::move(delegate)) { 17 delegate_(std::move(delegate)) {
18 NotifyCreated(); 18 NotifyCreated();
19 } 19 }
20 20
21 ForwardingAgentHost::~ForwardingAgentHost() { 21 ForwardingAgentHost::~ForwardingAgentHost() {
22 } 22 }
23 23
24 void ForwardingAgentHost::DispatchOnClientHost(const std::string& message) { 24 void ForwardingAgentHost::DispatchOnClientHost(const std::string& message) {
25 if (session()) 25 if (!sessions().empty())
26 session()->SendMessageToClient(message); 26 sessions().begin()->second->SendMessageToClient(message);
27 } 27 }
28 28
29 void ForwardingAgentHost::ConnectionClosed() { 29 void ForwardingAgentHost::ConnectionClosed() {
30 ForceDetach(false); 30 ForceDetachAllClients(false);
31 } 31 }
32 32
33 void ForwardingAgentHost::AttachSession(DevToolsSession* session) { 33 void ForwardingAgentHost::AttachSession(DevToolsSession* session) {
34 delegate_->Attach(this); 34 delegate_->Attach(this);
35 } 35 }
36 36
37 void ForwardingAgentHost::DetachSession(int session_id) { 37 void ForwardingAgentHost::DetachSession(int session_id) {
38 delegate_->Detach(); 38 delegate_->Detach();
39 } 39 }
40 40
41 bool ForwardingAgentHost::DispatchProtocolMessage( 41 bool ForwardingAgentHost::DispatchProtocolMessage(
42 DevToolsSession* session, 42 DevToolsSession* session,
43 const std::string& message) { 43 const std::string& message) {
44 delegate_->SendMessageToBackend(message); 44 delegate_->SendMessageToBackend(message);
45 return true; 45 return true;
46 } 46 }
47 47
48 bool ForwardingAgentHost::AttachMultiClient(DevToolsAgentHostClient* client) {
49 if (!sessions().empty())
50 return false;
51 return DevToolsAgentHostImpl::AttachMultiClient(client);
52 }
53
48 std::string ForwardingAgentHost::GetType() { 54 std::string ForwardingAgentHost::GetType() {
49 return delegate_->GetType(); 55 return delegate_->GetType();
50 } 56 }
51 57
52 std::string ForwardingAgentHost::GetTitle() { 58 std::string ForwardingAgentHost::GetTitle() {
53 return delegate_->GetTitle(); 59 return delegate_->GetTitle();
54 } 60 }
55 61
56 GURL ForwardingAgentHost::GetURL() { 62 GURL ForwardingAgentHost::GetURL() {
57 return delegate_->GetURL(); 63 return delegate_->GetURL();
(...skipping 17 matching lines...) Expand all
75 81
76 bool ForwardingAgentHost::Close() { 82 bool ForwardingAgentHost::Close() {
77 return delegate_->Close(); 83 return delegate_->Close();
78 } 84 }
79 85
80 base::TimeTicks ForwardingAgentHost::GetLastActivityTime() { 86 base::TimeTicks ForwardingAgentHost::GetLastActivityTime() {
81 return delegate_->GetLastActivityTime(); 87 return delegate_->GetLastActivityTime();
82 } 88 }
83 89
84 } // content 90 } // content
OLDNEW
« no previous file with comments | « content/browser/devtools/forwarding_agent_host.h ('k') | content/browser/devtools/render_frame_devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698