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

Unified Diff: content/browser/debugger/devtools_http_protocol_handler.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/devtools_http_protocol_handler.cc
diff --git a/content/browser/debugger/devtools_http_protocol_handler.cc b/content/browser/debugger/devtools_http_protocol_handler.cc
index c16659ccb75d432e30bf05c876f9a636805814fd..a7c47305247fed1085b5709b893e80f0425325d5 100644
--- a/content/browser/debugger/devtools_http_protocol_handler.cc
+++ b/content/browser/debugger/devtools_http_protocol_handler.cc
@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "base/json/json_writer.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/message_loop_proxy.h"
#include "base/string_number_conversions.h"
@@ -92,16 +93,16 @@ class TabContentsIDHelper : public TabContentsObserver {
public:
static int GetID(TabContents* tab) {
- TabContentsToIdMap::iterator it = tabcontents_to_id_.find(tab);
- if (it != tabcontents_to_id_.end())
+ TabContentsToIdMap::iterator it = tabcontents_to_id_.Get().find(tab);
+ if (it != tabcontents_to_id_.Get().end())
return it->second;
TabContentsIDHelper* wrapper = new TabContentsIDHelper(tab);
return wrapper->id_;
}
static TabContents* GetTabContents(int id) {
- IdToTabContentsMap::iterator it = id_to_tabcontents_.find(id);
- if (it != id_to_tabcontents_.end())
+ IdToTabContentsMap::iterator it = id_to_tabcontents_.Get().find(id);
+ if (it != id_to_tabcontents_.Get().end())
return it->second;
return NULL;
}
@@ -110,27 +111,37 @@ class TabContentsIDHelper : public TabContentsObserver {
explicit TabContentsIDHelper(TabContents* tab)
: TabContentsObserver(tab),
id_(next_id++) {
- id_to_tabcontents_[id_] = tab;
- tabcontents_to_id_[tab] = id_;
+ id_to_tabcontents_.Get()[id_] = tab;
+ tabcontents_to_id_.Get()[tab] = id_;
}
virtual ~TabContentsIDHelper() {}
virtual void TabContentsDestroyed(TabContents* tab) {
- id_to_tabcontents_.erase(id_);
- tabcontents_to_id_.erase(tab);
+ id_to_tabcontents_.Get().erase(id_);
+ tabcontents_to_id_.Get().erase(tab);
delete this;
}
int id_;
typedef std::map<int, TabContents*> IdToTabContentsMap;
- static IdToTabContentsMap id_to_tabcontents_;
+ static base::LazyInstance<IdToTabContentsMap,
Mark Mentovai 2011/11/07 22:34:15 Note that I have no real concern with private + st
+ base::LeakyLazyInstanceTraits<IdToTabContentsMap> >
+ id_to_tabcontents_;
typedef std::map<TabContents*, int> TabContentsToIdMap;
- static TabContentsToIdMap tabcontents_to_id_;
+ static base::LazyInstance<TabContentsToIdMap,
+ base::LeakyLazyInstanceTraits<TabContentsToIdMap> >
+ tabcontents_to_id_;
};
-TabContentsIDHelper::IdToTabContentsMap TabContentsIDHelper::id_to_tabcontents_;
-TabContentsIDHelper::TabContentsToIdMap TabContentsIDHelper::tabcontents_to_id_;
+base::LazyInstance<
+ TabContentsIDHelper::IdToTabContentsMap,
+ base::LeakyLazyInstanceTraits<TabContentsIDHelper::IdToTabContentsMap> >
+ TabContentsIDHelper::id_to_tabcontents_(base::LINKER_INITIALIZED);
+base::LazyInstance<
+ TabContentsIDHelper::TabContentsToIdMap,
+ base::LeakyLazyInstanceTraits<TabContentsIDHelper::TabContentsToIdMap> >
+ TabContentsIDHelper::tabcontents_to_id_(base::LINKER_INITIALIZED);
} // namespace

Powered by Google App Engine
This is Rietveld 408576698