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

Side by Side Diff: content/browser/debugger/devtools_manager.cc

Issue 8508004: Switch content/browser/debugger to base::Bind (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/debugger/devtools_manager.h" 5 #include "content/browser/debugger/devtools_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h"
9 #include "base/message_loop.h" 10 #include "base/message_loop.h"
10 #include "content/browser/browsing_instance.h" 11 #include "content/browser/browsing_instance.h"
11 #include "content/browser/child_process_security_policy.h" 12 #include "content/browser/child_process_security_policy.h"
12 #include "content/browser/debugger/devtools_client_host.h" 13 #include "content/browser/debugger/devtools_client_host.h"
13 #include "content/browser/debugger/devtools_netlog_observer.h" 14 #include "content/browser/debugger/devtools_netlog_observer.h"
14 #include "content/browser/debugger/render_view_devtools_agent_host.h" 15 #include "content/browser/debugger/render_view_devtools_agent_host.h"
15 #include "content/browser/renderer_host/render_view_host.h" 16 #include "content/browser/renderer_host/render_view_host.h"
16 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/content_browser_client.h" 19 #include "content/public/browser/content_browser_client.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 DevToolsClientHost* client_host) { 221 DevToolsClientHost* client_host) {
221 DCHECK(agent_to_client_host_.find(agent_host) == 222 DCHECK(agent_to_client_host_.find(agent_host) ==
222 agent_to_client_host_.end()); 223 agent_to_client_host_.end());
223 DCHECK(client_to_agent_host_.find(client_host) == 224 DCHECK(client_to_agent_host_.find(client_host) ==
224 client_to_agent_host_.end()); 225 client_to_agent_host_.end());
225 226
226 if (client_to_agent_host_.empty()) { 227 if (client_to_agent_host_.empty()) {
227 BrowserThread::PostTask( 228 BrowserThread::PostTask(
228 BrowserThread::IO, 229 BrowserThread::IO,
229 FROM_HERE, 230 FROM_HERE,
230 NewRunnableFunction(&DevToolsNetLogObserver::Attach)); 231 base::Bind(&DevToolsNetLogObserver::Attach));
231 } 232 }
232 agent_to_client_host_[agent_host] = client_host; 233 agent_to_client_host_[agent_host] = client_host;
233 client_to_agent_host_[client_host] = agent_host; 234 client_to_agent_host_[client_host] = agent_host;
234 agent_host->set_close_listener(this); 235 agent_host->set_close_listener(this);
235 236
236 int process_id = agent_host->GetRenderProcessId(); 237 int process_id = agent_host->GetRenderProcessId();
237 if (process_id != -1) 238 if (process_id != -1)
238 ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies(process_id); 239 ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies(process_id);
239 } 240 }
240 241
241 void DevToolsManager::UnbindClientHost(DevToolsAgentHost* agent_host, 242 void DevToolsManager::UnbindClientHost(DevToolsAgentHost* agent_host,
242 DevToolsClientHost* client_host) { 243 DevToolsClientHost* client_host) {
243 DCHECK(agent_host); 244 DCHECK(agent_host);
244 DCHECK(agent_to_client_host_.find(agent_host)->second == 245 DCHECK(agent_to_client_host_.find(agent_host)->second ==
245 client_host); 246 client_host);
246 DCHECK(client_to_agent_host_.find(client_host)->second == 247 DCHECK(client_to_agent_host_.find(client_host)->second ==
247 agent_host); 248 agent_host);
248 agent_host->set_close_listener(NULL); 249 agent_host->set_close_listener(NULL);
249 250
250 agent_to_client_host_.erase(agent_host); 251 agent_to_client_host_.erase(agent_host);
251 client_to_agent_host_.erase(client_host); 252 client_to_agent_host_.erase(client_host);
252 agent_runtime_states_.erase(agent_host); 253 agent_runtime_states_.erase(agent_host);
253 254
254 if (client_to_agent_host_.empty()) { 255 if (client_to_agent_host_.empty()) {
255 BrowserThread::PostTask( 256 BrowserThread::PostTask(
256 BrowserThread::IO, 257 BrowserThread::IO,
257 FROM_HERE, 258 FROM_HERE,
258 NewRunnableFunction(&DevToolsNetLogObserver::Detach)); 259 base::Bind(&DevToolsNetLogObserver::Detach));
259 } 260 }
260 agent_host->Detach(); 261 agent_host->Detach();
261 262
262 int process_id = agent_host->GetRenderProcessId(); 263 int process_id = agent_host->GetRenderProcessId();
263 if (process_id == -1) 264 if (process_id == -1)
264 return; 265 return;
265 for (AgentToClientHostMap::iterator it = agent_to_client_host_.begin(); 266 for (AgentToClientHostMap::iterator it = agent_to_client_host_.begin();
266 it != agent_to_client_host_.end(); 267 it != agent_to_client_host_.end();
267 ++it) { 268 ++it) {
268 if (it->first->GetRenderProcessId() == process_id) 269 if (it->first->GetRenderProcessId() == process_id)
269 return; 270 return;
270 } 271 }
271 // We've disconnected from the last renderer -> revoke cookie permissions. 272 // We've disconnected from the last renderer -> revoke cookie permissions.
272 ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id); 273 ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id);
273 } 274 }
274 275
275 void DevToolsManager::CloseAllClientHosts() { 276 void DevToolsManager::CloseAllClientHosts() {
276 std::vector<DevToolsAgentHost*> agents; 277 std::vector<DevToolsAgentHost*> agents;
277 for (AgentToClientHostMap::iterator it = 278 for (AgentToClientHostMap::iterator it =
278 agent_to_client_host_.begin(); 279 agent_to_client_host_.begin();
279 it != agent_to_client_host_.end(); ++it) { 280 it != agent_to_client_host_.end(); ++it) {
280 agents.push_back(it->first); 281 agents.push_back(it->first);
281 } 282 }
282 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); 283 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin();
283 it != agents.end(); ++it) { 284 it != agents.end(); ++it) {
284 UnregisterDevToolsClientHostFor(*it); 285 UnregisterDevToolsClientHostFor(*it);
285 } 286 }
286 } 287 }
OLDNEW
« no previous file with comments | « content/browser/debugger/devtools_http_protocol_handler.cc ('k') | content/browser/debugger/worker_devtools_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698