Commit b0bfadcc authored by fdoray's avatar fdoray Committed by Commit bot

Remove use of deprecated MessageLoop methods in remoting.

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 code on the bug).
2. Run tools/sort-headers.py on modified files.
3. Run git cl format.

BUG=616447
R=garykac@chromium.org

Review-Url: https://codereview.chromium.org/2031083002
Cr-Commit-Position: refs/heads/master@{#398062}
parent 9eeee90e
......@@ -7,8 +7,11 @@
#include <utility>
#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "net/base/net_errors.h"
#include "net/socket/socket.h"
#include "net/socket/stream_socket.h"
......@@ -36,7 +39,7 @@ const char kTestChannelName2[] = "test2";
void QuitCurrentThread() {
base::MessageLoop::current()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
}
......
......@@ -9,7 +9,10 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "jingle/glue/thread_wrapper.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
......@@ -127,7 +130,7 @@ class FakeSocket : public P2PDatagramSocket {
const net::CompletionCallback& callback) override {
DCHECK(buf);
if (peer_socket_) {
base::MessageLoop::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&FakeSocket::AppendInputPacket,
base::Unretained(peer_socket_),
......
......@@ -5,8 +5,10 @@
#include "remoting/test/fake_network_manager.h"
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "jingle/glue/utils.h"
#include "third_party/webrtc/base/socketaddress.h"
......@@ -24,10 +26,9 @@ FakeNetworkManager::~FakeNetworkManager() {
void FakeNetworkManager::StartUpdating() {
started_ = true;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&FakeNetworkManager::SendNetworksChangedSignal,
weak_factory_.GetWeakPtr()));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&FakeNetworkManager::SendNetworksChangedSignal,
weak_factory_.GetWeakPtr()));
}
void FakeNetworkManager::StopUpdating() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment