Skip to content

Commit

Permalink
Remove remaining use of the deprecated MessageLoopProxy
Browse files Browse the repository at this point in the history
This patch removes the remaining usage of MessageLoopProxy outside
base/. Note that there are still some call sites for
Thread::message_loop_proxy() and MessageLoop::message_loop_proxy() which
will be cleaned up separately.

BUG=465354

Review URL: https://codereview.chromium.org/1169923009

Cr-Commit-Position: refs/heads/master@{#334198}
  • Loading branch information
skyostil authored and Commit bot committed Jun 12, 2015
1 parent b213436 commit a389986
Show file tree
Hide file tree
Showing 22 changed files with 126 additions and 143 deletions.
4 changes: 2 additions & 2 deletions chromecast/base/metrics/cast_metrics_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class CastMetricsHelper {
virtual void SetRecordActionCallback(const RecordActionCallback& callback);

protected:
// Creates a CastMetricsHelper instance with no MessageLoopProxy. This should
// only be used by tests, since invoking any non-overridden methods on this
// Creates a CastMetricsHelper instance with no task runner. This should only
// be used by tests, since invoking any non-overridden methods on this
// instance will cause a failure.
CastMetricsHelper();

Expand Down
4 changes: 2 additions & 2 deletions components/proximity_auth/ble/proximity_auth_ble_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/thread_task_runner_handle.h"
#include "components/proximity_auth/ble/bluetooth_low_energy_connection.h"
#include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h"
#include "components/proximity_auth/ble/fake_wire_message.h"
Expand Down Expand Up @@ -183,7 +183,7 @@ void ProximityAuthBleSystem::StartPollingScreenState() {
make_scoped_ptr(new FakeWireMessage(kPollScreenState)));

// Schedules the next message in |kPollingIntervalSeconds| ms.
base::MessageLoopProxy::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&ProximityAuthBleSystem::StartPollingScreenState,
weak_ptr_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(kPollingIntervalSeconds));
Expand Down
5 changes: 3 additions & 2 deletions components/safe_json_parser/safe_json_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string>

#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "base/tuple.h"
#include "base/values.h"
#include "components/safe_json_parser/safe_json_parser_messages.h"
Expand Down Expand Up @@ -41,8 +42,8 @@ SafeJsonParser::~SafeJsonParser() {

void SafeJsonParser::StartWorkOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
UtilityProcessHost* host =
UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get());
UtilityProcessHost* host = UtilityProcessHost::Create(
this, base::ThreadTaskRunnerHandle::Get().get());
host->SetName(
l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_JSON_PARSER_NAME));
host->Send(new SafeJsonParserMsg_ParseJSON(unsafe_json_));
Expand Down
9 changes: 4 additions & 5 deletions components/test_runner/web_test_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "components/test_runner/accessibility_controller.h"
#include "components/test_runner/event_sender.h"
Expand Down Expand Up @@ -629,11 +630,9 @@ void WebTestProxyBase::CapturePixelsAsync(
}

