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

Unified Diff: content/browser/browser_thread_impl.cc

Issue 9696034: Avoid creating BrowserThreadGlobals when we don't need to. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert d'tor changes, as globals are sure to exist already here Created 8 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_thread_impl.cc
diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc
index 590ab15e53830465def0d36f18f0fa7354f22770..21b84965796bd6868e62b18751f727ed829769b0 100644
--- a/content/browser/browser_thread_impl.cc
+++ b/content/browser/browser_thread_impl.cc
@@ -242,6 +242,9 @@ base::SequencedWorkerPool* BrowserThread::GetBlockingPool() {
// static
bool BrowserThread::IsWellKnownThread(ID identifier) {
+ if (g_globals == NULL)
+ return false;
+
BrowserThreadGlobals& globals = g_globals.Get();
base::AutoLock lock(globals.lock);
return (identifier >= 0 && identifier < ID_COUNT &&
@@ -265,6 +268,9 @@ bool BrowserThread::CurrentlyOn(ID identifier) {
// static
bool BrowserThread::IsMessageLoopValid(ID identifier) {
+ if (g_globals == NULL)
+ return false;
+
BrowserThreadGlobals& globals = g_globals.Get();
base::AutoLock lock(globals.lock);
DCHECK(identifier >= 0 && identifier < ID_COUNT);
@@ -348,6 +354,9 @@ bool BrowserThread::PostTaskAndReply(
// static
bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) {
+ if (g_globals == NULL)
+ return false;
+
// We shouldn't use MessageLoop::current() since it uses LazyInstance which
// may be deleted by ~AtExitManager when a WorkerPool thread calls this
// function.
@@ -376,6 +385,9 @@ BrowserThread::GetMessageLoopProxyForThread(ID identifier) {
// static
MessageLoop* BrowserThread::UnsafeGetMessageLoopForThread(ID identifier) {
+ if (g_globals == NULL)
+ return NULL;
+
BrowserThreadGlobals& globals = g_globals.Get();
base::AutoLock lock(globals.lock);
base::Thread* thread = globals.threads[identifier];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698