Skip to content

Commit

Permalink
Migrate MessageLoop::current() to MessageLoopCurrent in /remoting
Browse files Browse the repository at this point in the history
These changes were scripted as part of the effort to restrict exposure of the
raw MessageLoop*.

Note that many static methods exposed on MessageLoopCurrent are also deprecated
so it is very well possible that this is migrating to an already deprecated
method.

The goal of this pass is to reduce usage of MessageLoop::current() (and
ultimately make it impossible to obtain the MessageLoop* statically).

As such I will not edit this CL unless the script did something logically wrong.
I defer to owners to fix highlighted usage of already deprecated APIs.

Possible script screw ups / things to look out for in this review:
 - Storing MessageLoopCurrent in a MessageLoop* variable or comparing it against
   one (I will go over that in a separate pass).

Includes should have been stripped if that was the last usage of message_loop.h
in that file.

Please CQ if LGTY

This CL was uploaded by git cl split.

R=lambroslambrou@chromium.org

Bug: 825327
Change-Id: Ic3627d36d9e562b112766c1d597351caae7c0718
Reviewed-on: https://chromium-review.googlesource.com/1024284
Reviewed-by: Joe Downing <joedow@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553293}
  • Loading branch information
Gabriel Charette authored and Commit Bot committed Apr 24, 2018
1 parent ceba636 commit aec08d4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion remoting/base/auto_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace remoting {
//
// (1) Thread::CleanUp()
// (2) MessageLoop::~MessageLoop
// (3.b) MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop
// (3.b) MessageLoopCurrent::DestructionObserver::WillDestroyCurrentMessageLoop
class AutoThread : base::PlatformThread::Delegate {
public:
// Create an AutoThread with the specified message-loop |type| and |name|.
Expand Down
3 changes: 2 additions & 1 deletion remoting/client/chromoting_client_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/task_scheduler/task_scheduler.h"
#include "remoting/base/chromium_url_request.h"
#include "remoting/base/telemetry_log_writer.h"
Expand All @@ -31,7 +32,7 @@ ChromotingClientRuntime* ChromotingClientRuntime::GetInstance() {
ChromotingClientRuntime::ChromotingClientRuntime() {
base::TaskScheduler::CreateAndStartWithDefaultParams("Remoting");

DCHECK(!base::MessageLoop::current());
DCHECK(!base::MessageLoopCurrent::Get());

VLOG(1) << "Starting main message loop";
ui_loop_.reset(new base::MessageLoopForUI());
Expand Down
6 changes: 4 additions & 2 deletions remoting/host/win/wts_session_process_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/process/process_handle.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -211,7 +212,7 @@ bool WtsSessionProcessDelegate::Core::Initialize(uint32_t session_id) {
// the completion port represented by |io_task_runner|. The registration has
// to be done on the I/O thread because
// MessageLoopForIO::RegisterJobObject() can only be called via
// MessageLoopForIO::current().
// MessageLoopCurrentForIO::Get().
io_task_runner_->PostTask(
FROM_HERE, base::Bind(&Core::InitializeJob, this, base::Passed(&job)));
}
Expand Down Expand Up @@ -487,7 +488,8 @@ void WtsSessionProcessDelegate::Core::InitializeJob(ScopedHandle job) {
DCHECK(io_task_runner_->BelongsToCurrentThread());

// Register to receive job notifications via the I/O thread's completion port.
if (!base::MessageLoopForIO::current()->RegisterJobObject(job.Get(), this)) {
if (!base::MessageLoopCurrentForIO::Get()->RegisterJobObject(job.Get(),
this)) {
PLOG(ERROR) << "Failed to associate the job object with a completion port";
return;
}
Expand Down
3 changes: 2 additions & 1 deletion remoting/test/access_token_fetcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/url_request/test_url_fetcher_factory.h"
Expand Down Expand Up @@ -101,7 +102,7 @@ void AccessTokenFetcherTest::OnAccessTokenRetrieved(
}

void AccessTokenFetcherTest::SetUp() {
if (!base::MessageLoop::current()) {
if (!base::MessageLoopCurrent::Get()) {
// Create a temporary message loop if the current thread does not already
// have one so we can use its task runner to create a request object.
message_loop_.reset(new base::MessageLoopForIO);
Expand Down
3 changes: 2 additions & 1 deletion remoting/test/app_remoting_test_driver_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/callback_forward.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "remoting/test/access_token_fetcher.h"
Expand Down Expand Up @@ -54,7 +55,7 @@ bool AppRemotingTestDriverEnvironment::Initialize(
return true;
}

if (!base::MessageLoop::current()) {
if (!base::MessageLoopCurrent::Get()) {
message_loop_.reset(new base::MessageLoopForIO);
}

Expand Down
3 changes: 2 additions & 1 deletion remoting/test/chromoting_test_driver_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "remoting/test/access_token_fetcher.h"
Expand Down Expand Up @@ -47,7 +48,7 @@ bool ChromotingTestDriverEnvironment::Initialize(
return true;
}

if (!base::MessageLoop::current()) {
if (!base::MessageLoopCurrent::Get()) {
message_loop_.reset(new base::MessageLoopForIO);
}

Expand Down
3 changes: 2 additions & 1 deletion remoting/test/test_video_renderer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/timer/timer.h"
Expand Down Expand Up @@ -122,7 +123,7 @@ TestVideoRendererTest::TestVideoRendererTest()
TestVideoRendererTest::~TestVideoRendererTest() = default;

void TestVideoRendererTest::SetUp() {
if (!base::MessageLoop::current()) {
if (!base::MessageLoopCurrent::Get()) {
// Create a temporary message loop if the current thread does not already
// have one.
message_loop_.reset(new base::MessageLoop);
Expand Down

0 comments on commit aec08d4

Please sign in to comment.