if (test_interfaces_->GetTestRunner()->isPrinting()) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(&WebTestProxyBase::CapturePixelsForPrinting,
base::Unretained(this),
callback));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&WebTestProxyBase::CapturePixelsForPrinting,
base::Unretained(this), callback));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/base64.h"
#include "base/bind.h"
#include "base/sequenced_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/worker_pool.h"
#include "components/onc/onc_constants.h"
#include "content/public/browser/browser_thread.h"
Expand Down Expand Up @@ -56,7 +57,7 @@ NetworkingPrivateServiceClient::NetworkingPrivateServiceClient(
base::Bind(
&WiFiService::SetEventObservers,
base::Unretained(wifi_service_.get()),
base::MessageLoopProxy::current(),
base::ThreadTaskRunnerHandle::Get(),
base::Bind(
&NetworkingPrivateServiceClient::OnNetworksChangedEventOnUIThread,
weak_factory_.GetWeakPtr()),
Expand Down
5 changes: 3 additions & 2 deletions gin/per_isolate_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// found in the LICENSE file.

#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "gin/per_isolate_data.h"
#include "gin/public/gin_embedders.h"

Expand All @@ -21,7 +22,7 @@ PerIsolateData::PerIsolateData(Isolate* isolate,
ArrayBuffer::Allocator* allocator)
: isolate_(isolate),
allocator_(allocator),
message_loop_proxy_(base::MessageLoopProxy::current()) {
task_runner_(base::ThreadTaskRunnerHandle::Get()) {
isolate_->SetData(kEmbedderNativeGin, this);
}

Expand Down
8 changes: 3 additions & 5 deletions gin/per_isolate_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "v8/include/v8.h"

namespace base {
class MessageLoopProxy;
class SingleThreadTaskRunner;
}

namespace gin {
Expand Down Expand Up @@ -65,9 +65,7 @@ class GIN_EXPORT PerIsolateData {

v8::Isolate* isolate() { return isolate_; }
v8::ArrayBuffer::Allocator* allocator() { return allocator_; }
base::MessageLoopProxy* message_loop_proxy() {
return message_loop_proxy_.get();
}
base::SingleThreadTaskRunner* task_runner() { return task_runner_.get(); }

private:
typedef std::map<
Expand All @@ -87,7 +85,7 @@ class GIN_EXPORT PerIsolateData {
FunctionTemplateMap function_templates_;
IndexedPropertyInterceptorMap indexed_interceptors_;
NamedPropertyInterceptorMap named_interceptors_;
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;

DISALLOW_COPY_AND_ASSIGN(PerIsolateData);
};
Expand Down
2 changes: 1 addition & 1 deletion gin/v8_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void V8Platform::CallOnBackgroundThread(
}

void V8Platform::CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) {
PerIsolateData::From(isolate)->message_loop_proxy()->PostTask(
PerIsolateData::From(isolate)->task_runner()->PostTask(
FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)));
}

Expand Down
10 changes: 5 additions & 5 deletions media/audio/audio_output_device_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ ACTION_P2(SendPendingBytes, socket, pending_bytes) {
}

// Used to terminate a loop from a different thread than the loop belongs to.
// |loop| should be a MessageLoopProxy.
ACTION_P(QuitLoop, loop) {
loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
// |task_runner| should be a SingleThreadTaskRunner.
ACTION_P(QuitLoop, task_runner) {
task_runner->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
}

} // namespace.
Expand Down Expand Up @@ -112,7 +112,7 @@ AudioOutputDeviceTest::AudioOutputDeviceTest() {
audio_output_ipc_ = new MockAudioOutputIPC();
audio_device_ = new AudioOutputDevice(
scoped_ptr<AudioOutputIPC>(audio_output_ipc_),
io_loop_.message_loop_proxy());
io_loop_.task_runner());

audio_device_->Initialize(default_audio_parameters_,
&callback_);
Expand Down Expand Up @@ -177,7 +177,7 @@ void AudioOutputDeviceTest::ExpectRenderCallback() {
const int kNumberOfFramesToProcess = 0;
EXPECT_CALL(callback_, Render(_, _))
.WillOnce(DoAll(
QuitLoop(io_loop_.message_loop_proxy()),
QuitLoop(io_loop_.task_runner()),
Return(kNumberOfFramesToProcess)));
}

Expand Down
23 changes: 10 additions & 13 deletions media/audio/win/audio_low_latency_output_win_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ MATCHER_P(HasValidDelay, value, "") {
}

// Used to terminate a loop from a different thread than the loop belongs to.
// |loop| should be a MessageLoopProxy.
ACTION_P(QuitLoop, loop) {
loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
// |task_runner| should be a SingleThreadTaskRunner.
ACTION_P(QuitLoop, task_runner) {
task_runner->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
}

// This audio source implementation should be used for manual tests only since
Expand Down Expand Up @@ -381,9 +381,8 @@ TEST(WASAPIAudioOutputStreamTest, ValidPacketSize) {

// Wait for the first callback and verify its parameters.
EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet)))
.WillOnce(DoAll(
QuitLoop(loop.message_loop_proxy()),
Return(aosw.samples_per_packet())));
.WillOnce(DoAll(QuitLoop(loop.task_runner()),
Return(aosw.samples_per_packet())));

aos->Start(&source);
loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(),
Expand Down Expand Up @@ -575,9 +574,8 @@ TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeMinBufferSizeAt48kHz) {

// Wait for the first callback and verify its parameters.
EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet)))
.WillOnce(DoAll(
QuitLoop(loop.message_loop_proxy()),
Return(aosw.samples_per_packet())))
.WillOnce(DoAll(QuitLoop(loop.task_runner()),
Return(aosw.samples_per_packet())))
.WillRepeatedly(Return(aosw.samples_per_packet()));

