summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_process.h3
-rw-r--r--chrome/browser/browser_process_impl.cc13
-rw-r--r--chrome/browser/browser_process_impl.h3
-rw-r--r--chrome/browser/io_thread.cc15
-rw-r--r--chrome/browser/io_thread.h8
-rw-r--r--chrome/browser/net/proxy_service_factory.cc4
-rw-r--r--chrome/browser/process_singleton_linux.cc16
-rw-r--r--chrome/test/base/testing_browser_process.cc4
-rw-r--r--chrome/test/base/testing_browser_process.h1
-rw-r--r--content/browser/browser_thread_impl.cc4
-rw-r--r--content/public/browser/browser_thread.h23
11 files changed, 43 insertions, 51 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index 8cb0e37..faaa90c 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -134,9 +134,6 @@ class BrowserProcess {
// database. History has its own thread since it has much higher traffic.
virtual base::Thread* db_thread() = 0;
- // Returns the thread that is used for background cache operations.
- virtual base::Thread* cache_thread() = 0;
-
// Returns the thread that is used for health check of all browser threads.
virtual WatchDogThread* watchdog_thread() = 0;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 85d07f2..37bdd925 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -332,7 +332,8 @@ unsigned int BrowserProcessImpl::ReleaseModule() {
// of it on shutdown for valid reasons.
base::ThreadRestrictions::SetIOAllowed(true);
CHECK(!BrowserList::GetLastActive());
- io_thread()->message_loop()->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::IO,
FROM_HERE,
base::IgnoreReturn<bool>(
base::Bind(&base::ThreadRestrictions::SetIOAllowed, true)));
@@ -424,16 +425,6 @@ base::Thread* BrowserProcessImpl::db_thread() {
return BrowserThread::UnsafeGetBrowserThread(BrowserThread::DB);
}
-base::Thread* BrowserProcessImpl::process_launcher_thread() {
- DCHECK(CalledOnValidThread());
- return BrowserThread::UnsafeGetBrowserThread(BrowserThread::PROCESS_LAUNCHER);
-}
-
-base::Thread* BrowserProcessImpl::cache_thread() {
- DCHECK(CalledOnValidThread());
- return BrowserThread::UnsafeGetBrowserThread(BrowserThread::CACHE);
-}
-
WatchDogThread* BrowserProcessImpl::watchdog_thread() {
DCHECK(CalledOnValidThread());
if (!created_watchdog_thread_)
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 2227ab0..2fb2095 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -59,8 +59,6 @@ class BrowserProcessImpl : public BrowserProcess,
void PreStopThread(content::BrowserThread::ID identifier);
void PostStopThread(content::BrowserThread::ID identifier);
- base::Thread* process_launcher_thread();
-
// BrowserProcess methods
virtual void EndSession() OVERRIDE;
virtual ResourceDispatcherHost* resource_dispatcher_host() OVERRIDE;
@@ -68,7 +66,6 @@ class BrowserProcessImpl : public BrowserProcess,
virtual IOThread* io_thread() OVERRIDE;
virtual base::Thread* file_thread() OVERRIDE;
virtual base::Thread* db_thread() OVERRIDE;
- virtual base::Thread* cache_thread() OVERRIDE;
virtual WatchDogThread* watchdog_thread() OVERRIDE;
#if defined(OS_CHROMEOS)
virtual base::Thread* web_socket_proxy_thread() OVERRIDE;
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 12b0c50..130a932 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -589,11 +589,6 @@ void IOThread::ClearHostCache() {
host_cache->clear();
}
-MessageLoop* IOThread::message_loop() const {
- return BrowserThread::UnsafeGetBrowserThread(
- BrowserThread::IO)->message_loop();
-}
-
net::SSLConfigService* IOThread::GetSSLConfigService() {
return ssl_config_service_manager_->Get();
}
@@ -602,7 +597,7 @@ void IOThread::InitSystemRequestContext() {
if (system_url_request_context_getter_)
return;
// If we're in unit_tests, IOThread may not be run.
- if (!message_loop())
+ if (!BrowserThread::IsMessageLoopValid(BrowserThread::IO))
return;
ChromeProxyConfigService* proxy_config_service =
ProxyServiceFactory::CreateProxyConfigService();
@@ -615,9 +610,11 @@ void IOThread::InitSystemRequestContext() {
new SystemURLRequestContextGetter(this);
// Safe to post an unretained this pointer, since IOThread is
// guaranteed to outlive the IO BrowserThread.
- message_loop()->PostTask(
- FROM_HERE, base::Bind(&IOThread::InitSystemRequestContextOnIOThread,
- base::Unretained(this)));
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&IOThread::InitSystemRequestContextOnIOThread,
+ base::Unretained(this)));
}
void IOThread::InitSystemRequestContextOnIOThread() {
diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h
index ccf1c83..207257a 100644
--- a/chrome/browser/io_thread.h
+++ b/chrome/browser/io_thread.h
@@ -47,8 +47,7 @@ class URLSecurityManager;
} // namespace net
// Contains state associated with, initialized and cleaned up on, and
-// primarily used on, the IO thread. Also acts as a convenience
-// accessor to the Thread object for the IO thread.
+// primarily used on, the IO thread.
class IOThread : public content::BrowserThreadDelegate {
public:
struct Globals {
@@ -115,11 +114,6 @@ class IOThread : public content::BrowserThreadDelegate {
// called on the IO thread.
void ClearHostCache();
- // Convenience method similar to base::Thread, giving access to the
- // actual IO thread.
- // TODO(joi): Remove this in follow-up changes.
- MessageLoop* message_loop() const;
-
private:
// BrowserThreadDelegate implementation, runs on the IO thread.
// This handles initialization and destruction of state that must
diff --git a/chrome/browser/net/proxy_service_factory.cc b/chrome/browser/net/proxy_service_factory.cc
index d85ba01..1ef72f3 100644
--- a/chrome/browser/net/proxy_service_factory.cc
+++ b/chrome/browser/net/proxy_service_factory.cc
@@ -46,8 +46,8 @@ ChromeProxyConfigService* ProxyServiceFactory::CreateProxyConfigService() {
// that code be moved to chrome/browser instead of being in net, so that it
// can use BrowserThread instead of raw MessageLoop pointers? See bug 25354.
base_service = net::ProxyService::CreateSystemProxyConfigService(
- g_browser_process->io_thread()->message_loop(),
- g_browser_process->file_thread()->message_loop());
+ BrowserThread::UnsafeGetMessageLoop(BrowserThread::IO),
+ BrowserThread::UnsafeGetMessageLoop(BrowserThread::FILE));
#endif // !defined(OS_CHROMEOS)
return new ChromeProxyConfigService(base_service);
diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc
index cbf6492f..34feef1 100644
--- a/chrome/browser/process_singleton_linux.cc
+++ b/chrome/browser/process_singleton_linux.cc
@@ -995,15 +995,13 @@ bool ProcessSingleton::Create() {
if (listen(sock, 5) < 0)
NOTREACHED() << "listen failed: " << safe_strerror(errno);
- // Normally we would use BrowserThread, but the IO thread hasn't started yet.
- // Using g_browser_process, we start the thread so we can listen on the
- // socket.
- MessageLoop* ml = g_browser_process->io_thread()->message_loop();
- DCHECK(ml);
- ml->PostTask(FROM_HERE, base::Bind(
- &ProcessSingleton::LinuxWatcher::StartListening,
- watcher_.get(),
- sock));
+ DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&ProcessSingleton::LinuxWatcher::StartListening,
+ watcher_.get(),
+ sock));
return true;
}
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index 0888530..8610f47 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -51,10 +51,6 @@ base::Thread* TestingBrowserProcess::db_thread() {
return NULL;
}
-base::Thread* TestingBrowserProcess::cache_thread() {
- return NULL;
-}
-
WatchDogThread* TestingBrowserProcess::watchdog_thread() {
return NULL;
}
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index ae65756..c00d351 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -51,7 +51,6 @@ class TestingBrowserProcess : public BrowserProcess {
virtual base::Thread* file_thread() OVERRIDE;
virtual base::Thread* db_thread() OVERRIDE;
- virtual base::Thread* cache_thread() OVERRIDE;
virtual WatchDogThread* watchdog_thread() OVERRIDE;
#if defined(OS_CHROMEOS)
diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc
index 0025f77..9f8cc35 100644
--- a/content/browser/browser_thread_impl.cc
+++ b/content/browser/browser_thread_impl.cc
@@ -401,6 +401,10 @@ base::Thread* BrowserThread::UnsafeGetBrowserThread(ID identifier) {
return thread;
}
+MessageLoop* BrowserThread::UnsafeGetMessageLoop(ID identifier) {
+ return UnsafeGetBrowserThread(identifier)->message_loop();
+}
+
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 71d7472..9862684 100644
--- a/content/public/browser/browser_thread.h
+++ b/content/public/browser/browser_thread.h
@@ -17,6 +17,8 @@
#include "base/logging.h"
#endif // UNIT_TEST
+class MessageLoop;
+
namespace base {
class MessageLoopProxy;
class Thread;
@@ -179,8 +181,8 @@ class CONTENT_EXPORT BrowserThread {
// with a command-line that would specify a browser process (e.g. an
// empty command line).
//
- // This is unsafe as your pointer may become invalid close to
- // shutdown.
+ // 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
@@ -188,6 +190,23 @@ class CONTENT_EXPORT BrowserThread {
// 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);
+
// Sets the delegate for the specified BrowserThread.
//
// Only one delegate may be registered at a time. Delegates may be