summaryrefslogtreecommitdiffstats
path: root/chrome
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 /chrome
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 'chrome')
-rw-r--r--chrome/browser/browser_process.h36
-rw-r--r--chrome/browser/browser_process_impl.cc21
-rw-r--r--chrome/browser/browser_process_impl.h5
-rw-r--r--chrome/browser/chrome_browser_main.cc5
-rw-r--r--chrome/browser/chromeos/boot_times_loader.cc2
-rw-r--r--chrome/browser/chromeos/version_loader.cc10
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler.cc13
-rw-r--r--chrome/browser/metrics/metrics_service.cc4
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc3
-rw-r--r--chrome/browser/net/chrome_url_request_context.h4
-rw-r--r--chrome/browser/net/proxy_service_factory.cc4
-rw-r--r--chrome/browser/printing/printer_manager_dialog_win.cc9
-rw-r--r--chrome/browser/sessions/base_session_service.cc71
-rw-r--r--chrome/browser/sessions/base_session_service.h17
-rw-r--r--chrome/browser/sessions/session_service.cc10
-rw-r--r--chrome/browser/ui/browser_init.cc3
-rw-r--r--chrome/browser/ui/webui/options/advanced_options_utils_win.cc11
-rw-r--r--chrome/test/base/testing_browser_process.cc14
-rw-r--r--chrome/test/base/testing_browser_process.h8
19 files changed, 96 insertions, 154 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index c2bb8a7..abc4e14 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -44,10 +44,6 @@ class TabCloseableStateWatcher;
class ThumbnailGenerator;
class WatchDogThread;
-namespace base {
-class Thread;
-}
-
#if defined(OS_CHROMEOS)
namespace browser {
class OomPriorityManager;
@@ -114,35 +110,19 @@ class BrowserProcess {
// Returns the manager for desktop notifications.
virtual NotificationUIManager* notification_ui_manager() = 0;
- // Returns the thread that we perform I/O coordination on (network requests,
- // communication with renderers, etc.
- // NOTE: You should ONLY use this to pass to IPC or other objects which must
- // need a MessageLoop*. If you just want to post a task, use
- // BrowserThread::PostTask (or other variants) as they take care of checking
- // that a thread is still alive, race conditions, lifetime differences etc.
- // If you still must use this check the return value for NULL.
+ // Returns the state object for the thread that we perform I/O
+ // coordination on (network requests, communication with renderers,
+ // etc.
+ //
+ // Can be NULL close to startup and shutdown.
+ //
+ // NOTE: If you want to post a task to the IO thread, use
+ // BrowserThread::PostTask (or other variants).
virtual IOThread* io_thread() = 0;
- // Returns the thread that we perform random file operations on. For code
- // that wants to do I/O operations (not network requests or even file: URL
- // requests), this is the thread to use to avoid blocking the UI thread.
- // It might be nicer to have a thread pool for this kind of thing.
- virtual base::Thread* file_thread() = 0;
-
- // Returns the thread that is used for database operations such as the web
- // 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 health check of all browser threads.
virtual WatchDogThread* watchdog_thread() = 0;
-#if defined(OS_CHROMEOS)
- // Returns thread for websocket to TCP proxy.
- // TODO(dilmah): remove this thread. Instead provide this functionality via
- // hooks into websocket bridge layer.
- virtual base::Thread* web_socket_proxy_thread() = 0;
-#endif
-
virtual policy::BrowserPolicyConnector* browser_policy_connector() = 0;
virtual IconManager* icon_manager() = 0;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index cf3861a..4d13782 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -291,6 +291,10 @@ void BrowserProcessImpl::PostStopThread(BrowserThread::ID thread_id) {
// Reset associated state right after actual thread is stopped,
// as io_thread_.global_ cleanup happens in CleanUp on the IO
// thread, i.e. as the thread exits its message loop.
+ //
+ // This is important also because in various places, the
+ // IOThread object being NULL is considered synonymous with the
+ // IO thread having stopped.
io_thread_.reset();
break;
default:
@@ -414,16 +418,6 @@ IOThread* BrowserProcessImpl::io_thread() {
return io_thread_.get();
}
-base::Thread* BrowserProcessImpl::file_thread() {
- DCHECK(CalledOnValidThread());
- return BrowserThread::UnsafeGetBrowserThread(BrowserThread::FILE);
-}
-
-base::Thread* BrowserProcessImpl::db_thread() {
- DCHECK(CalledOnValidThread());
- return BrowserThread::UnsafeGetBrowserThread(BrowserThread::DB);
-}
-
WatchDogThread* BrowserProcessImpl::watchdog_thread() {
DCHECK(CalledOnValidThread());
if (!created_watchdog_thread_)
@@ -432,13 +426,6 @@ WatchDogThread* BrowserProcessImpl::watchdog_thread() {
return watchdog_thread_.get();
}
-#if defined(OS_CHROMEOS)
-base::Thread* BrowserProcessImpl::web_socket_proxy_thread() {
- DCHECK(CalledOnValidThread());
- return BrowserThread::UnsafeGetBrowserThread(BrowserThread::WEB_SOCKET_PROXY);
-}
-#endif
-
ProfileManager* BrowserProcessImpl::profile_manager() {
DCHECK(CalledOnValidThread());
if (!created_profile_manager_)
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 423202d..141a5d9 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -64,12 +64,7 @@ class BrowserProcessImpl : public BrowserProcess,
virtual ResourceDispatcherHost* resource_dispatcher_host() OVERRIDE;
virtual MetricsService* metrics_service() OVERRIDE;
virtual IOThread* io_thread() OVERRIDE;
- virtual base::Thread* file_thread() OVERRIDE;
- virtual base::Thread* db_thread() OVERRIDE;
virtual WatchDogThread* watchdog_thread() OVERRIDE;
-#if defined(OS_CHROMEOS)
- virtual base::Thread* web_socket_proxy_thread() OVERRIDE;
-#endif
virtual ProfileManager* profile_manager() OVERRIDE;
virtual PrefService* local_state() OVERRIDE;
virtual SidebarManager* sidebar_manager() OVERRIDE;
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 47261b7..6737eb6 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -1426,8 +1426,9 @@ void ChromeBrowserMainParts::PostStartThread(
#if defined(USE_LINUX_BREAKPAD)
// Needs to be called after we have chrome::DIR_USER_DATA and
// g_browser_process. This happens in PreCreateThreads.
- g_browser_process->file_thread()->message_loop()->PostTask(
- FROM_HERE, base::Bind(&GetLinuxDistroCallback));
+ BrowserThread::PostTask(BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&GetLinuxDistroCallback));
if (IsCrashReportingEnabled(local_state_))
InitCrashReporter();
diff --git a/chrome/browser/chromeos/boot_times_loader.cc b/chrome/browser/chromeos/boot_times_loader.cc
index 6a27400c..21f1632 100644
--- a/chrome/browser/chromeos/boot_times_loader.cc
+++ b/chrome/browser/chromeos/boot_times_loader.cc
@@ -121,7 +121,7 @@ BootTimesLoader* BootTimesLoader::Get() {
BootTimesLoader::Handle BootTimesLoader::GetBootTimes(
CancelableRequestConsumerBase* consumer,
BootTimesLoader::GetBootTimesCallback* callback) {
- if (!g_browser_process->file_thread()) {
+ if (!BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
// This should only happen if Chrome is shutting down, so we don't do
// anything.
return 0;
diff --git a/chrome/browser/chromeos/version_loader.cc b/chrome/browser/chromeos/version_loader.cc
index 82d56c0..b3ea12f 100644
--- a/chrome/browser/chromeos/version_loader.cc
+++ b/chrome/browser/chromeos/version_loader.cc
@@ -48,7 +48,7 @@ VersionLoader::Handle VersionLoader::GetVersion(
CancelableRequestConsumerBase* consumer,
const VersionLoader::GetVersionCallback& callback,
VersionFormat format) {
- if (!g_browser_process->file_thread()) {
+ if (!BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
// This should only happen if Chrome is shutting down, so we don't do
// anything.
return 0;
@@ -57,7 +57,8 @@ VersionLoader::Handle VersionLoader::GetVersion(
scoped_refptr<GetVersionRequest> request(new GetVersionRequest(callback));
AddRequest(request, consumer);
- g_browser_process->file_thread()->message_loop()->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
FROM_HERE,
NewRunnableMethod(backend_.get(), &Backend::GetVersion, request, format));
return request->handle();
@@ -66,7 +67,7 @@ VersionLoader::Handle VersionLoader::GetVersion(
VersionLoader::Handle VersionLoader::GetFirmware(
CancelableRequestConsumerBase* consumer,
const VersionLoader::GetFirmwareCallback& callback) {
- if (!g_browser_process->file_thread()) {
+ if (!BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
// This should only happen if Chrome is shutting down, so we don't do
// anything.
return 0;
@@ -75,7 +76,8 @@ VersionLoader::Handle VersionLoader::GetFirmware(
scoped_refptr<GetFirmwareRequest> request(new GetFirmwareRequest(callback));
AddRequest(request, consumer);
- g_browser_process->file_thread()->message_loop()->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
FROM_HERE,
NewRunnableMethod(backend_.get(), &Backend::GetFirmware, request));
return request->handle();
diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
index a3b45b3..ee497cc 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler.cc
@@ -17,9 +17,12 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/common/pref_names.h"
+#include "content/public/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
#include "net/base/escape.h"
+using content::BrowserThread;
+
// Whether we accept requests for launching external protocols. This is set to
// false every time an external protocol is requested, and set back to true on
// each user gesture. This variable should only be accessed from the UI thread.
@@ -283,12 +286,10 @@ void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(const GURL& url) {
#else
// Otherwise put this work on the file thread. On Windows ShellExecute may
// block for a significant amount of time, and it shouldn't hurt on Linux.
- MessageLoop* loop = g_browser_process->file_thread()->message_loop();
- if (loop == NULL) {
- return;
- }
-
- loop->PostTask(FROM_HERE, base::Bind(&platform_util::OpenExternal, url));
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&platform_util::OpenExternal, url));
#endif
}
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 54519dd..90ac13e 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -800,7 +800,9 @@ void MetricsService::StartRecording() {
// initialization steps (such as plugin list generation) necessary
// for sending the initial log. This avoids blocking the main UI
// thread.
- g_browser_process->file_thread()->message_loop()->PostDelayedTask(FROM_HERE,
+ BrowserThread::PostDelayedTask(
+ BrowserThread::FILE,
+ FROM_HERE,
base::Bind(&MetricsService::InitTaskGetHardwareClass,
base::Unretained(this),
MessageLoop::current()->message_loop_proxy()),
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 1763445..5a71d38 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -118,8 +118,7 @@ class FactoryForMedia : public ChromeURLRequestContextFactory {
ChromeURLRequestContextGetter::ChromeURLRequestContextGetter(
Profile* profile,
ChromeURLRequestContextFactory* factory)
- : io_thread_(g_browser_process->io_thread()),
- factory_(factory) {
+ : factory_(factory) {
DCHECK(factory);
DCHECK(profile);
RegisterPrefsObserver(profile);
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 854a098..1ddd636 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -182,10 +182,6 @@ class ChromeURLRequestContextGetter : public net::URLRequestContextGetter,
PrefChangeRegistrar registrar_;
- // |io_thread_| is always valid during the lifetime of |this| since |this| is
- // deleted on the IO thread.
- IOThread* const io_thread_;
-
// Deferred logic for creating a ChromeURLRequestContext.
// Access only from the IO thread.
scoped_ptr<ChromeURLRequestContextFactory> factory_;
diff --git a/chrome/browser/net/proxy_service_factory.cc b/chrome/browser/net/proxy_service_factory.cc
index 1ef72f3..dfbaf46 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(
- BrowserThread::UnsafeGetMessageLoop(BrowserThread::IO),
- BrowserThread::UnsafeGetMessageLoop(BrowserThread::FILE));
+ BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
+ BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE));
#endif // !defined(OS_CHROMEOS)
return new ChromeProxyConfigService(base_service);
diff --git a/chrome/browser/printing/printer_manager_dialog_win.cc b/chrome/browser/printing/printer_manager_dialog_win.cc
index 8c94d07..1a1121c 100644
--- a/chrome/browser/printing/printer_manager_dialog_win.cc
+++ b/chrome/browser/printing/printer_manager_dialog_win.cc
@@ -12,6 +12,9 @@
#include "base/path_service.h"
#include "base/threading/thread.h"
#include "chrome/browser/browser_process.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
namespace printing {
@@ -29,8 +32,10 @@ void OpenPrintersDialogCallback() {
}
void PrinterManagerDialog::ShowPrinterManagerDialog() {
- g_browser_process->file_thread()->message_loop()->PostTask(
- FROM_HERE, base::Bind(OpenPrintersDialogCallback));
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(OpenPrintersDialogCallback));
}
} // namespace printing
diff --git a/chrome/browser/sessions/base_session_service.cc b/chrome/browser/sessions/base_session_service.cc
index e63383f..f8e6623 100644
--- a/chrome/browser/sessions/base_session_service.cc
+++ b/chrome/browser/sessions/base_session_service.cc
@@ -14,9 +14,11 @@
#include "chrome/browser/sessions/session_types.h"
#include "chrome/common/url_constants.h"
#include "content/browser/tab_contents/navigation_entry.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/common/referrer.h"
#include "webkit/glue/webkit_glue.h"
+using content::BrowserThread;
using WebKit::WebReferrerPolicy;
// InternalGetCommandsRequest -------------------------------------------------
@@ -69,7 +71,6 @@ BaseSessionService::BaseSessionService(SessionType type,
const FilePath& path)
: profile_(profile),
path_(path),
- backend_thread_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
pending_reset_(false),
commands_since_reset_(0) {
@@ -80,22 +81,18 @@ BaseSessionService::BaseSessionService(SessionType type,
backend_ = new SessionBackend(type,
profile_ ? profile_->GetPath() : path_);
DCHECK(backend_.get());
- backend_thread_ = g_browser_process->file_thread();
- if (!backend_thread_)
- backend_->Init();
- // If backend_thread is non-null, backend will init itself as appropriate.
+
+ RunTaskOnBackendThread(FROM_HERE,
+ base::Bind(&SessionBackend::Init, backend_));
}
BaseSessionService::~BaseSessionService() {
}
void BaseSessionService::DeleteLastSession() {
- if (!backend_thread()) {
- backend()->DeleteLastSession();
- } else {
- backend_thread()->message_loop()->PostTask(
- FROM_HERE, base::Bind(&SessionBackend::DeleteLastSession, backend()));
- }
+ RunTaskOnBackendThread(
+ FROM_HERE,
+ base::Bind(&SessionBackend::DeleteLastSession, backend()));
}
void BaseSessionService::ScheduleCommand(SessionCommand* command) {
@@ -122,16 +119,12 @@ void BaseSessionService::Save() {
if (pending_commands_.empty())
return;
- if (!backend_thread()) {
- backend()->AppendCommands(
- new std::vector<SessionCommand*>(pending_commands_), pending_reset_);
- } else {
- backend_thread()->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&SessionBackend::AppendCommands, backend(),
- new std::vector<SessionCommand*>(pending_commands_),
- pending_reset_));
- }
+ RunTaskOnBackendThread(
+ FROM_HERE,
+ base::Bind(&SessionBackend::AppendCommands, backend(),
+ new std::vector<SessionCommand*>(pending_commands_),
+ pending_reset_));
+
// Backend took ownership of commands.
pending_commands_.clear();
@@ -275,14 +268,10 @@ BaseSessionService::Handle BaseSessionService::ScheduleGetLastSessionCommands(
CancelableRequestConsumerBase* consumer) {
scoped_refptr<InternalGetCommandsRequest> request_wrapper(request);
AddRequest(request, consumer);
- if (backend_thread()) {
- backend_thread()->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&SessionBackend::ReadLastSessionCommands, backend(),
- request_wrapper));
- } else {
- backend()->ReadLastSessionCommands(request);
- }
+ RunTaskOnBackendThread(
+ FROM_HERE,
+ base::Bind(&SessionBackend::ReadLastSessionCommands, backend(),
+ request_wrapper));
return request->handle();
}
@@ -292,13 +281,23 @@ BaseSessionService::Handle
CancelableRequestConsumerBase* consumer) {
scoped_refptr<InternalGetCommandsRequest> request_wrapper(request);
AddRequest(request, consumer);
- if (backend_thread()) {
- backend_thread()->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&SessionBackend::ReadCurrentSessionCommands, backend(),
- request_wrapper));
+ RunTaskOnBackendThread(
+ FROM_HERE,
+ base::Bind(&SessionBackend::ReadCurrentSessionCommands, backend(),
+ request_wrapper));
+ return request->handle();
+}
+
+bool BaseSessionService::RunTaskOnBackendThread(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
+ return BrowserThread::PostTask(BrowserThread::FILE, from_here, task);
} else {
- backend()->ReadCurrentSessionCommands(request);
+ // Fall back to executing on the main thread if the file thread
+ // has gone away (around shutdown time) or if we're running as
+ // part of a unit test that does not set profile_.
+ task.Run();
+ return true;
}
- return request->handle();
}
diff --git a/chrome/browser/sessions/base_session_service.h b/chrome/browser/sessions/base_session_service.h
index 92d3fe2..7f43d43 100644
--- a/chrome/browser/sessions/base_session_service.h
+++ b/chrome/browser/sessions/base_session_service.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
+#include "base/location.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
@@ -22,10 +23,6 @@ class SessionBackend;
class SessionCommand;
class TabNavigation;
-namespace base {
-class Thread;
-}
-
// BaseSessionService is the super class of both tab restore service and
// session service. It contains commonality needed by both, in particular
// it manages a set of SessionCommands that are periodically sent to a
@@ -85,9 +82,6 @@ class BaseSessionService : public CancelableRequestProvider,
// Returns the backend.
SessionBackend* backend() const { return backend_; }
- // Returns the thread the backend runs on. This returns NULL during testing.
- base::Thread* backend_thread() const { return backend_thread_; }
-
// Returns the set of commands that needed to be scheduled. The commands
// in the vector are owned by BaseSessionService, until they are scheduled
// on the backend at which point the backend owns the commands.
@@ -157,6 +151,12 @@ class BaseSessionService : public CancelableRequestProvider,
InternalGetCommandsRequest* request,
CancelableRequestConsumerBase* consumer);
+ // In production, this posts the task to the FILE thread. For
+ // tests, it immediately runs the specified task on the current
+ // thread.
+ bool RunTaskOnBackendThread(const tracked_objects::Location& from_here,
+ const base::Closure& task);
+
// Max number of navigation entries in each direction we'll persist.
static const int max_persist_navigation_count;
@@ -170,9 +170,6 @@ class BaseSessionService : public CancelableRequestProvider,
// The backend.
scoped_refptr<SessionBackend> backend_;
- // Thread backend tasks are run on, is NULL during testing.
- base::Thread* backend_thread_;
-
// Used to invoke Save.
base::WeakPtrFactory<BaseSessionService> weak_factory_;
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index fc7df95..0dda61c 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -182,13 +182,9 @@ void SessionService::MoveCurrentSessionToLastSession() {
Save();
- if (!backend_thread()) {
- backend()->MoveCurrentSessionToLastSession();
- } else {
- backend_thread()->message_loop()->PostTask(
- FROM_HERE, base::Bind(&SessionBackend::MoveCurrentSessionToLastSession,
- backend()));
- }
+ RunTaskOnBackendThread(
+ FROM_HERE, base::Bind(&SessionBackend::MoveCurrentSessionToLastSession,
+ backend()));
}
void SessionService::SetTabWindow(const SessionID& window_id,
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 87c15a1..0c92604 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -204,7 +204,8 @@ bool DefaultBrowserInfoBarDelegate::NeedElevation(InfoBarButton button) const {
bool DefaultBrowserInfoBarDelegate::Accept() {
action_taken_ = true;
UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1);
- g_browser_process->file_thread()->message_loop()->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
FROM_HERE,
base::IgnoreReturn<bool>(
base::Bind(&ShellIntegration::SetAsDefaultBrowser)));
diff --git a/chrome/browser/ui/webui/options/advanced_options_utils_win.cc b/chrome/browser/ui/webui/options/advanced_options_utils_win.cc
index f7bfb73..2e26678 100644
--- a/chrome/browser/ui/webui/options/advanced_options_utils_win.cc
+++ b/chrome/browser/ui/webui/options/advanced_options_utils_win.cc
@@ -16,6 +16,9 @@
#include "chrome/browser/browser_process.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
// Callback that opens the Internet Options control panel dialog with the
// Connections tab selected.
@@ -45,10 +48,10 @@ void OpenConnectionDialogCallback() {
void AdvancedOptionsUtilities::ShowNetworkProxySettings(
TabContents* tab_contents) {
- base::Thread* thread = g_browser_process->file_thread();
- DCHECK(thread);
- thread->message_loop()->PostTask(FROM_HERE,
- base::Bind(&OpenConnectionDialogCallback));
+ DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE));
+ BrowserThread::PostTask(BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&OpenConnectionDialogCallback));
}
void AdvancedOptionsUtilities::ShowManageSSLCertificates(
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index 84008aa..fc6af74 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -43,24 +43,10 @@ IOThread* TestingBrowserProcess::io_thread() {
return io_thread_;
}
-base::Thread* TestingBrowserProcess::file_thread() {
- return NULL;
-}
-
-base::Thread* TestingBrowserProcess::db_thread() {
- return NULL;
-}
-
WatchDogThread* TestingBrowserProcess::watchdog_thread() {
return NULL;
}
-#if defined(OS_CHROMEOS)
-base::Thread* TestingBrowserProcess::web_socket_proxy_thread() {
- return NULL;
-}
-#endif
-
ProfileManager* TestingBrowserProcess::profile_manager() {
return profile_manager_.get();
}
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index 2f9dbc8..57587ea 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -48,15 +48,7 @@ class TestingBrowserProcess : public BrowserProcess {
virtual ResourceDispatcherHost* resource_dispatcher_host() OVERRIDE;
virtual MetricsService* metrics_service() OVERRIDE;
virtual IOThread* io_thread() OVERRIDE;
-
- virtual base::Thread* file_thread() OVERRIDE;
- virtual base::Thread* db_thread() OVERRIDE;
virtual WatchDogThread* watchdog_thread() OVERRIDE;
-
-#if defined(OS_CHROMEOS)
- virtual base::Thread* web_socket_proxy_thread() OVERRIDE;
-#endif
-
virtual ProfileManager* profile_manager() OVERRIDE;
virtual PrefService* local_state() OVERRIDE;
virtual policy::BrowserPolicyConnector* browser_policy_connector() OVERRIDE;