aos->Start(&source);
Expand Down Expand Up @@ -610,10 +608,9 @@ TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeMinBufferSizeAt44kHz) {

// Wait for the first callback and verify its parameters.
EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet)))
.WillOnce(DoAll(
QuitLoop(loop.message_loop_proxy()),
Return(aosw.samples_per_packet())))
.WillRepeatedly(Return(aosw.samples_per_packet()));
.WillOnce(DoAll(QuitLoop(loop.task_runner()),
Return(aosw.samples_per_packet())))
.WillRepeatedly(Return(aosw.samples_per_packet()));

aos->Start(&source);
loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(),
Expand Down
3 changes: 2 additions & 1 deletion media/base/android/media_codec_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/thread_task_runner_handle.h"

#define RUN_ON_MEDIA_THREAD(METHOD, ...) \
do { \
Expand Down Expand Up @@ -49,7 +50,7 @@ MediaCodecPlayer::MediaCodecPlayer(
manager,
request_media_resources_cb,
frame_url),
ui_task_runner_(base::MessageLoopProxy::current()),
ui_task_runner_(base::ThreadTaskRunnerHandle::Get()),
demuxer_(demuxer.Pass()),
weak_factory_(this) {
// UI thread
Expand Down
8 changes: 5 additions & 3 deletions mojo/application/public/cpp/lib/content_handler_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
#include "mojo/application/public/cpp/application_connection.h"
#include "mojo/application/public/cpp/application_delegate.h"
Expand All @@ -25,7 +27,7 @@ namespace {
class ApplicationThread : public base::PlatformThread::Delegate {
public:
ApplicationThread(
scoped_refptr<base::MessageLoopProxy> handler_thread,
scoped_refptr<base::SingleThreadTaskRunner> handler_thread,
const base::Callback<void(ApplicationThread*)>& termination_callback,
ContentHandlerFactory::Delegate* handler_delegate,
InterfaceRequest<Application> application_request,
Expand All @@ -44,7 +46,7 @@ class ApplicationThread : public base::PlatformThread::Delegate {
base::Bind(termination_callback_, this));
}

scoped_refptr<base::MessageLoopProxy> handler_thread_;
scoped_refptr<base::SingleThreadTaskRunner> handler_thread_;
base::Callback<void(ApplicationThread*)> termination_callback_;
ContentHandlerFactory::Delegate* handler_delegate_;
InterfaceRequest<Application> application_request_;
Expand Down Expand Up @@ -77,7 +79,7 @@ class ContentHandlerImpl : public ContentHandler {
void StartApplication(InterfaceRequest<Application> application_request,
URLResponsePtr response) override {
ApplicationThread* thread = new ApplicationThread(
base::MessageLoopProxy::current(),
base::ThreadTaskRunnerHandle::Get(),
base::Bind(&ContentHandlerImpl::OnThreadEnd,
weak_factory_.GetWeakPtr()),
delegate_, application_request.Pass(), response.Pass());
Expand Down
17 changes: 7 additions & 10 deletions mojo/common/handle_watcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
#include "base/memory/singleton.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
Expand All @@ -41,16 +42,14 @@ base::TimeTicks MojoDeadlineToTimeTicks(MojoDeadline deadline) {
// Tracks the data for a single call to Start().
struct WatchData {
WatchData()
: id(0),
handle_signals(MOJO_HANDLE_SIGNAL_NONE),
message_loop(NULL) {}
: id(0), handle_signals(MOJO_HANDLE_SIGNAL_NONE), task_runner(NULL) {}

WatcherID id;
Handle handle;
MojoHandleSignals handle_signals;
base::TimeTicks deadline;
base::Callback<void(MojoResult)> callback;
scoped_refptr<base::MessageLoopProxy> message_loop;
scoped_refptr<base::SingleThreadTaskRunner> task_runner;
};

// WatcherBackend --------------------------------------------------------------
Expand Down Expand Up @@ -124,7 +123,7 @@ void WatcherBackend::RemoveAndNotify(const Handle& handle,
handle_to_data_.erase(handle);
MessagePumpMojo::current()->RemoveHandler(handle);

data.message_loop->PostTask(FROM_HERE, base::Bind(data.callback, result));
data.task_runner->PostTask(FROM_HERE, base::Bind(data.callback, result));
}

bool WatcherBackend::GetMojoHandleByWatcherID(WatcherID watcher_id,
Expand Down Expand Up @@ -238,9 +237,7 @@ WatcherID WatcherThreadManager::StartWatching(
request_data.start_data.callback = callback;
request_data.start_data.handle_signals = handle_signals;
request_data.start_data.deadline = deadline;
request_data.start_data.message_loop = base::MessageLoopProxy::current();
DCHECK_NE(static_cast<base::MessageLoopProxy*>(NULL),
request_data.start_data.message_loop.get());
request_data.start_data.task_runner = base::ThreadTaskRunnerHandle::Get();
AddRequest(request_data);
return request_data.start_data.id;
}
Expand Down Expand Up @@ -280,7 +277,7 @@ void WatcherThreadManager::AddRequest(const RequestData& data) {
return;
}
// We own |thread_|, so it's safe to use Unretained() here.
thread_.message_loop()->PostTask(
thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&WatcherThreadManager::ProcessRequestsOnBackendThread,
base::Unretained(this)));
Expand Down
3 changes: 2 additions & 1 deletion mojo/runner/child_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "base/threading/thread_checker.h"
#include "mojo/common/message_pump_mojo.h"
Expand Down Expand Up @@ -194,7 +195,7 @@ class ChildControllerImpl : public ChildController, public ErrorHandler {
platform_channel.Pass(), app_context->io_runner(),
base::Bind(&ChildControllerImpl::DidCreateChannel,
base::Unretained(impl.get())),
base::MessageLoopProxy::current()));
base::ThreadTaskRunnerHandle::Get()));

impl->Bind(host_message_pipe.Pass());

Expand Down
8 changes: 4 additions & 4 deletions mojo/runner/in_process_native_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
#include "mojo/runner/native_application_support.h"

Expand Down Expand Up @@ -42,9 +42,9 @@ void InProcessNativeRunner::Start(
application_request_ = application_request.Pass();

DCHECK(app_completed_callback_runner_.is_null());
app_completed_callback_runner_ =
base::Bind(&base::TaskRunner::PostTask, base::MessageLoopProxy::current(),
FROM_HERE, app_completed_callback);
app_completed_callback_runner_ = base::Bind(
&base::TaskRunner::PostTask, base::ThreadTaskRunnerHandle::Get(),
FROM_HERE, app_completed_callback);

DCHECK(!thread_);
thread_.reset(new base::DelegateSimpleThread(this, "app_thread"));
Expand Down
4 changes: 2 additions & 2 deletions storage/browser/blob/scoped_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "base/callback.h"
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/task_runner.h"
#include "base/thread_task_runner_handle.h"

namespace storage {

Expand Down Expand Up @@ -41,7 +41,7 @@ void ScopedFile::AddScopeOutCallback(
const ScopeOutCallback& callback,
base::TaskRunner* callback_runner) {
if (!callback_runner)
callback_runner = base::MessageLoopProxy::current().get();
callback_runner = base::ThreadTaskRunnerHandle::Get().get();
scope_out_callbacks_.push_back(std::make_pair(callback, callback_runner));
}

Expand Down
Loading

0 comments on commit a389986

Please sign in to comment.