Remove MessageLoop::current() from browser_context.cc.
Whenever possible, use ThreadTaskRunnerHandle::Get() instead of
MessageLoop::current(). ThreadTaskRunnerHandle::Get() works within
TaskScheduler while MessageLoop::current() doesn't.
Good reasons to use MessageLoop::current():
- Add destruction, nesting or task observers.
- Run nested loops.
Bad reasons to use MessageLoop::current():
- Post tasks. Use ThreadTaskRunnerHandle::Get() instead.
- Watch a file descriptor. Use FileDescriptorWatcher instead.
- Verify that it is possible to post tasks to the current thread.
Use ThreadTaskRunnerHandle::IsSet() instead.
- Verify that code runs on a specific thread. Use
SingleThreadTaskRunner::BelongsToCurrentThread() instead.
BUG=650723
Review-Url: https://codereview.chromium.org/2407353002
Cr-Commit-Position: refs/heads/master@{#424715}
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index 5b7ba414..a7c63e5 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -431,7 +431,7 @@
ServiceManagerConnection* service_manager_connection =
ServiceManagerConnection::GetForProcess();
- if (service_manager_connection && base::MessageLoop::current()) {
+ if (service_manager_connection && base::ThreadTaskRunnerHandle::IsSet()) {
// NOTE: Many unit tests create a TestBrowserContext without initializing
// Mojo or the global service manager connection.