| OLD | NEW |
| 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" |
| 8 #include "content/browser/devtools/protocol/inspector_handler.h" |
| 9 |
| 7 namespace content { | 10 namespace content { |
| 8 | 11 |
| 9 ForwardingAgentHost::ForwardingAgentHost( | 12 ForwardingAgentHost::ForwardingAgentHost( |
| 10 DevToolsExternalAgentProxyDelegate* delegate) | 13 DevToolsExternalAgentProxyDelegate* delegate) |
| 11 : delegate_(delegate) { | 14 : delegate_(delegate) { |
| 12 } | 15 } |
| 13 | 16 |
| 14 ForwardingAgentHost::~ForwardingAgentHost() { | 17 ForwardingAgentHost::~ForwardingAgentHost() { |
| 15 } | 18 } |
| 16 | 19 |
| 17 void ForwardingAgentHost::DispatchOnClientHost(const std::string& message) { | 20 void ForwardingAgentHost::DispatchOnClientHost(const std::string& message) { |
| 18 SendMessageToClient(message); | 21 SendMessageToClient(message); |
| 19 } | 22 } |
| 20 | 23 |
| 21 void ForwardingAgentHost::ConnectionClosed() { | 24 void ForwardingAgentHost::ConnectionClosed() { |
| 22 HostClosed(); | 25 devtools::inspector::Client inspector( |
| 26 base::Bind(&ForwardingAgentHost::DispatchOnClientHost, |
| 27 base::Unretained(this))); |
| 28 inspector.Detached(devtools::inspector::DetachedParams::Create() |
| 29 ->set_reason("Connection lost.")); |
| 30 delegate_.reset(); |
| 23 } | 31 } |
| 24 | 32 |
| 25 void ForwardingAgentHost::Attach() { | 33 void ForwardingAgentHost::Attach() { |
| 26 delegate_->Attach(this); | 34 if (delegate_) |
| 35 delegate_->Attach(this); |
| 27 } | 36 } |
| 28 | 37 |
| 29 void ForwardingAgentHost::Detach() { | 38 void ForwardingAgentHost::Detach() { |
| 30 delegate_->Detach(); | 39 if (delegate_) |
| 40 delegate_->Detach(); |
| 31 } | 41 } |
| 32 | 42 |
| 33 void ForwardingAgentHost::DispatchProtocolMessage( | 43 void ForwardingAgentHost::DispatchProtocolMessage( |
| 34 const std::string& message) { | 44 const std::string& message) { |
| 35 delegate_->SendMessageToBackend(message); | 45 if (delegate_) |
| 46 delegate_->SendMessageToBackend(message); |
| 36 } | 47 } |
| 37 | 48 |
| 38 DevToolsAgentHost::Type ForwardingAgentHost::GetType() { | 49 DevToolsAgentHost::Type ForwardingAgentHost::GetType() { |
| 39 return TYPE_EXTERNAL; | 50 return TYPE_EXTERNAL; |
| 40 } | 51 } |
| 41 | 52 |
| 42 std::string ForwardingAgentHost::GetTitle() { | 53 std::string ForwardingAgentHost::GetTitle() { |
| 43 return ""; | 54 return ""; |
| 44 } | 55 } |
| 45 | 56 |
| 46 GURL ForwardingAgentHost::GetURL() { | 57 GURL ForwardingAgentHost::GetURL() { |
| 47 return GURL(); | 58 return GURL(); |
| 48 } | 59 } |
| 49 | 60 |
| 50 bool ForwardingAgentHost::Activate() { | 61 bool ForwardingAgentHost::Activate() { |
| 51 return false; | 62 return false; |
| 52 } | 63 } |
| 53 | 64 |
| 54 bool ForwardingAgentHost::Close() { | 65 bool ForwardingAgentHost::Close() { |
| 55 return false; | 66 return false; |
| 56 } | 67 } |
| 57 | 68 |
| 58 } // content | 69 } // content |
| OLD | NEW |