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

Unified Diff: content/renderer/devtools_agent.cc

Issue 8493016: content: Remove 16 exit time destructors and 15 static initializers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac compile 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/devtools_agent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/devtools_agent.cc
diff --git a/content/renderer/devtools_agent.cc b/content/renderer/devtools_agent.cc
index 7516b2d572808ebf3f882e76b134001957c580e7..cedb9d2070d44d1e19fa4c41f5e2f2601530604e 100644
--- a/content/renderer/devtools_agent.cc
+++ b/content/renderer/devtools_agent.cc
@@ -7,6 +7,7 @@
#include <map>
#include "base/command_line.h"
+#include "base/lazy_instance.h"
#include "base/message_loop.h"
#include "base/process.h"
#include "base/string_number_conversions.h"
@@ -51,15 +52,16 @@ class WebKitClientMessageLoopImpl
MessageLoop* message_loop_;
};
-} // namespace
+typedef std::map<int, DevToolsAgent*> IdToAgentMap;
+base::LazyInstance<IdToAgentMap, base::LeakyLazyInstanceTraits<IdToAgentMap> >
+ g_agent_for_routing_id(base::LINKER_INITIALIZED);
-// static
-std::map<int, DevToolsAgent*> DevToolsAgent::agent_for_routing_id_;
+} // namespace
DevToolsAgent::DevToolsAgent(RenderViewImpl* render_view)
: content::RenderViewObserver(render_view),
is_attached_(false) {
- agent_for_routing_id_[routing_id()] = this;
+ g_agent_for_routing_id.Get()[routing_id()] = this;
CommandLine* cmd = CommandLine::ForCurrentProcess();
expose_v8_debugger_protocol_ = cmd->HasSwitch(switches::kRemoteShellPort);
@@ -70,7 +72,7 @@ DevToolsAgent::DevToolsAgent(RenderViewImpl* render_view)
}
DevToolsAgent::~DevToolsAgent() {
- agent_for_routing_id_.erase(routing_id());
+ g_agent_for_routing_id.Get().erase(routing_id());
}
// Called on the Renderer thread.
@@ -136,9 +138,8 @@ void DevToolsAgent::clearBrowserCookies() {
// static
DevToolsAgent* DevToolsAgent::FromHostId(int host_id) {
- std::map<int, DevToolsAgent*>::iterator it =
- agent_for_routing_id_.find(host_id);
- if (it != agent_for_routing_id_.end()) {
+ IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(host_id);
+ if (it != g_agent_for_routing_id.Get().end()) {
return it->second;
}
return NULL;
« no previous file with comments | « content/renderer/devtools_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698