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

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

Issue 25571005: DevTools: Never instantiate DevToolsAgentHost on threads other than UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
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 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "content/browser/devtools/devtools_manager_impl.h" 12 #include "content/browser/devtools/devtools_manager_impl.h"
13 #include "content/public/browser/browser_thread.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 namespace { 17 namespace {
17 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; 18 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances;
18 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; 19 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER;
19 } // namespace 20 } // namespace
20 21
21 DevToolsAgentHostImpl::DevToolsAgentHostImpl() 22 DevToolsAgentHostImpl::DevToolsAgentHostImpl()
22 : close_listener_(NULL), 23 : close_listener_(NULL),
23 id_(base::GenerateGUID()) { 24 id_(base::GenerateGUID()) {
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
24 g_instances.Get()[id_] = this; 26 g_instances.Get()[id_] = this;
25 } 27 }
26 28
27 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() { 29 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() {
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
28 g_instances.Get().erase(g_instances.Get().find(id_)); 31 g_instances.Get().erase(g_instances.Get().find(id_));
29 } 32 }
30 33
31 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId( 34 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId(
32 const std::string& id) { 35 const std::string& id) {
33 if (g_instances == NULL) 36 if (g_instances == NULL)
34 return NULL; 37 return NULL;
35 Instances::iterator it = g_instances.Get().find(id); 38 Instances::iterator it = g_instances.Get().find(id);
36 if (it == g_instances.Get().end()) 39 if (it == g_instances.Get().end())
37 return NULL; 40 return NULL;
(...skipping 21 matching lines...) Expand all
59 62
60 void DevToolsAgentHostImpl::NotifyCloseListener() { 63 void DevToolsAgentHostImpl::NotifyCloseListener() {
61 if (close_listener_) { 64 if (close_listener_) {
62 scoped_refptr<DevToolsAgentHostImpl> protect(this); 65 scoped_refptr<DevToolsAgentHostImpl> protect(this);
63 close_listener_->AgentHostClosing(this); 66 close_listener_->AgentHostClosing(this);
64 close_listener_ = NULL; 67 close_listener_ = NULL;
65 } 68 }
66 } 69 }
67 70
68 } // namespace content 71 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/debugger/debugger_api.cc ('k') | content/browser/devtools/devtools_http_handler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698