summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-07 12:03:42 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-07 12:03:42 +0000
commited10dd138cfcb174ac890133e7fe40da91e5b04f (patch)
tree56316df961cf55cf73884d7b886eca581a7ca46f /content
parent2a349e9b87611c6971a410a056376e87808fbfca (diff)
downloadchromium_src-ed10dd138cfcb174ac890133e7fe40da91e5b04f.zip
chromium_src-ed10dd138cfcb174ac890133e7fe40da91e5b04f.tar.gz
chromium_src-ed10dd138cfcb174ac890133e7fe40da91e5b04f.tar.bz2
Remove BrowserThread::UnsafeGetBrowserThread, add UnsafeGetMessageLoopForThread.
This also removes several accessors on BrowserProcess that are no longer used. I wanted to remove all retrieval of MessageLoop objects via BrowserThread, but this proved harder than it looked, because several net:: classes use MessageLoop and have fairly deep assumptions that it is a real MessageLoop, e.g. they use MessageLoopForIO with its IO observers and so forth. Therefore, we now have UnsafeGetMessageLoopForThread but UnsafeGetBrowserThread is gone. TBR=abodenha@chromium.org BUG=98716 Review URL: http://codereview.chromium.org/8769013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113377 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/browser_thread_impl.cc11
-rw-r--r--content/public/browser/browser_thread.h38
-rw-r--r--content/shell/shell_browser_context.cc6
3 files changed, 14 insertions, 41 deletions
diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc
index 9cea8f4..f37c5b4 100644
--- a/content/browser/browser_thread_impl.cc
+++ b/content/browser/browser_thread_impl.cc
@@ -395,17 +395,16 @@ BrowserThread::GetMessageLoopProxyForThread(
return proxy;
}
-base::Thread* BrowserThread::UnsafeGetBrowserThread(ID identifier) {
+// static
+MessageLoop* BrowserThread::UnsafeGetMessageLoopForThread(ID identifier) {
base::AutoLock lock(g_lock.Get());
base::Thread* thread = g_browser_threads[identifier];
DCHECK(thread);
- return thread;
-}
-
-MessageLoop* BrowserThread::UnsafeGetMessageLoop(ID identifier) {
- return UnsafeGetBrowserThread(identifier)->message_loop();
+ MessageLoop* loop = thread->message_loop();
+ return loop;
}
+// static
void BrowserThread::SetDelegate(ID identifier,
BrowserThreadDelegate* delegate) {
using base::subtle::AtomicWord;
diff --git a/content/public/browser/browser_thread.h b/content/public/browser/browser_thread.h
index 981eed4..743bec6 100644
--- a/content/public/browser/browser_thread.h
+++ b/content/public/browser/browser_thread.h
@@ -177,39 +177,15 @@ class CONTENT_EXPORT BrowserThread {
static scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxyForThread(
ID identifier);
- // Gets the Thread object for the specified thread, or NULL if the
- // thread has not been created (or has been destroyed during
- // shutdown).
+ // Returns a pointer to the thread's message loop, which will become
+ // invalid during shutdown, so you probably shouldn't hold onto it.
//
- // Before calling this, you must have called content::ContentMain
- // with a command-line that would specify a browser process (e.g. an
- // empty command line).
+ // This must not be called before the thread is started, or after
+ // the thread is stopped, or it will DCHECK.
//
- // It is unsafe to store this pointer as it may become invalid close
- // to shutdown.
- //
- // TODO(joi): Remove this once clients such as BrowserProcessImpl
- // (and classes that call things like
- // g_browser_process->file_thread()) are switched to using
- // MessageLoopProxy.
- static base::Thread* UnsafeGetBrowserThread(ID identifier);
-
- // Gets the MessageLoop for the specified thread, or NULL if the
- // thread has not been created (or has been destroyed during
- // shutdown).
- //
- // Before calling this, you must have called content::ContentMain
- // with a command-line that would specify a browser process (e.g. an
- // empty command line).
- //
- // It is unsafe to store this pointer as it may become invalid close
- // to shutdown.
- //
- // TODO(joi): Remove this once clients such as BrowserProcessImpl
- // (and classes that call things like
- // g_browser_process->file_thread()) are switched to using
- // MessageLoopProxy.
- static MessageLoop* UnsafeGetMessageLoop(ID identifier);
+ // Ownership remains with the BrowserThread implementation, so you
+ // must not delete the pointer.
+ static MessageLoop* UnsafeGetMessageLoopForThread(ID identifier);
// Sets the delegate for the specified BrowserThread.
//
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc
index b72beaf..f5c6996 100644
--- a/content/shell/shell_browser_context.cc
+++ b/content/shell/shell_browser_context.cc
@@ -142,10 +142,8 @@ net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() {
if (!url_request_getter_) {
url_request_getter_ = new ShellURLRequestContextGetter(
GetPath(),
- BrowserThread::UnsafeGetBrowserThread(
- BrowserThread::IO)->message_loop(),
- BrowserThread::UnsafeGetBrowserThread(
- BrowserThread::FILE)->message_loop());
+ BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
+ BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE));
}
return url_request_getter_;
}