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

Unified Diff: content/browser/gpu/gpu_process_host_ui_shim.cc

Issue 7740066: Remove static initializers from GpuProcessHost and GpuProcessHostUIShim. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/gpu_process_host_ui_shim.cc
===================================================================
--- content/browser/gpu/gpu_process_host_ui_shim.cc (revision 98804)
+++ content/browser/gpu/gpu_process_host_ui_shim.cc (working copy)
@@ -9,6 +9,7 @@
#include "base/id_map.h"
#include "base/process_util.h"
#include "base/debug/trace_event.h"
+#include "base/lazy_instance.h"
#include "content/browser/browser_thread.h"
#include "content/browser/gpu/gpu_data_manager.h"
#include "content/browser/gpu/gpu_process_host.h"
@@ -31,7 +32,8 @@
#undef DestroyAll
#endif
-IDMap<GpuProcessHostUIShim> g_hosts_by_id;
+base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id(
+ base::LINKER_INITIALIZED);
class SendOnIOThreadTask : public Task {
public:
@@ -71,7 +73,7 @@
GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id)
: host_id_(host_id) {
- g_hosts_by_id.AddWithID(this, host_id_);
+ g_hosts_by_id.Pointer()->AddWithID(this, host_id_);
}
// static
@@ -89,8 +91,8 @@
// static
void GpuProcessHostUIShim::DestroyAll() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- while (!g_hosts_by_id.IsEmpty()) {
- IDMap<GpuProcessHostUIShim>::iterator it(&g_hosts_by_id);
+ while (!g_hosts_by_id.Pointer()->IsEmpty()) {
+ IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer());
delete it.GetCurrentValue();
}
}
@@ -98,7 +100,7 @@
// static
GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- return g_hosts_by_id.Lookup(host_id);
+ return g_hosts_by_id.Pointer()->Lookup(host_id);
}
bool GpuProcessHostUIShim::Send(IPC::Message* msg) {
@@ -137,7 +139,7 @@
GpuProcessHostUIShim::~GpuProcessHostUIShim() {
DCHECK(CalledOnValidThread());
- g_hosts_by_id.Remove(host_id_);
+ g_hosts_by_id.Pointer()->Remove(host_id_);
}
bool GpuProcessHostUIShim::OnControlMessageReceived(
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698