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

Unified Diff: content/browser/debugger/render_view_devtools_agent_host.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: . 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
Index: content/browser/debugger/render_view_devtools_agent_host.cc
diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc
index 5a49afa2841083f9e4f228814404f300f798d010..b7ed381453d03908b3a9461c5580e7cb61ae7350 100644
--- a/content/browser/debugger/render_view_devtools_agent_host.cc
+++ b/content/browser/debugger/render_view_devtools_agent_host.cc
@@ -5,6 +5,7 @@
#include "content/browser/debugger/render_view_devtools_agent_host.h"
#include "base/basictypes.h"
+#include "base/lazy_instance.h"
#include "content/browser/debugger/devtools_manager.h"
#include "content/browser/debugger/render_view_devtools_agent_host.h"
#include "content/browser/renderer_host/render_process_host.h"
@@ -16,12 +17,18 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
-RenderViewDevToolsAgentHost::Instances RenderViewDevToolsAgentHost::instances_;
+typedef std::map<RenderViewHost*, RenderViewDevToolsAgentHost*> Instances;
+
+namespace {
+base::LazyInstance<Instances,
+ base::LeakyLazyInstanceTraits<Instances> >
+ instances_(base::LINKER_INITIALIZED);
Mark Mentovai 2011/11/07 22:34:15 This should not be named instances_ now.
Nico 2011/11/07 23:29:21 Done.
+} // namespace
DevToolsAgentHost* RenderViewDevToolsAgentHost::FindFor(
RenderViewHost* rvh) {
- Instances::iterator it = instances_.find(rvh);
- if (it != instances_.end())
+ Instances::iterator it = instances_.Get().find(rvh);
+ if (it != instances_.Get().end())
return it->second;
return new RenderViewDevToolsAgentHost(rvh);
}
@@ -32,8 +39,8 @@ bool RenderViewDevToolsAgentHost::IsDebuggerAttached(
if (!devtools_manager)
return false;
RenderViewHostDelegate* delegate = tab_contents;
- for (Instances::iterator it = instances_.begin();
- it != instances_.end(); ++it) {
+ for (Instances::iterator it = instances_.Get().begin();
+ it != instances_.Get().end(); ++it) {
if (it->first->delegate() != delegate)
continue;
if (devtools_manager->GetDevToolsClientHostFor(it->second))
@@ -45,7 +52,7 @@ bool RenderViewDevToolsAgentHost::IsDebuggerAttached(
RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh)
: RenderViewHostObserver(rvh),
render_view_host_(rvh) {
- instances_[rvh] = this;
+ instances_.Get()[rvh] = this;
}
void RenderViewDevToolsAgentHost::SendMessageToAgent(IPC::Message* msg) {
@@ -66,7 +73,7 @@ int RenderViewDevToolsAgentHost::GetRenderProcessId() {
}
RenderViewDevToolsAgentHost::~RenderViewDevToolsAgentHost() {
- instances_.erase(render_view_host_);
+ instances_.Get().erase(render_view_host_);
}
void RenderViewDevToolsAgentHost::RenderViewHostDestroyed(RenderViewHost* rvh) {

Powered by Google App Engine
This is Rietveld 408576698