| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/devtools_agent_host_impl.h" | 5 #include "content/browser/devtools/devtools_agent_host_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // static | 101 // static |
| 102 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::Create( | 102 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::Create( |
| 103 DevToolsExternalAgentProxyDelegate* delegate) { | 103 DevToolsExternalAgentProxyDelegate* delegate) { |
| 104 return new ForwardingAgentHost(delegate); | 104 return new ForwardingAgentHost(delegate); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void DevToolsAgentHostImpl::AttachClient(DevToolsAgentHostClient* client) { | 107 void DevToolsAgentHostImpl::AttachClient(DevToolsAgentHostClient* client) { |
| 108 scoped_refptr<DevToolsAgentHostImpl> protect(this); | 108 scoped_refptr<DevToolsAgentHostImpl> protect(this); |
| 109 if (client_) { | 109 if (client_) { |
| 110 client_->AgentHostClosed(this, true); | 110 client_->AgentHostClosed(this, true); |
| 111 Detach(); | 111 InnerDetach(); |
| 112 } | 112 } |
| 113 client_ = client; | 113 client_ = client; |
| 114 Attach(); | 114 Attach(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void DevToolsAgentHostImpl::DetachClient() { | 117 void DevToolsAgentHostImpl::DetachClient() { |
| 118 if (!client_) | 118 if (!client_) |
| 119 return; | 119 return; |
| 120 | 120 |
| 121 scoped_refptr<DevToolsAgentHostImpl> protect(this); | 121 scoped_refptr<DevToolsAgentHostImpl> protect(this); |
| 122 client_ = NULL; | 122 client_ = NULL; |
| 123 InnerDetach(); |
| 124 } |
| 125 |
| 126 void DevToolsAgentHostImpl::InnerDetach() { |
| 123 Detach(); | 127 Detach(); |
| 128 io_context_.DiscardAllStreams(); |
| 124 } | 129 } |
| 125 | 130 |
| 126 bool DevToolsAgentHostImpl::IsAttached() { | 131 bool DevToolsAgentHostImpl::IsAttached() { |
| 127 return !!client_; | 132 return !!client_; |
| 128 } | 133 } |
| 129 | 134 |
| 130 void DevToolsAgentHostImpl::InspectElement(int x, int y) { | 135 void DevToolsAgentHostImpl::InspectElement(int x, int y) { |
| 131 } | 136 } |
| 132 | 137 |
| 133 std::string DevToolsAgentHostImpl::GetId() { | 138 std::string DevToolsAgentHostImpl::GetId() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // removes it from the instances. | 179 // removes it from the instances. |
| 175 Instances copy = g_instances.Get(); | 180 Instances copy = g_instances.Get(); |
| 176 for (Instances::iterator it(copy.begin()); it != copy.end(); ++it) { | 181 for (Instances::iterator it(copy.begin()); it != copy.end(); ++it) { |
| 177 DevToolsAgentHostImpl* agent_host = it->second; | 182 DevToolsAgentHostImpl* agent_host = it->second; |
| 178 if (agent_host->client_) { | 183 if (agent_host->client_) { |
| 179 scoped_refptr<DevToolsAgentHostImpl> protect(agent_host); | 184 scoped_refptr<DevToolsAgentHostImpl> protect(agent_host); |
| 180 // Clear |client_| before notifying it. | 185 // Clear |client_| before notifying it. |
| 181 DevToolsAgentHostClient* client = agent_host->client_; | 186 DevToolsAgentHostClient* client = agent_host->client_; |
| 182 agent_host->client_ = NULL; | 187 agent_host->client_ = NULL; |
| 183 client->AgentHostClosed(agent_host, true); | 188 client->AgentHostClosed(agent_host, true); |
| 184 agent_host->Detach(); | 189 agent_host->InnerDetach(); |
| 185 } | 190 } |
| 186 } | 191 } |
| 187 } | 192 } |
| 188 | 193 |
| 189 // static | 194 // static |
| 190 void DevToolsAgentHost::AddAgentStateCallback( | 195 void DevToolsAgentHost::AddAgentStateCallback( |
| 191 const AgentStateCallback& callback) { | 196 const AgentStateCallback& callback) { |
| 192 g_callbacks.Get().push_back(&callback); | 197 g_callbacks.Get().push_back(&callback); |
| 193 } | 198 } |
| 194 | 199 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 265 |
| 261 if (chunk.is_last) { | 266 if (chunk.is_last) { |
| 262 CHECK(message_buffer_.size() == message_buffer_size_); | 267 CHECK(message_buffer_.size() == message_buffer_size_); |
| 263 callback_.Run(message_buffer_); | 268 callback_.Run(message_buffer_); |
| 264 message_buffer_ = std::string(); | 269 message_buffer_ = std::string(); |
| 265 message_buffer_size_ = 0; | 270 message_buffer_size_ = 0; |
| 266 } | 271 } |
| 267 } | 272 } |
| 268 | 273 |
| 269 } // namespace content | 274 } // namespace content |
| OLD | NEW |