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_manager_impl.h" | 5 #include "content/browser/devtools/devtools_manager_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 agent_to_client_host_.erase(agent_host); | 263 agent_to_client_host_.erase(agent_host); |
264 client_to_agent_host_.erase(client_host); | 264 client_to_agent_host_.erase(client_host); |
265 agent_runtime_states_.erase(agent_host); | 265 agent_runtime_states_.erase(agent_host); |
266 | 266 |
267 if (client_to_agent_host_.empty()) { | 267 if (client_to_agent_host_.empty()) { |
268 BrowserThread::PostTask( | 268 BrowserThread::PostTask( |
269 BrowserThread::IO, | 269 BrowserThread::IO, |
270 FROM_HERE, | 270 FROM_HERE, |
271 base::Bind(&DevToolsNetLogObserver::Detach)); | 271 base::Bind(&DevToolsNetLogObserver::Detach)); |
272 } | 272 } |
| 273 int process_id = agent_host->GetRenderProcessId(); |
| 274 |
| 275 // Lazy agent hosts can be deleted from within detach. |
| 276 // Do not access agent_host below this line. |
273 agent_host->Detach(); | 277 agent_host->Detach(); |
274 | 278 |
275 int process_id = agent_host->GetRenderProcessId(); | |
276 if (process_id == -1) | 279 if (process_id == -1) |
277 return; | 280 return; |
278 for (AgentToClientHostMap::iterator it = agent_to_client_host_.begin(); | 281 for (AgentToClientHostMap::iterator it = agent_to_client_host_.begin(); |
279 it != agent_to_client_host_.end(); | 282 it != agent_to_client_host_.end(); |
280 ++it) { | 283 ++it) { |
281 if (it->first->GetRenderProcessId() == process_id) | 284 if (it->first->GetRenderProcessId() == process_id) |
282 return; | 285 return; |
283 } | 286 } |
284 // We've disconnected from the last renderer -> revoke cookie permissions. | 287 // We've disconnected from the last renderer -> revoke cookie permissions. |
285 ChildProcessSecurityPolicyImpl::GetInstance()->RevokeReadRawCookies( | 288 ChildProcessSecurityPolicyImpl::GetInstance()->RevokeReadRawCookies( |
286 process_id); | 289 process_id); |
287 } | 290 } |
288 | 291 |
289 void DevToolsManagerImpl::CloseAllClientHosts() { | 292 void DevToolsManagerImpl::CloseAllClientHosts() { |
290 std::vector<DevToolsAgentHost*> agents; | 293 std::vector<DevToolsAgentHost*> agents; |
291 for (AgentToClientHostMap::iterator it = | 294 for (AgentToClientHostMap::iterator it = |
292 agent_to_client_host_.begin(); | 295 agent_to_client_host_.begin(); |
293 it != agent_to_client_host_.end(); ++it) { | 296 it != agent_to_client_host_.end(); ++it) { |
294 agents.push_back(it->first); | 297 agents.push_back(it->first); |
295 } | 298 } |
296 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); | 299 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); |
297 it != agents.end(); ++it) { | 300 it != agents.end(); ++it) { |
298 UnregisterDevToolsClientHostFor(*it); | 301 UnregisterDevToolsClientHostFor(*it); |
299 } | 302 } |
300 } | 303 } |
301 | 304 |
302 } // namespace content | 305 } // namespace content |
OLD | NEW |