Remove MessageLoop::current()->task_runner() in chrome.
This CL replaces MessageLoop::current()->task_runner() with
ThreadTaskRunnerHandle::Get() in chrome.
In files where this replacement is made, it adds these include:
#include "base/threading/thread_task_runner_handle.h"
#include "base/location.h" (if required)
#include "base/single_thread_task_runner.h" (if required)
And removes this include if it is no longer required:
#include "base/message_loop/message_loop.h"
Why?
The fact that there's a MessageLoop on the thread is an
unnecessary implementation detail. When browser threads
are migrated to base/task_scheduler, tasks will no longer
have access to a MessageLoop but they will have access to
a ThreadTaskRunnerHandle.
Steps to generate this patch:
1. Run message_loop_cleanup_2.py (see code on the bug).
2. Run tools/sort-headers.py on modified files.
3. Run git cl format.
BUG=616447
Review-Url: https://codereview.chromium.org/2055073003
Cr-Commit-Position: refs/heads/master@{#399328}
diff --git a/chrome/browser/ui/browser_focus_uitest.cc b/chrome/browser/ui/browser_focus_uitest.cc
index 37f4147..631d67e 100644
--- a/chrome/browser/ui/browser_focus_uitest.cc
+++ b/chrome/browser/ui/browser_focus_uitest.cc
@@ -7,11 +7,14 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
+#include "base/location.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
+#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/ui/browser.h"
@@ -229,7 +232,7 @@
#if defined(OS_POSIX)
// It seems we have to wait a little bit for the widgets to spin up before
// we can start clicking on them.
- base::MessageLoop::current()->task_runner()->PostDelayedTask(
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
base::TimeDelta::FromMilliseconds(kActionDelayMs));
content::RunMessageLoop();
@@ -692,12 +695,12 @@
// This functionality is currently broken. http://crbug.com/304865.
//
-//#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
-//// TODO(erg): http://crbug.com/163931
-//#define MAYBE_FocusOnNavigate DISABLED_FocusOnNavigate
-//#else
-//#define MAYBE_FocusOnNavigate FocusOnNavigate
-//#endif
+// #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
+// // TODO(erg): http://crbug.com/163931
+// #define MAYBE_FocusOnNavigate DISABLED_FocusOnNavigate
+// #else
+// #define MAYBE_FocusOnNavigate FocusOnNavigate
+// #endif
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnNavigate) {
// Needed on Mac.