Remove use of deprecated MessageLoop methods in chrome/.
MessageLoop::PostTask/PostDelayedTask/DeleteSoon/ReleaseSoon
are deprecated. This CL makes the following replacements to
remove some uses of these methods:
"MessageLoop(ForUI|ForIO)::current()->PostTask" ->
"ThreadTaskRunnerHandle::Get()->PostTask"
"MessageLoop(ForUI|ForIO)::current()->PostDelayedTask" ->
"ThreadTaskRunnerHandle::Get()->PostDelayedTask"
"MessageLoop(ForUI|ForIO)::current()->DeleteSoon" ->
"ThreadTaskRunnerHandle::Get()->DeleteSoon"
"MessageLoop(ForUI|ForIO)::current()->ReleaseSoon" ->
"ThreadTaskRunnerHandle::Get()->ReleaseSoon"
In files where these replacements are made, it adds these includes:
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
And removes this include if it is no longer required:
#include "base/message_loop/message_loop.h"
Why ThreadTaskRunnerHandle::Get() instead of
MessageLoop::current()->task_runner()?
- The two are equivalent on threads that run a MessageLoop.
- MessageLoop::current() doesn't work in base/task_scheduler
because the scheduler's thread don't run MessageLoops.
This CL will therefore facilitate the migration of browser
threads to base/task_scheduler.
Steps to generate this patch:
1. Run message_loop_cleanup.py (see this CL's comments).
2. Run tools/sort-headers.py on modified files.
3. Run git cl format.
BUG=616447
Review-Url: https://codereview.chromium.org/2033753002
Cr-Commit-Position: refs/heads/master@{#397497}
diff --git a/chrome/browser/extensions/external_install_error.cc b/chrome/browser/extensions/external_install_error.cc
index 23bea74..aa17a948 100644
--- a/chrome/browser/extensions/external_install_error.cc
+++ b/chrome/browser/extensions/external_install_error.cc
@@ -8,10 +8,12 @@
#include <utility>
#include "base/bind.h"
+#include "base/location.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram_macros.h"
+#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/extension_install_error_menu_item_id_provider.h"
#include "chrome/browser/extensions/extension_install_prompt_show_params.h"
@@ -321,10 +323,9 @@
// If the error isn't removed and deleted as part of handling the user's
// response (which can happen, e.g., if an uninstall fails), be sure to remove
// the error directly in order to ensure it's not called twice.
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&ExternalInstallError::RemoveError,
- weak_factory_.GetWeakPtr()));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&ExternalInstallError::RemoveError,
+ weak_factory_.GetWeakPtr()));
switch (result) {
case ExtensionInstallPrompt::Result::ACCEPTED: