summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorstevenjb <stevenjb@chromium.org>2015-04-29 14:43:03 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-29 21:44:18 +0000
commit7669182866d8605d98a5141f7b82be3b516799ca (patch)
treeab4b166fa5b19181751469bfff84be8c0f00aaad /base
parentfd2d6d70942f4a64845022066098622809c189e9 (diff)
downloadchromium_src-7669182866d8605d98a5141f7b82be3b516799ca.zip
chromium_src-7669182866d8605d98a5141f7b82be3b516799ca.tar.gz
chromium_src-7669182866d8605d98a5141f7b82be3b516799ca.tar.bz2
Revert of base: Remove use of MessageLoopProxy (patchset #6 id:100001 of https://codereview.chromium.org/1100773004/)
Reason for revert: This CL caused this failure: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%281%29/builds/2126 I would strongly recommend doing this in smaller pieces since it combines mechanical changes with more subtle ones (base/prefs, base/task). Original issue's description: > base: Remove use of MessageLoopProxy > > Replace usage of MessageLoopProxy under base/ with SingleThreadTaskRunner > and ThreadTaskRunnerHandle (excluding the implementation of MessageLoopProxy > itself which will removed later). > > This patch was mostly autogenerated with > https://codereview.chromium.org/1010073002. > > Depends on https://codereview.chromium.org/1086733002/. > > BUG=465354 > TBR=nkostylev@chromium.org,pkasting@chromium.org,pauljensen@chromium.org > > Committed: https://crrev.com/62aa5ca413e15738ebebbb9acd271138ec808739 > Cr-Commit-Position: refs/heads/master@{#327512} TBR=danakj@chromium.org,skyostil@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=465354 Review URL: https://codereview.chromium.org/1113953002 Cr-Commit-Position: refs/heads/master@{#327573}
Diffstat (limited to 'base')
-rw-r--r--base/android/application_status_listener_unittest.cc7
-rw-r--r--base/async_socket_io_handler_unittest.cc17
-rw-r--r--base/bind_helpers.h2
-rw-r--r--base/cancelable_callback_unittest.cc8
-rw-r--r--base/chromeos/memory_pressure_monitor_chromeos.cc9
-rw-r--r--base/critical_closure.h2
-rw-r--r--base/deferred_sequenced_task_runner_unittest.cc32
-rw-r--r--base/files/file_path_watcher.h13
-rw-r--r--base/files/file_path_watcher_fsevents.cc17
-rw-r--r--base/files/file_path_watcher_kqueue.cc15
-rw-r--r--base/files/file_path_watcher_kqueue.h6
-rw-r--r--base/files/file_path_watcher_linux.cc30
-rw-r--r--base/files/file_path_watcher_unittest.cc34
-rw-r--r--base/files/file_path_watcher_win.cc17
-rw-r--r--base/files/file_proxy.cc1
-rw-r--r--base/files/file_proxy_unittest.cc3
-rw-r--r--base/files/file_util_proxy_unittest.cc3
-rw-r--r--base/files/important_file_writer.cc2
-rw-r--r--base/files/important_file_writer_unittest.cc29
-rw-r--r--base/memory/ref_counted_delete_on_message_loop.h3
-rw-r--r--base/memory/weak_ptr_unittest.cc45
-rw-r--r--base/observer_list_threadsafe.h11
-rw-r--r--base/observer_list_unittest.cc10
-rw-r--r--base/posix/unix_domain_socket_linux_unittest.cc14
-rw-r--r--base/prefs/json_pref_store.h1
-rw-r--r--base/prefs/json_pref_store_unittest.cc93
-rw-r--r--base/prefs/pref_member.cc23
-rw-r--r--base/prefs/pref_member.h11
-rw-r--r--base/prefs/pref_member_unittest.cc28
-rw-r--r--base/prefs/pref_service.cc9
-rw-r--r--base/sequence_checker_unittest.cc9
-rw-r--r--base/single_thread_task_runner.h3
-rw-r--r--base/synchronization/cancellation_flag_unittest.cc5
-rw-r--r--base/synchronization/condition_variable_unittest.cc4
-rw-r--r--base/synchronization/waitable_event_watcher_posix.cc6
-rw-r--r--base/task/cancelable_task_tracker.cc9
-rw-r--r--base/task/cancelable_task_tracker_unittest.cc45
-rw-r--r--base/task_runner_util_unittest.cc20
-rw-r--r--base/test/launcher/test_launcher.cc47
-rw-r--r--base/test/launcher/unit_test_launcher.cc21
-rw-r--r--base/test/sequenced_worker_pool_owner.cc6
-rw-r--r--base/test/task_runner_test_template.h4
-rw-r--r--base/test/thread_test_helper.cc4
-rw-r--r--base/test/thread_test_helper.h6
-rw-r--r--base/threading/post_task_and_reply_impl.cc18
-rw-r--r--base/threading/post_task_and_reply_impl.h6
-rw-r--r--base/threading/sequenced_worker_pool.cc24
-rw-r--r--base/threading/sequenced_worker_pool.h6
-rw-r--r--base/threading/sequenced_worker_pool_unittest.cc1
-rw-r--r--base/threading/thread.cc3
-rw-r--r--base/threading/thread.h4
-rw-r--r--base/threading/thread_perftest.cc26
-rw-r--r--base/threading/thread_unittest.cc21
-rw-r--r--base/threading/worker_pool.h2
-rw-r--r--base/trace_event/trace_event_android.cc2
-rw-r--r--base/trace_event/trace_event_impl.cc34
-rw-r--r--base/trace_event/trace_event_impl.h7
-rw-r--r--base/trace_event/trace_event_memory.cc21
-rw-r--r--base/trace_event/trace_event_memory.h15
-rw-r--r--base/trace_event/trace_event_memory_unittest.cc10
-rw-r--r--base/trace_event/trace_event_system_stats_monitor_unittest.cc4
-rw-r--r--base/trace_event/trace_event_unittest.cc45
-rw-r--r--base/win/object_watcher.cc2
63 files changed, 503 insertions, 432 deletions
diff --git a/base/android/application_status_listener_unittest.cc b/base/android/application_status_listener_unittest.cc
index ce78bf9..1049628 100644
--- a/base/android/application_status_listener_unittest.cc
+++ b/base/android/application_status_listener_unittest.cc
@@ -7,7 +7,7 @@
#include "base/callback_forward.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
@@ -49,8 +49,9 @@ class MultiThreadedTest {
void Run() {
// Start the thread and tell it to register for events.
thread_.Start();
- thread_.task_runner()->PostTask(
- FROM_HERE, base::Bind(&MultiThreadedTest::RegisterThreadForEvents,
+ thread_.message_loop()
+ ->PostTask(FROM_HERE,
+ base::Bind(&MultiThreadedTest::RegisterThreadForEvents,
base::Unretained(this)));
// Wait for its completion.
diff --git a/base/async_socket_io_handler_unittest.cc b/base/async_socket_io_handler_unittest.cc
index 721de9c..2b0e3c2 100644
--- a/base/async_socket_io_handler_unittest.cc
+++ b/base/async_socket_io_handler_unittest.cc
@@ -5,9 +5,6 @@
#include "base/async_socket_io_handler.h"
#include "base/bind.h"
-#include "base/location.h"
-#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -107,8 +104,8 @@ TEST(AsyncSocketIoHandlerTest, SynchronousReadWithMessageLoop) {
TestSocketReader reader(&pair[0], -1, false, false);
pair[1].Send(kAsyncSocketIoTestString, kAsyncSocketIoTestStringLength);
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::MessageLoop::QuitClosure(),
+ base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ base::MessageLoop::QuitClosure(),
base::TimeDelta::FromMilliseconds(100));
base::MessageLoop::current()->Run();
@@ -138,15 +135,15 @@ TEST(AsyncSocketIoHandlerTest, ReadFromCallback) {
// Issue sends on an interval to satisfy the Read() requirements.
int64 milliseconds = 0;
for (int i = 0; i < kReadOperationCount; ++i) {
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::Bind(&SendData, &pair[1], kAsyncSocketIoTestString,
- kAsyncSocketIoTestStringLength),
+ base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ base::Bind(&SendData, &pair[1], kAsyncSocketIoTestString,
+ kAsyncSocketIoTestStringLength),
base::TimeDelta::FromMilliseconds(milliseconds));
milliseconds += 10;
}
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::MessageLoop::QuitClosure(),
+ base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ base::MessageLoop::QuitClosure(),
base::TimeDelta::FromMilliseconds(100 + milliseconds));
base::MessageLoop::current()->Run();
diff --git a/base/bind_helpers.h b/base/bind_helpers.h
index 24063ad..c49b5b81 100644
--- a/base/bind_helpers.h
+++ b/base/bind_helpers.h
@@ -129,7 +129,7 @@
// Passed() is particularly useful with PostTask() when you are transferring
// ownership of an argument into a task, but don't necessarily know if the
// task will always be executed. This can happen if the task is cancellable
-// or if it is posted to a TaskRunner.
+// or if it is posted to a MessageLoopProxy.
//
//
// SIMPLE FUNCTIONS AND UTILITIES.
diff --git a/base/cancelable_callback_unittest.cc b/base/cancelable_callback_unittest.cc
index 6d0a114..fcbe23c 100644
--- a/base/cancelable_callback_unittest.cc
+++ b/base/cancelable_callback_unittest.cc
@@ -6,11 +6,9 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/location.h"
#include "base/memory/ref_counted.h"
+#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -167,12 +165,12 @@ TEST(CancelableCallbackTest, PostTask) {
CancelableClosure cancelable(base::Bind(&Increment,
base::Unretained(&count)));
- ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, cancelable.callback());
+ MessageLoop::current()->PostTask(FROM_HERE, cancelable.callback());
RunLoop().RunUntilIdle();
EXPECT_EQ(1, count);
- ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, cancelable.callback());
+ MessageLoop::current()->PostTask(FROM_HERE, cancelable.callback());
// Cancel before running the message loop.
cancelable.Cancel();
diff --git a/base/chromeos/memory_pressure_monitor_chromeos.cc b/base/chromeos/memory_pressure_monitor_chromeos.cc
index 78f78ea..404c515 100644
--- a/base/chromeos/memory_pressure_monitor_chromeos.cc
+++ b/base/chromeos/memory_pressure_monitor_chromeos.cc
@@ -7,10 +7,10 @@
#include <fcntl.h>
#include <sys/select.h>
+#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram_macros.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/process_metrics.h"
-#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
namespace base {
@@ -120,9 +120,10 @@ MemoryPressureMonitorChromeOS::~MemoryPressureMonitorChromeOS() {
}
void MemoryPressureMonitorChromeOS::ScheduleEarlyCheck() {
- ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, Bind(&MemoryPressureMonitorChromeOS::CheckMemoryPressure,
- weak_ptr_factory_.GetWeakPtr()));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ Bind(&MemoryPressureMonitorChromeOS::CheckMemoryPressure,
+ weak_ptr_factory_.GetWeakPtr()));
}
MemoryPressureListener::MemoryPressureLevel
diff --git a/base/critical_closure.h b/base/critical_closure.h
index 75e3704..ac07911 100644
--- a/base/critical_closure.h
+++ b/base/critical_closure.h
@@ -52,7 +52,7 @@ class CriticalClosure {
// returned.
//
// Example:
-// file_task_runner_->PostTask(
+// file_message_loop_proxy_->PostTask(
// FROM_HERE,
// MakeCriticalClosure(base::Bind(&WriteToDiskTask, path_, data)));
//
diff --git a/base/deferred_sequenced_task_runner_unittest.cc b/base/deferred_sequenced_task_runner_unittest.cc
index 6e17ad9..81f2a0a 100644
--- a/base/deferred_sequenced_task_runner_unittest.cc
+++ b/base/deferred_sequenced_task_runner_unittest.cc
@@ -7,9 +7,9 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/location.h"
#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/threading/non_thread_safe.h"
#include "base/threading/thread.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -58,9 +58,11 @@ class DeferredSequencedTaskRunnerTest : public testing::Test,
}
protected:
- DeferredSequencedTaskRunnerTest()
- : loop_(),
- runner_(new base::DeferredSequencedTaskRunner(loop_.task_runner())) {}
+ DeferredSequencedTaskRunnerTest() :
+ loop_(),
+ runner_(
+ new base::DeferredSequencedTaskRunner(loop_.message_loop_proxy())) {
+ }
base::MessageLoop loop_;
scoped_refptr<base::DeferredSequencedTaskRunner> runner_;
@@ -124,18 +126,21 @@ TEST_F(DeferredSequencedTaskRunnerTest, DeferredStartWithMultipleThreads) {
thread1.Start();
thread2.Start();
for (int i = 0; i < 5; ++i) {
- thread1.task_runner()->PostTask(
+ thread1.message_loop()->PostTask(
FROM_HERE,
base::Bind(&DeferredSequencedTaskRunnerTest::PostExecuteTask,
- base::Unretained(this), 2 * i));
- thread2.task_runner()->PostTask(
+ base::Unretained(this),
+ 2 * i));
+ thread2.message_loop()->PostTask(
FROM_HERE,
base::Bind(&DeferredSequencedTaskRunnerTest::PostExecuteTask,
- base::Unretained(this), 2 * i + 1));
+ base::Unretained(this),
+ 2 * i + 1));
if (i == 2) {
- thread1.task_runner()->PostTask(
- FROM_HERE, base::Bind(&DeferredSequencedTaskRunnerTest::StartRunner,
- base::Unretained(this)));
+ thread1.message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&DeferredSequencedTaskRunnerTest::StartRunner,
+ base::Unretained(this)));
}
}
}
@@ -149,7 +154,8 @@ TEST_F(DeferredSequencedTaskRunnerTest, ObjectDestructionOrder) {
{
base::Thread thread("DeferredSequencedTaskRunnerTestThread");
thread.Start();
- runner_ = new base::DeferredSequencedTaskRunner(thread.task_runner());
+ runner_ =
+ new base::DeferredSequencedTaskRunner(thread.message_loop_proxy());
for (int i = 0; i < 5; ++i) {
{
// Use a block to ensure that no reference to |short_lived_object|
diff --git a/base/files/file_path_watcher.h b/base/files/file_path_watcher.h
index 4f132af..d26fa06 100644
--- a/base/files/file_path_watcher.h
+++ b/base/files/file_path_watcher.h
@@ -12,7 +12,7 @@
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop_proxy.h"
namespace base {
@@ -58,13 +58,12 @@ class BASE_EXPORT FilePathWatcher {
// check |is_cancelled()| to avoid duplicate work.
virtual void CancelOnMessageLoopThread() = 0;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner() const {
- return task_runner_;
+ scoped_refptr<base::MessageLoopProxy> message_loop() const {
+ return message_loop_;
}
- void set_task_runner(
- scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
- task_runner_ = task_runner.Pass();
+ void set_message_loop(const scoped_refptr<base::MessageLoopProxy>& loop) {
+ message_loop_ = loop;
}
// Must be called before the PlatformDelegate is deleted.
@@ -77,7 +76,7 @@ class BASE_EXPORT FilePathWatcher {
}
private:
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
bool cancelled_;
};
diff --git a/base/files/file_path_watcher_fsevents.cc b/base/files/file_path_watcher_fsevents.cc
index da01c43..ef4e6ee 100644
--- a/base/files/file_path_watcher_fsevents.cc
+++ b/base/files/file_path_watcher_fsevents.cc
@@ -13,7 +13,6 @@
#include "base/mac/libdispatch_task_runner.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/message_loop/message_loop.h"
-#include "base/thread_task_runner_handle.h"
namespace base {
@@ -93,7 +92,7 @@ bool FilePathWatcherFSEvents::Watch(const FilePath& path,
if (!recursive)
return false;
- set_task_runner(ThreadTaskRunnerHandle::Get());
+ set_message_loop(MessageLoopProxy::current());
callback_ = callback;
FSEventStreamEventId start_event = FSEventsGetCurrentEventId();
@@ -153,7 +152,7 @@ void FilePathWatcherFSEvents::FSEventsCallback(
}
FilePathWatcherFSEvents::~FilePathWatcherFSEvents() {
- // This method may be called on either the libdispatch or task_runner()
+ // This method may be called on either the libdispatch or message_loop()
// thread. Checking callback_ on the libdispatch thread here is safe because
// it is executing in a task posted by Cancel() which first reset callback_.
// PostTask forms a sufficient memory barrier to ensure that the value is
@@ -166,7 +165,7 @@ void FilePathWatcherFSEvents::OnFilePathsChanged(
const std::vector<FilePath>& paths) {
DCHECK(g_task_runner.Get().RunsTasksOnCurrentThread());
DCHECK(!resolved_target_.empty());
- task_runner()->PostTask(
+ message_loop()->PostTask(
FROM_HERE, Bind(&FilePathWatcherFSEvents::DispatchEvents, this, paths,
target_, resolved_target_));
}
@@ -174,7 +173,7 @@ void FilePathWatcherFSEvents::OnFilePathsChanged(
void FilePathWatcherFSEvents::DispatchEvents(const std::vector<FilePath>& paths,
const FilePath& target,
const FilePath& resolved_target) {
- DCHECK(task_runner()->RunsTasksOnCurrentThread());
+ DCHECK(message_loop()->RunsTasksOnCurrentThread());
// Don't issue callbacks after Cancel() has been called.
if (is_cancelled() || callback_.is_null()) {
@@ -191,7 +190,7 @@ void FilePathWatcherFSEvents::DispatchEvents(const std::vector<FilePath>& paths,
void FilePathWatcherFSEvents::CancelOnMessageLoopThread() {
// For all other implementations, the "message loop thread" is the IO thread,
- // as returned by task_runner(). This implementation, however, needs to
+ // as returned by message_loop(). This implementation, however, needs to
// cancel pending work on the Dispatch Queue thread.
DCHECK(g_task_runner.Get().RunsTasksOnCurrentThread());
@@ -240,7 +239,7 @@ void FilePathWatcherFSEvents::UpdateEventStream(
g_task_runner.Get().GetDispatchQueue());
if (!FSEventStreamStart(fsevent_stream_)) {
- task_runner()->PostTask(
+ message_loop()->PostTask(
FROM_HERE, Bind(&FilePathWatcherFSEvents::ReportError, this, target_));
}
}
@@ -251,14 +250,14 @@ bool FilePathWatcherFSEvents::ResolveTargetPath() {
bool changed = resolved != resolved_target_;
resolved_target_ = resolved;
if (resolved_target_.empty()) {
- task_runner()->PostTask(
+ message_loop()->PostTask(
FROM_HERE, Bind(&FilePathWatcherFSEvents::ReportError, this, target_));
}
return changed;
}
void FilePathWatcherFSEvents::ReportError(const FilePath& target) {
- DCHECK(task_runner()->RunsTasksOnCurrentThread());
+ DCHECK(message_loop()->RunsTasksOnCurrentThread());
if (!callback_.is_null()) {
callback_.Run(target, true);
}
diff --git a/base/files/file_path_watcher_kqueue.cc b/base/files/file_path_watcher_kqueue.cc
index e15cba7..8941d2e 100644
--- a/base/files/file_path_watcher_kqueue.cc
+++ b/base/files/file_path_watcher_kqueue.cc
@@ -11,7 +11,6 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
-#include "base/thread_task_runner_handle.h"
// On some platforms these are not defined.
#if !defined(EV_RECEIPT)
@@ -328,7 +327,7 @@ bool FilePathWatcherKQueue::Watch(const FilePath& path,
target_ = path;
MessageLoop::current()->AddDestructionObserver(this);
- io_task_runner_ = ThreadTaskRunnerHandle::Get();
+ io_message_loop_ = base::MessageLoopProxy::current();
kqueue_ = kqueue();
if (kqueue_ == -1) {
@@ -357,14 +356,14 @@ bool FilePathWatcherKQueue::Watch(const FilePath& path,
}
void FilePathWatcherKQueue::Cancel() {
- SingleThreadTaskRunner* task_runner = io_task_runner_.get();
- if (!task_runner) {
+ base::MessageLoopProxy* proxy = io_message_loop_.get();
+ if (!proxy) {
set_cancelled();
return;
}
- if (!task_runner->BelongsToCurrentThread()) {
- task_runner->PostTask(FROM_HERE,
- base::Bind(&FilePathWatcherKQueue::Cancel, this));
+ if (!proxy->BelongsToCurrentThread()) {
+ proxy->PostTask(FROM_HERE,
+ base::Bind(&FilePathWatcherKQueue::Cancel, this));
return;
}
CancelOnMessageLoopThread();
@@ -381,7 +380,7 @@ void FilePathWatcherKQueue::CancelOnMessageLoopThread() {
kqueue_ = -1;
std::for_each(events_.begin(), events_.end(), ReleaseEvent);
events_.clear();
- io_task_runner_ = NULL;
+ io_message_loop_ = NULL;
MessageLoop::current()->RemoveDestructionObserver(this);
callback_.Reset();
}
diff --git a/base/files/file_path_watcher_kqueue.h b/base/files/file_path_watcher_kqueue.h
index 69555a3..87af891 100644
--- a/base/files/file_path_watcher_kqueue.h
+++ b/base/files/file_path_watcher_kqueue.h
@@ -11,7 +11,7 @@
#include "base/files/file_path.h"
#include "base/files/file_path_watcher.h"
#include "base/message_loop/message_loop.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop_proxy.h"
namespace base {
@@ -59,7 +59,7 @@ class FilePathWatcherKQueue : public FilePathWatcher::PlatformDelegate,
typedef std::vector<struct kevent> EventVector;
- // Can only be called on |io_task_runner_|'s thread.
+ // Can only be called on |io_message_loop_|'s thread.
void CancelOnMessageLoopThread() override;
// Returns true if the kevent values are error free.
@@ -118,7 +118,7 @@ class FilePathWatcherKQueue : public FilePathWatcher::PlatformDelegate,
}
EventVector events_;
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+ scoped_refptr<base::MessageLoopProxy> io_message_loop_;
MessageLoopForIO::FileDescriptorWatcher kqueue_watcher_;
FilePathWatcher::Callback callback_;
FilePath target_;
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc
index ba2f1d9..06c517a 100644
--- a/base/files/file_path_watcher_linux.cc
+++ b/base/files/file_path_watcher_linux.cc
@@ -26,10 +26,10 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "base/trace_event/trace_event.h"
@@ -264,7 +264,7 @@ InotifyReader::InotifyReader()
shutdown_pipe_[0] = -1;
shutdown_pipe_[1] = -1;
if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) {
- thread_.task_runner()->PostTask(
+ thread_.message_loop()->PostTask(
FROM_HERE,
Bind(&InotifyReaderCallback, this, inotify_fd_, shutdown_pipe_[0]));
valid_ = true;
@@ -349,11 +349,12 @@ void FilePathWatcherImpl::OnFilePathChanged(InotifyReader::Watch fired_watch,
bool created,
bool deleted,
bool is_dir) {
- if (!task_runner()->BelongsToCurrentThread()) {
- // Switch to task_runner() to access |watches_| safely.
- task_runner()->PostTask(FROM_HERE,
- Bind(&FilePathWatcherImpl::OnFilePathChanged, this,
- fired_watch, child, created, deleted, is_dir));
+ if (!message_loop()->BelongsToCurrentThread()) {
+ // Switch to message_loop() to access |watches_| safely.
+ message_loop()->PostTask(
+ FROM_HERE,
+ Bind(&FilePathWatcherImpl::OnFilePathChanged, this,
+ fired_watch, child, created, deleted, is_dir));
return;
}
@@ -451,7 +452,7 @@ bool FilePathWatcherImpl::Watch(const FilePath& path,
DCHECK(target_.empty());
DCHECK(MessageLoopForIO::current());
- set_task_runner(ThreadTaskRunnerHandle::Get());
+ set_message_loop(MessageLoopProxy::current());
callback_ = callback;
target_ = path;
recursive_ = recursive;
@@ -475,16 +476,17 @@ void FilePathWatcherImpl::Cancel() {
}
// Switch to the message_loop() if necessary so we can access |watches_|.
- if (!task_runner()->BelongsToCurrentThread()) {
- task_runner()->PostTask(FROM_HERE, Bind(&FilePathWatcher::CancelWatch,
- make_scoped_refptr(this)));
+ if (!message_loop()->BelongsToCurrentThread()) {
+ message_loop()->PostTask(FROM_HERE,
+ Bind(&FilePathWatcher::CancelWatch,
+ make_scoped_refptr(this)));
} else {
CancelOnMessageLoopThread();
}
}
void FilePathWatcherImpl::CancelOnMessageLoopThread() {
- DCHECK(task_runner()->BelongsToCurrentThread());
+ DCHECK(message_loop()->BelongsToCurrentThread());
set_cancelled();
if (!callback_.is_null()) {
@@ -508,7 +510,7 @@ void FilePathWatcherImpl::WillDestroyCurrentMessageLoop() {
void FilePathWatcherImpl::UpdateWatches() {
// Ensure this runs on the message_loop() exclusively in order to avoid
// concurrency issues.
- DCHECK(task_runner()->BelongsToCurrentThread());
+ DCHECK(message_loop()->BelongsToCurrentThread());
DCHECK(HasValidWatchVector());
// Walk the list of watches and update them as we go.
diff --git a/base/files/file_path_watcher_unittest.cc b/base/files/file_path_watcher_unittest.cc
index 21e9dd1..0e1c467 100644
--- a/base/files/file_path_watcher_unittest.cc
+++ b/base/files/file_path_watcher_unittest.cc
@@ -20,15 +20,14 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/location.h"
+#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_file_util.h"
#include "base/test/test_timeouts.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -47,13 +46,14 @@ class TestDelegate;
class NotificationCollector
: public base::RefCountedThreadSafe<NotificationCollector> {
public:
- NotificationCollector() : task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
+ NotificationCollector()
+ : loop_(base::MessageLoopProxy::current()) {}
// Called from the file thread by the delegates.
void OnChange(TestDelegate* delegate) {
- task_runner_->PostTask(
- FROM_HERE, base::Bind(&NotificationCollector::RecordChange, this,
- base::Unretained(delegate)));
+ loop_->PostTask(FROM_HERE,
+ base::Bind(&NotificationCollector::RecordChange, this,
+ base::Unretained(delegate)));
}
void Register(TestDelegate* delegate) {
@@ -74,13 +74,13 @@ class NotificationCollector
void RecordChange(TestDelegate* delegate) {
// Warning: |delegate| is Unretained. Do not dereference.
- ASSERT_TRUE(task_runner_->BelongsToCurrentThread());
+ ASSERT_TRUE(loop_->BelongsToCurrentThread());
ASSERT_TRUE(delegates_.count(delegate));
signaled_.insert(delegate);
// Check whether all delegates have been signaled.
if (signaled_ == delegates_)
- task_runner_->PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure());
+ loop_->PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure());
}
// Set of registered delegates.
@@ -90,7 +90,7 @@ class NotificationCollector
std::set<TestDelegate*> signaled_;
// The loop we should break after all delegates signaled.
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ scoped_refptr<base::MessageLoopProxy> loop_;
};
class TestDelegateBase : public SupportsWeakPtr<TestDelegateBase> {
@@ -171,7 +171,7 @@ class FilePathWatcherTest : public testing::Test {
void TearDown() override { RunLoop().RunUntilIdle(); }
void DeleteDelegateOnFileThread(TestDelegate* delegate) {
- file_thread_.task_runner()->DeleteSoon(FROM_HERE, delegate);
+ file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, delegate);
}
FilePath test_file() {
@@ -216,9 +216,10 @@ bool FilePathWatcherTest::SetupWatch(const FilePath& target,
bool recursive_watch) {
base::WaitableEvent completion(false, false);
bool result;
- file_thread_.task_runner()->PostTask(
- FROM_HERE, base::Bind(SetupWatchCallback, target, watcher, delegate,
- recursive_watch, &result, &completion));
+ file_thread_.message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(SetupWatchCallback, target, watcher, delegate, recursive_watch,
+ &result, &completion));
completion.Wait();
return result;
}
@@ -288,8 +289,7 @@ class Deleter : public TestDelegateBase {
void OnFileChanged(const FilePath&, bool) override {
watcher_.reset();
- loop_->task_runner()->PostTask(FROM_HERE,
- MessageLoop::QuitWhenIdleClosure());
+ loop_->PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure());
}
FilePathWatcher* watcher() const { return watcher_.get(); }
@@ -324,7 +324,7 @@ TEST_F(FilePathWatcherTest, DISABLED_DestroyWithPendingNotification) {
FilePathWatcher* watcher = new FilePathWatcher;
ASSERT_TRUE(SetupWatch(test_file(), watcher, delegate.get(), false));
ASSERT_TRUE(WriteFile(test_file(), "content"));
- file_thread_.task_runner()->DeleteSoon(FROM_HERE, watcher);
+ file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, watcher);
DeleteDelegateOnFileThread(delegate.release());
}
diff --git a/base/files/file_path_watcher_win.cc b/base/files/file_path_watcher_win.cc
index 081698f..d7ce5248 100644
--- a/base/files/file_path_watcher_win.cc
+++ b/base/files/file_path_watcher_win.cc
@@ -10,7 +10,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/time/time.h"
#include "base/win/object_watcher.h"
@@ -57,7 +57,7 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate,
// Destroy the watch handle.
void DestroyWatch();
- // Cleans up and stops observing the |task_runner_| thread.
+ // Cleans up and stops observing the |message_loop_| thread.
void CancelOnMessageLoopThread() override;
// Callback to notify upon changes.
@@ -91,7 +91,7 @@ bool FilePathWatcherImpl::Watch(const FilePath& path,
const FilePathWatcher::Callback& callback) {
DCHECK(target_.value().empty()); // Can only watch one path.
- set_task_runner(ThreadTaskRunnerHandle::Get());
+ set_message_loop(MessageLoopProxy::current());
callback_ = callback;
target_ = path;
recursive_watch_ = recursive;
@@ -113,22 +113,23 @@ bool FilePathWatcherImpl::Watch(const FilePath& path,
void FilePathWatcherImpl::Cancel() {
if (callback_.is_null()) {
- // Watch was never called, or the |task_runner_| has already quit.
+ // Watch was never called, or the |message_loop_| has already quit.
set_cancelled();
return;
}
// Switch to the file thread if necessary so we can stop |watcher_|.
- if (!task_runner()->BelongsToCurrentThread()) {
- task_runner()->PostTask(FROM_HERE, Bind(&FilePathWatcher::CancelWatch,
- make_scoped_refptr(this)));
+ if (!message_loop()->BelongsToCurrentThread()) {
+ message_loop()->PostTask(FROM_HERE,
+ Bind(&FilePathWatcher::CancelWatch,
+ make_scoped_refptr(this)));
} else {
CancelOnMessageLoopThread();
}
}
void FilePathWatcherImpl::CancelOnMessageLoopThread() {
- DCHECK(task_runner()->BelongsToCurrentThread());
+ DCHECK(message_loop()->BelongsToCurrentThread());
set_cancelled();
if (handle_ != INVALID_HANDLE_VALUE)
diff --git a/base/files/file_proxy.cc b/base/files/file_proxy.cc
index f995735..53b14fe 100644
--- a/base/files/file_proxy.cc
+++ b/base/files/file_proxy.cc
@@ -9,6 +9,7 @@
#include "base/files/file.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/task_runner_util.h"
diff --git a/base/files/file_proxy_unittest.cc b/base/files/file_proxy_unittest.cc
index df0bbc8..dbf1476 100644
--- a/base/files/file_proxy_unittest.cc
+++ b/base/files/file_proxy_unittest.cc
@@ -9,6 +9,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -78,7 +79,7 @@ class FileProxyTest : public testing::Test {
}
TaskRunner* file_task_runner() const {
- return file_thread_.task_runner().get();
+ return file_thread_.message_loop_proxy().get();
}
const FilePath& test_dir_path() const { return dir_.path(); }
const FilePath test_path() const { return dir_.path().AppendASCII("test"); }
diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc
index 7408369..5eb6819 100644
--- a/base/files/file_util_proxy_unittest.cc
+++ b/base/files/file_util_proxy_unittest.cc
@@ -8,6 +8,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -39,7 +40,7 @@ class FileUtilProxyTest : public testing::Test {
protected:
TaskRunner* file_task_runner() const {
- return file_thread_.task_runner().get();
+ return file_thread_.message_loop_proxy().get();
}
const FilePath& test_dir_path() const { return dir_.path(); }
const FilePath test_path() const { return dir_.path().AppendASCII("test"); }
diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc
index 814fc7b..f49790c 100644
--- a/base/files/important_file_writer.cc
+++ b/base/files/important_file_writer.cc
@@ -130,7 +130,7 @@ ImportantFileWriter::ImportantFileWriter(
commit_interval_(TimeDelta::FromMilliseconds(kDefaultCommitIntervalMs)),
weak_factory_(this) {
DCHECK(CalledOnValidThread());
- DCHECK(task_runner_);
+ DCHECK(task_runner_.get());
}
ImportantFileWriter::~ImportantFileWriter() {
diff --git a/base/files/important_file_writer_unittest.cc b/base/files/important_file_writer_unittest.cc
index d376cdc..170c2b2 100644
--- a/base/files/important_file_writer_unittest.cc
+++ b/base/files/important_file_writer_unittest.cc
@@ -9,11 +9,9 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/location.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -99,7 +97,7 @@ class ImportantFileWriterTest : public testing::Test {
};
TEST_F(ImportantFileWriterTest, Basic) {
- ImportantFileWriter writer(file_, ThreadTaskRunnerHandle::Get());
+ ImportantFileWriter writer(file_, MessageLoopProxy::current().get());
EXPECT_FALSE(PathExists(writer.path()));
EXPECT_FALSE(successful_write_observer_.GetAndResetObservationState());
writer.WriteNow(make_scoped_ptr(new std::string("foo")));
@@ -111,7 +109,7 @@ TEST_F(ImportantFileWriterTest, Basic) {
}
TEST_F(ImportantFileWriterTest, BasicWithSuccessfulWriteObserver) {
- ImportantFileWriter writer(file_, ThreadTaskRunnerHandle::Get());
+ ImportantFileWriter writer(file_, MessageLoopProxy::current().get());
EXPECT_FALSE(PathExists(writer.path()));
EXPECT_FALSE(successful_write_observer_.GetAndResetObservationState());
successful_write_observer_.ObserveNextSuccessfulWrite(&writer);
@@ -145,14 +143,15 @@ TEST_F(ImportantFileWriterTest, BasicWithSuccessfulWriteObserver) {
}
TEST_F(ImportantFileWriterTest, ScheduleWrite) {
- ImportantFileWriter writer(file_, ThreadTaskRunnerHandle::Get());
+ ImportantFileWriter writer(file_, MessageLoopProxy::current().get());
writer.set_commit_interval(TimeDelta::FromMilliseconds(25));
EXPECT_FALSE(writer.HasPendingWrite());
DataSerializer serializer("foo");
writer.ScheduleWrite(&serializer);
EXPECT_TRUE(writer.HasPendingWrite());
- ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, MessageLoop::QuitWhenIdleClosure(),
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ MessageLoop::QuitWhenIdleClosure(),
TimeDelta::FromMilliseconds(100));
MessageLoop::current()->Run();
EXPECT_FALSE(writer.HasPendingWrite());
@@ -161,14 +160,15 @@ TEST_F(ImportantFileWriterTest, ScheduleWrite) {
}
TEST_F(ImportantFileWriterTest, DoScheduledWrite) {
- ImportantFileWriter writer(file_, ThreadTaskRunnerHandle::Get());
+ ImportantFileWriter writer(file_, MessageLoopProxy::current().get());
EXPECT_FALSE(writer.HasPendingWrite());
DataSerializer serializer("foo");
writer.ScheduleWrite(&serializer);
EXPECT_TRUE(writer.HasPendingWrite());
writer.DoScheduledWrite();
- ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, MessageLoop::QuitWhenIdleClosure(),
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ MessageLoop::QuitWhenIdleClosure(),
TimeDelta::FromMilliseconds(100));
MessageLoop::current()->Run();
EXPECT_FALSE(writer.HasPendingWrite());
@@ -177,14 +177,15 @@ TEST_F(ImportantFileWriterTest, DoScheduledWrite) {
}
TEST_F(ImportantFileWriterTest, BatchingWrites) {
- ImportantFileWriter writer(file_, ThreadTaskRunnerHandle::Get());
+ ImportantFileWriter writer(file_, MessageLoopProxy::current().get());
writer.set_commit_interval(TimeDelta::FromMilliseconds(25));
DataSerializer foo("foo"), bar("bar"), baz("baz");
writer.ScheduleWrite(&foo);
writer.ScheduleWrite(&bar);
writer.ScheduleWrite(&baz);
- ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, MessageLoop::QuitWhenIdleClosure(),
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ MessageLoop::QuitWhenIdleClosure(),
TimeDelta::FromMilliseconds(100));
MessageLoop::current()->Run();
ASSERT_TRUE(PathExists(writer.path()));
diff --git a/base/memory/ref_counted_delete_on_message_loop.h b/base/memory/ref_counted_delete_on_message_loop.h
index 6a109e8..139a1ed 100644
--- a/base/memory/ref_counted_delete_on_message_loop.h
+++ b/base/memory/ref_counted_delete_on_message_loop.h
@@ -32,7 +32,6 @@ namespace base {
// ~Foo();
// };
-// TODO(skyostil): Rename this to RefCountedDeleteOnTaskRunner.
template <class T>
class RefCountedDeleteOnMessageLoop : public subtle::RefCountedThreadSafeBase {
public:
@@ -43,7 +42,7 @@ class RefCountedDeleteOnMessageLoop : public subtle::RefCountedThreadSafeBase {
RefCountedDeleteOnMessageLoop(
const scoped_refptr<SingleThreadTaskRunner>& task_runner)
: task_runner_(task_runner) {
- DCHECK(task_runner_);
+ DCHECK(task_runner_.get());
}
void AddRef() const {
diff --git a/base/memory/weak_ptr_unittest.cc b/base/memory/weak_ptr_unittest.cc
index 20e5c7b..d89a5c6 100644
--- a/base/memory/weak_ptr_unittest.cc
+++ b/base/memory/weak_ptr_unittest.cc
@@ -8,9 +8,8 @@
#include "base/bind.h"
#include "base/debug/leak_annotations.h"
-#include "base/location.h"
#include "base/memory/scoped_ptr.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -26,8 +25,9 @@ class OffThreadObjectCreator {
{
Thread creator_thread("creator_thread");
creator_thread.Start();
- creator_thread.task_runner()->PostTask(
- FROM_HERE, base::Bind(OffThreadObjectCreator::CreateObject, &result));
+ creator_thread.message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(OffThreadObjectCreator::CreateObject, &result));
}
DCHECK(result); // We synchronized on thread destruction above.
return result;
@@ -66,23 +66,25 @@ class BackgroundThread : public Thread {
void CreateArrowFromTarget(Arrow** arrow, Target* target) {
WaitableEvent completion(true, false);
- task_runner()->PostTask(
- FROM_HERE, base::Bind(&BackgroundThread::DoCreateArrowFromTarget, arrow,
- target, &completion));
+ message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&BackgroundThread::DoCreateArrowFromTarget,
+ arrow, target, &completion));
completion.Wait();
}
void CreateArrowFromArrow(Arrow** arrow, const Arrow* other) {
WaitableEvent completion(true, false);
- task_runner()->PostTask(
- FROM_HERE, base::Bind(&BackgroundThread::DoCreateArrowFromArrow, arrow,
- other, &completion));
+ message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&BackgroundThread::DoCreateArrowFromArrow,
+ arrow, other, &completion));
completion.Wait();
}
void DeleteTarget(Target* object) {
WaitableEvent completion(true, false);
- task_runner()->PostTask(
+ message_loop()->PostTask(
FROM_HERE,
base::Bind(&BackgroundThread::DoDeleteTarget, object, &completion));
completion.Wait();
@@ -90,23 +92,25 @@ class BackgroundThread : public Thread {
void CopyAndAssignArrow(Arrow* object) {
WaitableEvent completion(true, false);
- task_runner()->PostTask(
- FROM_HERE, base::Bind(&BackgroundThread::DoCopyAndAssignArrow, object,
- &completion));
+ message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&BackgroundThread::DoCopyAndAssignArrow,
+ object, &completion));
completion.Wait();
}
void CopyAndAssignArrowBase(Arrow* object) {
WaitableEvent completion(true, false);
- task_runner()->PostTask(
- FROM_HERE, base::Bind(&BackgroundThread::DoCopyAndAssignArrowBase,
- object, &completion));
+ message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&BackgroundThread::DoCopyAndAssignArrowBase,
+ object, &completion));
completion.Wait();
}
void DeleteArrow(Arrow* object) {
WaitableEvent completion(true, false);
- task_runner()->PostTask(
+ message_loop()->PostTask(
FROM_HERE,
base::Bind(&BackgroundThread::DoDeleteArrow, object, &completion));
completion.Wait();
@@ -115,8 +119,9 @@ class BackgroundThread : public Thread {
Target* DeRef(const Arrow* arrow) {
WaitableEvent completion(true, false);
Target* result = NULL;
- task_runner()->PostTask(FROM_HERE, base::Bind(&BackgroundThread::DoDeRef,
- arrow, &result, &completion));
+ message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&BackgroundThread::DoDeRef, arrow, &result, &completion));
completion.Wait();
return result;
}
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h
index e0ce0da..5205a5a 100644
--- a/base/observer_list_threadsafe.h
+++ b/base/observer_list_threadsafe.h
@@ -14,10 +14,9 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/observer_list.h"
-#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
///////////////////////////////////////////////////////////////////////////////
@@ -178,7 +177,7 @@ class ObserverListThreadSafe
base::AutoLock lock(list_lock_);
for (const auto& entry : observer_lists_) {
ObserverListContext* context = entry.second;
- context->task_runner->PostTask(
+ context->loop->PostTask(
from_here,
base::Bind(
&ObserverListThreadSafe<ObserverType>::template NotifyWrapper<
@@ -193,9 +192,11 @@ class ObserverListThreadSafe
struct ObserverListContext {
explicit ObserverListContext(NotificationType type)
- : task_runner(base::ThreadTaskRunnerHandle::Get()), list(type) {}
+ : loop(base::MessageLoopProxy::current()),
+ list(type) {
+ }
- scoped_refptr<base::SingleThreadTaskRunner> task_runner;
+ scoped_refptr<base::MessageLoopProxy> loop;
ObserverList<ObserverType> list;
private:
diff --git a/base/observer_list_unittest.cc b/base/observer_list_unittest.cc
index 2e51e45..ea916b1 100644
--- a/base/observer_list_unittest.cc
+++ b/base/observer_list_unittest.cc
@@ -8,10 +8,9 @@
#include <vector>
#include "base/compiler_specific.h"
-#include "base/location.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
#include "base/threading/platform_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -108,7 +107,7 @@ class AddRemoveThread : public PlatformThread::Delegate,
void ThreadMain() override {
loop_ = new MessageLoop(); // Fire up a message loop.
- loop_->task_runner()->PostTask(
+ loop_->PostTask(
FROM_HERE,
base::Bind(&AddRemoveThread::AddTask, weak_factory_.GetWeakPtr()));
loop_->Run();
@@ -138,14 +137,13 @@ class AddRemoveThread : public PlatformThread::Delegate,
list_->Notify(FROM_HERE, &Foo::Observe, 10);
}
- loop_->task_runner()->PostTask(
+ loop_->PostTask(
FROM_HERE,
base::Bind(&AddRemoveThread::AddTask, weak_factory_.GetWeakPtr()));
}
void Quit() {
- loop_->task_runner()->PostTask(FROM_HERE,
- MessageLoop::QuitWhenIdleClosure());
+ loop_->PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure());
}
void Observe(int x) override {
diff --git a/base/posix/unix_domain_socket_linux_unittest.cc b/base/posix/unix_domain_socket_linux_unittest.cc
index c05141c..60b2bb8 100644
--- a/base/posix/unix_domain_socket_linux_unittest.cc
+++ b/base/posix/unix_domain_socket_linux_unittest.cc
@@ -10,11 +10,9 @@
#include "base/bind_helpers.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
-#include "base/location.h"
#include "base/memory/scoped_vector.h"
#include "base/pickle.h"
#include "base/posix/unix_domain_socket_linux.h"
-#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -34,10 +32,11 @@ TEST(UnixDomainSocketTest, SendRecvMsgAbortOnReplyFDClose) {
// Have the thread send a synchronous message via the socket.
Pickle request;
- message_thread.task_runner()->PostTask(
+ message_thread.message_loop()->PostTask(
FROM_HERE,
- Bind(IgnoreResult(&UnixDomainSocket::SendRecvMsg), fds[1],
- static_cast<uint8_t*>(NULL), 0U, static_cast<int*>(NULL), request));
+ Bind(IgnoreResult(&UnixDomainSocket::SendRecvMsg),
+ fds[1], static_cast<uint8_t*>(NULL), 0U, static_cast<int*>(NULL),
+ request));
// Receive the message.
ScopedVector<base::ScopedFD> message_fds;
@@ -52,8 +51,9 @@ TEST(UnixDomainSocketTest, SendRecvMsgAbortOnReplyFDClose) {
// Check that the thread didn't get blocked.
WaitableEvent event(false, false);
- message_thread.task_runner()->PostTask(
- FROM_HERE, Bind(&WaitableEvent::Signal, Unretained(&event)));
+ message_thread.message_loop()->PostTask(
+ FROM_HERE,
+ Bind(&WaitableEvent::Signal, Unretained(&event)));
ASSERT_TRUE(event.TimedWait(TimeDelta::FromMilliseconds(5000)));
}
diff --git a/base/prefs/json_pref_store.h b/base/prefs/json_pref_store.h
index 1badcf2..d6ded59 100644
--- a/base/prefs/json_pref_store.h
+++ b/base/prefs/json_pref_store.h
@@ -17,6 +17,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/observer_list.h"
#include "base/prefs/base_prefs_export.h"
#include "base/prefs/persistent_pref_store.h"
diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc
index 728a57d..746c72b 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
@@ -16,7 +15,6 @@
#include "base/path_service.h"
#include "base/prefs/pref_filter.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -108,8 +106,7 @@ class JsonPrefStoreTest : public testing::Test {
void TearDown() override {
// Make sure all pending tasks have been processed (e.g., deleting the
// JsonPrefStore may post write tasks).
- message_loop_.task_runner()->PostTask(FROM_HERE,
- MessageLoop::QuitWhenIdleClosure());
+ message_loop_.PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure());
message_loop_.Run();
}
@@ -130,7 +127,9 @@ TEST_F(JsonPrefStoreTest, NonExistentFile) {
base::FilePath bogus_input_file = data_dir_.AppendASCII("read.txt");
ASSERT_FALSE(PathExists(bogus_input_file));
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- bogus_input_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ bogus_input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE,
pref_store->ReadPrefs());
EXPECT_FALSE(pref_store->ReadOnly());
@@ -143,9 +142,11 @@ TEST_F(JsonPrefStoreTest, NonExistentFileAndAlternateFile) {
data_dir_.AppendASCII("read_alternate.txt");
ASSERT_FALSE(PathExists(bogus_input_file));
ASSERT_FALSE(PathExists(bogus_alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(bogus_input_file, bogus_alternate_input_file,
- message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ bogus_input_file,
+ bogus_alternate_input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE,
pref_store->ReadPrefs());
EXPECT_FALSE(pref_store->ReadOnly());
@@ -156,8 +157,10 @@ TEST_F(JsonPrefStoreTest, InvalidFile) {
base::FilePath invalid_file_original = data_dir_.AppendASCII("invalid.json");
base::FilePath invalid_file = temp_dir_.path().AppendASCII("invalid.json");
ASSERT_TRUE(base::CopyFile(invalid_file_original, invalid_file));
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- invalid_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(invalid_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE,
pref_store->ReadPrefs());
EXPECT_FALSE(pref_store->ReadOnly());
@@ -243,7 +246,9 @@ TEST_F(JsonPrefStoreTest, Basic) {
base::FilePath input_file = temp_dir_.path().AppendASCII("write.json");
ASSERT_TRUE(PathExists(input_file));
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs());
EXPECT_FALSE(pref_store->ReadOnly());
EXPECT_TRUE(pref_store->IsInitializationComplete());
@@ -270,7 +275,9 @@ TEST_F(JsonPrefStoreTest, BasicAsync) {
base::FilePath input_file = temp_dir_.path().AppendASCII("write.json");
ASSERT_TRUE(PathExists(input_file));
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
{
MockPrefStoreObserver mock_observer;
@@ -307,7 +314,9 @@ TEST_F(JsonPrefStoreTest, PreserveEmptyValues) {
FilePath pref_file = temp_dir_.path().AppendASCII("empty_values.json");
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- pref_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ pref_file,
+ message_loop_.message_loop_proxy(),
+ scoped_ptr<PrefFilter>());
// Set some keys with empty values.
pref_store->SetValue("list", new base::ListValue);
@@ -318,8 +327,10 @@ TEST_F(JsonPrefStoreTest, PreserveEmptyValues) {
MessageLoop::current()->RunUntilIdle();
// Reload.
- pref_store = new JsonPrefStore(pref_file, message_loop_.task_runner(),
- scoped_ptr<PrefFilter>());
+ pref_store = new JsonPrefStore(
+ pref_file,
+ message_loop_.message_loop_proxy(),
+ scoped_ptr<PrefFilter>());
ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs());
ASSERT_FALSE(pref_store->ReadOnly());
@@ -337,7 +348,9 @@ TEST_F(JsonPrefStoreTest, RemoveClearsEmptyParent) {
FilePath pref_file = temp_dir_.path().AppendASCII("empty_values.json");
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- pref_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ pref_file,
+ message_loop_.message_loop_proxy(),
+ scoped_ptr<PrefFilter>());
base::DictionaryValue* dict = new base::DictionaryValue;
dict->SetString("key", "value");
@@ -355,7 +368,9 @@ TEST_F(JsonPrefStoreTest, AsyncNonExistingFile) {
base::FilePath bogus_input_file = data_dir_.AppendASCII("read.txt");
ASSERT_FALSE(PathExists(bogus_input_file));
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- bogus_input_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ bogus_input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
MockPrefStoreObserver mock_observer;
pref_store->AddObserver(&mock_observer);
@@ -383,8 +398,10 @@ TEST_F(JsonPrefStoreTest, ReadWithInterceptor) {
new InterceptingPrefFilter());
InterceptingPrefFilter* raw_intercepting_pref_filter_ =
intercepting_pref_filter.get();
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file, message_loop_.task_runner(), intercepting_pref_filter.Pass());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(input_file,
+ message_loop_.message_loop_proxy().get(),
+ intercepting_pref_filter.Pass());
ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE,
pref_store->ReadPrefs());
@@ -428,8 +445,10 @@ TEST_F(JsonPrefStoreTest, ReadAsyncWithInterceptor) {
new InterceptingPrefFilter());
InterceptingPrefFilter* raw_intercepting_pref_filter_ =
intercepting_pref_filter.get();
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file, message_loop_.task_runner(), intercepting_pref_filter.Pass());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(input_file,
+ message_loop_.message_loop_proxy().get(),
+ intercepting_pref_filter.Pass());
MockPrefStoreObserver mock_observer;
pref_store->AddObserver(&mock_observer);
@@ -492,9 +511,11 @@ TEST_F(JsonPrefStoreTest, AlternateFile) {
temp_dir_.path().AppendASCII("alternate.json");
ASSERT_FALSE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(input_file, alternate_input_file,
- message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ input_file,
+ alternate_input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
ASSERT_FALSE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
@@ -536,9 +557,11 @@ TEST_F(JsonPrefStoreTest, AlternateFileIgnoredWhenMainFileExists) {
temp_dir_.path().AppendASCII("alternate.json");
ASSERT_TRUE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(input_file, alternate_input_file,
- message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ input_file,
+ alternate_input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
ASSERT_TRUE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
@@ -576,9 +599,11 @@ TEST_F(JsonPrefStoreTest, AlternateFileDNE) {
temp_dir_.path().AppendASCII("alternate.json");
ASSERT_TRUE(PathExists(input_file));
ASSERT_FALSE(PathExists(alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(input_file, alternate_input_file,
- message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ input_file,
+ alternate_input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
ASSERT_TRUE(PathExists(input_file));
ASSERT_FALSE(PathExists(alternate_input_file));
@@ -616,9 +641,11 @@ TEST_F(JsonPrefStoreTest, BasicAsyncWithAlternateFile) {
temp_dir_.path().AppendASCII("alternate.json");
ASSERT_FALSE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(input_file, alternate_input_file,
- message_loop_.task_runner(), scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ input_file,
+ alternate_input_file,
+ message_loop_.message_loop_proxy().get(),
+ scoped_ptr<PrefFilter>());
ASSERT_FALSE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
diff --git a/base/prefs/pref_member.cc b/base/prefs/pref_member.cc
index 3097596..8d80dd0 100644
--- a/base/prefs/pref_member.cc
+++ b/base/prefs/pref_member.cc
@@ -7,10 +7,11 @@
#include "base/callback.h"
#include "base/callback_helpers.h"
#include "base/location.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/prefs/pref_service.h"
-#include "base/thread_task_runner_handle.h"
#include "base/value_conversions.h"
+using base::MessageLoopProxy;
using base::SingleThreadTaskRunner;
namespace subtle {
@@ -51,7 +52,7 @@ void PrefMemberBase::Destroy() {
}
void PrefMemberBase::MoveToThread(
- scoped_refptr<SingleThreadTaskRunner> task_runner) {
+ const scoped_refptr<SingleThreadTaskRunner>& task_runner) {
VerifyValuePrefName();
// Load the value from preferences if it hasn't been loaded so far.
if (!internal())
@@ -90,14 +91,15 @@ void PrefMemberBase::InvokeUnnamedCallback(const base::Closure& callback,
}
PrefMemberBase::Internal::Internal()
- : thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ : thread_loop_(MessageLoopProxy::current()),
is_managed_(false),
is_user_modifiable_(false) {
}
PrefMemberBase::Internal::~Internal() { }
bool PrefMemberBase::Internal::IsOnCorrectThread() const {
- return thread_task_runner_->BelongsToCurrentThread();
+ // In unit tests, there may not be a message loop.
+ return thread_loop_.get() == NULL || thread_loop_->BelongsToCurrentThread();
}
void PrefMemberBase::Internal::UpdateValue(
@@ -113,18 +115,19 @@ void PrefMemberBase::Internal::UpdateValue(
is_managed_ = is_managed;
is_user_modifiable_ = is_user_modifiable;
} else {
- bool may_run = thread_task_runner_->PostTask(
- FROM_HERE, base::Bind(&PrefMemberBase::Internal::UpdateValue, this,
- value.release(), is_managed, is_user_modifiable,
- closure_runner.Release()));
+ bool may_run = thread_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&PrefMemberBase::Internal::UpdateValue, this,
+ value.release(), is_managed, is_user_modifiable,
+ closure_runner.Release()));
DCHECK(may_run);
}
}
void PrefMemberBase::Internal::MoveToThread(
- scoped_refptr<SingleThreadTaskRunner> task_runner) {
+ const scoped_refptr<SingleThreadTaskRunner>& task_runner) {
CheckOnCorrectThread();
- thread_task_runner_ = task_runner.Pass();
+ thread_loop_ = task_runner;
}
bool PrefMemberVectorStringUpdate(const base::Value& value,
diff --git a/base/prefs/pref_member.h b/base/prefs/pref_member.h
index 6dceb43..9b140d1 100644
--- a/base/prefs/pref_member.h
+++ b/base/prefs/pref_member.h
@@ -65,7 +65,8 @@ class BASE_PREFS_EXPORT PrefMemberBase : public PrefObserver {
bool is_user_modifiable,
const base::Closure& callback) const;
- void MoveToThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+ void MoveToThread(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
// See PrefMember<> for description.
bool IsManaged() const {
@@ -91,7 +92,7 @@ class BASE_PREFS_EXPORT PrefMemberBase : public PrefObserver {
bool IsOnCorrectThread() const;
- scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> thread_loop_;
mutable bool is_managed_;
mutable bool is_user_modifiable_;
@@ -112,7 +113,8 @@ class BASE_PREFS_EXPORT PrefMemberBase : public PrefObserver {
// See PrefMember<> for description.
void Destroy();
- void MoveToThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+ void MoveToThread(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
// PrefObserver
void OnPreferenceChanged(PrefService* service,
@@ -199,7 +201,8 @@ class PrefMember : public subtle::PrefMemberBase {
// via PostTask.
// This method should only be used from the thread the PrefMember is currently
// on, which is the UI thread by default.
- void MoveToThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+ void MoveToThread(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
subtle::PrefMemberBase::MoveToThread(task_runner);
}
diff --git a/base/prefs/pref_member_unittest.cc b/base/prefs/pref_member_unittest.cc
index a776e2c..435122b 100644
--- a/base/prefs/pref_member_unittest.cc
+++ b/base/prefs/pref_member_unittest.cc
@@ -5,10 +5,9 @@
#include "base/prefs/pref_member.h"
#include "base/bind.h"
-#include "base/location.h"
+#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/testing_pref_service.h"
-#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -38,7 +37,7 @@ class GetPrefValueHelper
void Init(const std::string& pref_name, PrefService* prefs) {
pref_.Init(pref_name, prefs);
- pref_.MoveToThread(pref_thread_.task_runner());
+ pref_.MoveToThread(pref_thread_.message_loop_proxy());
}
void Destroy() {
@@ -47,9 +46,10 @@ class GetPrefValueHelper
void FetchValue() {
base::WaitableEvent event(true, false);
- ASSERT_TRUE(pref_thread_.task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&GetPrefValueHelper::GetPrefValue, this, &event)));
+ ASSERT_TRUE(
+ pref_thread_.message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&GetPrefValueHelper::GetPrefValue, this, &event)));
event.Wait();
}
@@ -100,11 +100,7 @@ class PrefMemberTestClass {
} // anonymous namespace
-class PrefMemberTest : public testing::Test {
- base::MessageLoop message_loop_;
-};
-
-TEST_F(PrefMemberTest, BasicGetAndSet) {
+TEST(PrefMemberTest, BasicGetAndSet) {
TestingPrefServiceSimple prefs;
RegisterTestPrefs(prefs.registry());
@@ -231,7 +227,7 @@ TEST_F(PrefMemberTest, BasicGetAndSet) {
EXPECT_EQ(expected_vector, *string_list);
}
-TEST_F(PrefMemberTest, InvalidList) {
+TEST(PrefMemberTest, InvalidList) {
// Set the vector to an initial good value.
std::vector<std::string> expected_vector;
expected_vector.push_back("foo");
@@ -249,7 +245,7 @@ TEST_F(PrefMemberTest, InvalidList) {
EXPECT_EQ(expected_vector, vector);
}
-TEST_F(PrefMemberTest, TwoPrefs) {
+TEST(PrefMemberTest, TwoPrefs) {
// Make sure two DoublePrefMembers stay in sync.
TestingPrefServiceSimple prefs;
RegisterTestPrefs(prefs.registry());
@@ -270,7 +266,7 @@ TEST_F(PrefMemberTest, TwoPrefs) {
EXPECT_EQ(4.2, *pref2);
}
-TEST_F(PrefMemberTest, Observer) {
+TEST(PrefMemberTest, Observer) {
TestingPrefServiceSimple prefs;
RegisterTestPrefs(prefs.registry());
@@ -297,12 +293,12 @@ TEST_F(PrefMemberTest, Observer) {
EXPECT_EQ("hello", prefs.GetString(kStringPref));
}
-TEST_F(PrefMemberTest, NoInit) {
+TEST(PrefMemberTest, NoInit) {
// Make sure not calling Init on a PrefMember doesn't cause problems.
IntegerPrefMember pref;
}
-TEST_F(PrefMemberTest, MoveToThread) {
+TEST(PrefMemberTest, MoveToThread) {
TestingPrefServiceSimple prefs;
scoped_refptr<GetPrefValueHelper> helper(new GetPrefValueHelper());
RegisterTestPrefs(prefs.registry());
diff --git a/base/prefs/pref_service.cc b/base/prefs/pref_service.cc
index 3ccdae7..5afb5ea 100644
--- a/base/prefs/pref_service.cc
+++ b/base/prefs/pref_service.cc
@@ -8,18 +8,16 @@
#include "base/bind.h"
#include "base/files/file_path.h"
-#include "base/location.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/prefs/default_pref_store.h"
#include "base/prefs/pref_notifier_impl.h"
#include "base/prefs/pref_registry.h"
#include "base/prefs/pref_value_store.h"
-#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
-#include "base/thread_task_runner_handle.h"
#include "base/value_conversions.h"
#include "build/build_config.h"
@@ -81,9 +79,10 @@ void PrefService::InitFromStorage(bool async) {
read_error_callback_.Run(user_pref_store_->ReadPrefs());
} else {
// Guarantee that initialization happens after this function returned.
- base::ThreadTaskRunnerHandle::Get()->PostTask(
+ base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&PersistentPrefStore::ReadPrefsAsync, user_pref_store_.get(),
+ base::Bind(&PersistentPrefStore::ReadPrefsAsync,
+ user_pref_store_.get(),
new ReadErrorHandler(read_error_callback_)));
}
}
diff --git a/base/sequence_checker_unittest.cc b/base/sequence_checker_unittest.cc
index 0aa0f9c..9aae82c 100644
--- a/base/sequence_checker_unittest.cc
+++ b/base/sequence_checker_unittest.cc
@@ -9,8 +9,8 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/sequence_checker.h"
-#include "base/single_thread_task_runner.h"
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -84,9 +84,10 @@ class SequenceCheckerTest : public testing::Test {
void PostDoStuffToOtherThread(
SequenceCheckedObject* sequence_checked_object) {
- other_thread()->task_runner()->PostTask(
- FROM_HERE, base::Bind(&SequenceCheckedObject::DoStuff,
- base::Unretained(sequence_checked_object)));
+ other_thread()->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&SequenceCheckedObject::DoStuff,
+ base::Unretained(sequence_checked_object)));
}
void PostDeleteToOtherThread(
diff --git a/base/single_thread_task_runner.h b/base/single_thread_task_runner.h
index 6e93193..b5311db 100644
--- a/base/single_thread_task_runner.h
+++ b/base/single_thread_task_runner.h
@@ -16,8 +16,7 @@ namespace base {
// there is a specific need to run tasks on only a single thread.
//
// SingleThreadTaskRunner implementations might:
-// - Post tasks to an existing thread's MessageLoop (see
-// MessageLoop::task_runner()).
+// - Post tasks to an existing thread's MessageLoop (see MessageLoopProxy).
// - Create their own worker thread and MessageLoop to post tasks to.
// - Add tasks to a FIFO and signal to a non-MessageLoop thread for them to
// be processed. This allows TaskRunner-oriented code run on threads
diff --git a/base/synchronization/cancellation_flag_unittest.cc b/base/synchronization/cancellation_flag_unittest.cc
index 13c74bc..02b08b6 100644
--- a/base/synchronization/cancellation_flag_unittest.cc
+++ b/base/synchronization/cancellation_flag_unittest.cc
@@ -7,9 +7,8 @@
#include "base/synchronization/cancellation_flag.h"
#include "base/bind.h"
-#include "base/location.h"
#include "base/logging.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop.h"
#include "base/synchronization/spin_wait.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
@@ -57,7 +56,7 @@ TEST(CancellationFlagTest, SetOnDifferentThreadDeathTest) {
ASSERT_TRUE(t.IsRunning());
CancellationFlag flag;
- t.task_runner()->PostTask(FROM_HERE, base::Bind(&CancelHelper, &flag));
+ t.message_loop()->PostTask(FROM_HERE, base::Bind(&CancelHelper, &flag));
}
} // namespace
diff --git a/base/synchronization/condition_variable_unittest.cc b/base/synchronization/condition_variable_unittest.cc
index e63a723..5d7a0ab 100644
--- a/base/synchronization/condition_variable_unittest.cc
+++ b/base/synchronization/condition_variable_unittest.cc
@@ -9,10 +9,8 @@
#include <vector>
#include "base/bind.h"
-#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/single_thread_task_runner.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/spin_wait.h"
@@ -222,7 +220,7 @@ TEST_F(ConditionVariableTest, DISABLED_TimeoutAcrossSetTimeOfDay) {
Thread thread("Helper");
thread.Start();
- thread.task_runner()->PostTask(FROM_HERE, base::Bind(&BackInTime, &lock));
+ thread.message_loop()->PostTask(FROM_HERE, base::Bind(&BackInTime, &lock));
TimeTicks start = TimeTicks::Now();
const TimeDelta kWaitTime = TimeDelta::FromMilliseconds(300);
diff --git a/base/synchronization/waitable_event_watcher_posix.cc b/base/synchronization/waitable_event_watcher_posix.cc
index ad66a4c..6fc337c 100644
--- a/base/synchronization/waitable_event_watcher_posix.cc
+++ b/base/synchronization/waitable_event_watcher_posix.cc
@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/location.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
@@ -68,7 +68,7 @@ class AsyncWaiter : public WaitableEvent::Waiter {
bool Fire(WaitableEvent* event) override {
// Post the callback if we haven't been cancelled.
if (!flag_->value()) {
- message_loop_->task_runner()->PostTask(FROM_HERE, callback_);
+ message_loop_->PostTask(FROM_HERE, callback_);
}
// We are removed from the wait-list by the WaitableEvent itself. It only
@@ -158,7 +158,7 @@ bool WaitableEventWatcher::StartWatching(
// No hairpinning - we can't call the delegate directly here. We have to
// enqueue a task on the MessageLoop as normal.
- current_ml->task_runner()->PostTask(FROM_HERE, internal_callback_);
+ current_ml->PostTask(FROM_HERE, internal_callback_);
return true;
}
diff --git a/base/task/cancelable_task_tracker.cc b/base/task/cancelable_task_tracker.cc
index a2e4799..b6e4b6a 100644
--- a/base/task/cancelable_task_tracker.cc
+++ b/base/task/cancelable_task_tracker.cc
@@ -11,10 +11,9 @@
#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/synchronization/cancellation_flag.h"
#include "base/task_runner.h"
-#include "base/thread_task_runner_handle.h"
using base::Bind;
using base::CancellationFlag;
@@ -86,7 +85,7 @@ CancelableTaskTracker::TaskId CancelableTaskTracker::PostTaskAndReply(
DCHECK(thread_checker_.CalledOnValidThread());
// We need a MessageLoop to run reply.
- DCHECK(base::ThreadTaskRunnerHandle::IsSet());
+ DCHECK(base::MessageLoopProxy::current().get());
// Owned by reply callback below.
CancellationFlag* flag = new CancellationFlag();
@@ -114,7 +113,7 @@ CancelableTaskTracker::TaskId CancelableTaskTracker::PostTaskAndReply(
CancelableTaskTracker::TaskId CancelableTaskTracker::NewTrackedTaskId(
IsCanceledCallback* is_canceled_cb) {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(base::ThreadTaskRunnerHandle::IsSet());
+ DCHECK(base::MessageLoopProxy::current().get());
TaskId id = next_id_;
next_id_++; // int64 is big enough that we ignore the potential overflow.
@@ -130,7 +129,7 @@ CancelableTaskTracker::TaskId CancelableTaskTracker::NewTrackedTaskId(
// Will always run |untrack_and_delete_flag| on current MessageLoop.
base::ScopedClosureRunner* untrack_and_delete_flag_runner =
new base::ScopedClosureRunner(Bind(&RunOrPostToTaskRunner,
- base::ThreadTaskRunnerHandle::Get(),
+ base::MessageLoopProxy::current(),
untrack_and_delete_flag));
*is_canceled_cb =
diff --git a/base/task/cancelable_task_tracker_unittest.cc b/base/task/cancelable_task_tracker_unittest.cc
index ff9e40b..8b2b86a 100644
--- a/base/task/cancelable_task_tracker_unittest.cc
+++ b/base/task/cancelable_task_tracker_unittest.cc
@@ -13,8 +13,8 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -84,13 +84,15 @@ TEST_F(CancelableTaskTrackerTest, NoCancel) {
Thread worker_thread("worker thread");
ASSERT_TRUE(worker_thread.Start());
- ignore_result(task_tracker_.PostTask(worker_thread.task_runner().get(),
+ ignore_result(task_tracker_.PostTask(worker_thread.message_loop_proxy().get(),
FROM_HERE,
MakeExpectedRunClosure(FROM_HERE)));
- ignore_result(task_tracker_.PostTaskAndReply(
- worker_thread.task_runner().get(), FROM_HERE,
- MakeExpectedRunClosure(FROM_HERE), MakeExpectedRunClosure(FROM_HERE)));
+ ignore_result(
+ task_tracker_.PostTaskAndReply(worker_thread.message_loop_proxy().get(),
+ FROM_HERE,
+ MakeExpectedRunClosure(FROM_HERE),
+ MakeExpectedRunClosure(FROM_HERE)));
CancelableTaskTracker::IsCanceledCallback is_canceled;
ignore_result(task_tracker_.NewTrackedTaskId(&is_canceled));
@@ -164,9 +166,11 @@ TEST_F(CancelableTaskTrackerTest, CancelReplyDifferentThread) {
Thread worker_thread("worker thread");
ASSERT_TRUE(worker_thread.Start());
- CancelableTaskTracker::TaskId task_id = task_tracker_.PostTaskAndReply(
- worker_thread.task_runner().get(), FROM_HERE, Bind(&DoNothing),
- MakeExpectedNotRunClosure(FROM_HERE));
+ CancelableTaskTracker::TaskId task_id =
+ task_tracker_.PostTaskAndReply(worker_thread.message_loop_proxy().get(),
+ FROM_HERE,
+ Bind(&DoNothing),
+ MakeExpectedNotRunClosure(FROM_HERE));
EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_id);
task_tracker_.TryCancel(task_id);
@@ -192,14 +196,14 @@ TEST_F(CancelableTaskTrackerTest, NewTrackedTaskIdDifferentThread) {
Thread other_thread("other thread");
ASSERT_TRUE(other_thread.Start());
- other_thread.task_runner()->PostTask(
+ other_thread.message_loop_proxy()->PostTask(
FROM_HERE, Bind(&ExpectIsCanceled, is_canceled, false));
other_thread.Stop();
task_tracker_.TryCancel(task_id);
ASSERT_TRUE(other_thread.Start());
- other_thread.task_runner()->PostTask(
+ other_thread.message_loop_proxy()->PostTask(
FROM_HERE, Bind(&ExpectIsCanceled, is_canceled, true));
other_thread.Stop();
}
@@ -374,9 +378,11 @@ TEST_F(CancelableTaskTrackerDeathTest, PostFromDifferentThread) {
Thread bad_thread("bad thread");
ASSERT_TRUE(bad_thread.Start());
- bad_thread.task_runner()->PostTask(
- FROM_HERE, Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
- Unretained(&task_tracker_), Bind(&PostDoNothingTask)));
+ bad_thread.message_loop_proxy()->PostTask(
+ FROM_HERE,
+ Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
+ Unretained(&task_tracker_),
+ Bind(&PostDoNothingTask)));
}
void TryCancel(CancelableTaskTracker::TaskId task_id,
@@ -395,9 +401,11 @@ TEST_F(CancelableTaskTrackerDeathTest, CancelOnDifferentThread) {
test_task_runner.get(), FROM_HERE, Bind(&DoNothing));
EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_id);
- bad_thread.task_runner()->PostTask(
- FROM_HERE, Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
- Unretained(&task_tracker_), Bind(&TryCancel, task_id)));
+ bad_thread.message_loop_proxy()->PostTask(
+ FROM_HERE,
+ Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
+ Unretained(&task_tracker_),
+ Bind(&TryCancel, task_id)));
test_task_runner->RunUntilIdle();
}
@@ -413,9 +421,10 @@ TEST_F(CancelableTaskTrackerDeathTest, CancelAllOnDifferentThread) {
test_task_runner.get(), FROM_HERE, Bind(&DoNothing));
EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_id);
- bad_thread.task_runner()->PostTask(
+ bad_thread.message_loop_proxy()->PostTask(
FROM_HERE,
- Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, Unretained(&task_tracker_),
+ Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
+ Unretained(&task_tracker_),
Bind(&CancelableTaskTracker::TryCancelAll)));
test_task_runner->RunUntilIdle();
diff --git a/base/task_runner_util_unittest.cc b/base/task_runner_util_unittest.cc
index 8245cfc..481f09e 100644
--- a/base/task_runner_util_unittest.cc
+++ b/base/task_runner_util_unittest.cc
@@ -5,7 +5,7 @@
#include "base/task_runner_util.h"
#include "base/bind.h"
-#include "base/location.h"
+#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -69,7 +69,8 @@ TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResult) {
int result = 0;
MessageLoop message_loop;
- PostTaskAndReplyWithResult(message_loop.task_runner().get(), FROM_HERE,
+ PostTaskAndReplyWithResult(message_loop.message_loop_proxy().get(),
+ FROM_HERE,
Bind(&ReturnFourtyTwo),
Bind(&StoreValue, &result));
@@ -82,7 +83,8 @@ TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResultImplicitConvert) {
double result = 0;
MessageLoop message_loop;
- PostTaskAndReplyWithResult(message_loop.task_runner().get(), FROM_HERE,
+ PostTaskAndReplyWithResult(message_loop.message_loop_proxy().get(),
+ FROM_HERE,
Bind(&ReturnFourtyTwo),
Bind(&StoreDoubleValue, &result));
@@ -96,8 +98,10 @@ TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResultPassed) {
g_foo_free_count = 0;
MessageLoop message_loop;
- PostTaskAndReplyWithResult(message_loop.task_runner().get(), FROM_HERE,
- Bind(&CreateFoo), Bind(&ExpectFoo));
+ PostTaskAndReplyWithResult(message_loop.message_loop_proxy().get(),
+ FROM_HERE,
+ Bind(&CreateFoo),
+ Bind(&ExpectFoo));
RunLoop().RunUntilIdle();
@@ -110,8 +114,10 @@ TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResultPassedFreeProc) {
g_foo_free_count = 0;
MessageLoop message_loop;
- PostTaskAndReplyWithResult(message_loop.task_runner().get(), FROM_HERE,
- Bind(&CreateScopedFoo), Bind(&ExpectScopedFoo));
+ PostTaskAndReplyWithResult(message_loop.message_loop_proxy().get(),
+ FROM_HERE,
+ Bind(&CreateScopedFoo),
+ Bind(&ExpectScopedFoo));
RunLoop().RunUntilIdle();
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index 7f258f5..521f69c 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -18,13 +18,11 @@
#include "base/format_macros.h"
#include "base/hash.h"
#include "base/lazy_instance.h"
-#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
-#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -36,7 +34,6 @@
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/test/test_switches.h"
#include "base/test/test_timeouts.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -352,7 +349,7 @@ void DoLaunchChildTestProcess(
TimeDelta timeout,
int flags,
bool redirect_stdio,
- SingleThreadTaskRunner* task_runner,
+ scoped_refptr<MessageLoopProxy> message_loop_proxy,
const TestLauncher::LaunchChildGTestProcessCallback& callback) {
TimeTicks start_time = TimeTicks::Now();
@@ -426,9 +423,14 @@ void DoLaunchChildTestProcess(
// Run target callback on the thread it was originating from, not on
// a worker pool thread.
- task_runner->PostTask(FROM_HERE, Bind(&RunCallback, callback, exit_code,
- TimeTicks::Now() - start_time,
- was_timeout, output_file_contents));
+ message_loop_proxy->PostTask(
+ FROM_HERE,
+ Bind(&RunCallback,
+ callback,
+ exit_code,
+ TimeTicks::Now() - start_time,
+ was_timeout,
+ output_file_contents));
}
} // namespace
@@ -502,8 +504,9 @@ bool TestLauncher::Run() {
// Start the watchdog timer.
watchdog_timer_.Reset();
- ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this)));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ Bind(&TestLauncher::RunTestIteration, Unretained(this)));
MessageLoop::current()->Run();
@@ -533,10 +536,16 @@ void TestLauncher::LaunchChildGTestProcess(
bool redirect_stdio = (parallel_jobs_ > 1) || BotModeEnabled();
worker_pool_owner_->pool()->PostWorkerTask(
- FROM_HERE, Bind(&DoLaunchChildTestProcess, new_command_line, timeout,
- flags, redirect_stdio, ThreadTaskRunnerHandle::Get(),
- Bind(&TestLauncher::OnLaunchTestProcessFinished,
- Unretained(this), callback)));
+ FROM_HERE,
+ Bind(&DoLaunchChildTestProcess,
+ new_command_line,
+ timeout,
+ flags,
+ redirect_stdio,
+ MessageLoopProxy::current(),
+ Bind(&TestLauncher::OnLaunchTestProcessFinished,
+ Unretained(this),
+ callback)));
}
void TestLauncher::OnTestFinished(const TestResult& result) {
@@ -948,8 +957,9 @@ void TestLauncher::RunTests() {
fflush(stdout);
// No tests have actually been started, so kick off the next iteration.
- ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this)));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ Bind(&TestLauncher::RunTestIteration, Unretained(this)));
}
}
@@ -970,7 +980,7 @@ void TestLauncher::RunTestIteration() {
tests_to_retry_.clear();
results_tracker_.OnTestIterationStarting();
- ThreadTaskRunnerHandle::Get()->PostTask(
+ MessageLoop::current()->PostTask(
FROM_HERE, Bind(&TestLauncher::RunTests, Unretained(this)));
}
@@ -1017,8 +1027,9 @@ void TestLauncher::OnTestIterationFinished() {
results_tracker_.PrintSummaryOfCurrentIteration();
// Kick off the next iteration.
- ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this)));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ Bind(&TestLauncher::RunTestIteration, Unretained(this)));
}
void TestLauncher::OnOutputTimeout() {
diff --git a/base/test/launcher/unit_test_launcher.cc b/base/test/launcher/unit_test_launcher.cc
index ab6fa72..1b3a162 100644
--- a/base/test/launcher/unit_test_launcher.cc
+++ b/base/test/launcher/unit_test_launcher.cc
@@ -12,9 +12,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/format_macros.h"
-#include "base/location.h"
#include "base/message_loop/message_loop.h"
-#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -24,7 +22,6 @@
#include "base/test/test_switches.h"
#include "base/test/test_timeouts.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/thread_checker.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -408,10 +405,13 @@ void SerialGTestCallback(
// The temporary file's directory is also temporary.
DeleteFile(callback_state.output_file.DirName(), true);
- ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, Bind(&RunUnitTestsSerially, callback_state.test_launcher,
- callback_state.platform_delegate, test_names,
- callback_state.launch_flags));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ Bind(&RunUnitTestsSerially,
+ callback_state.test_launcher,
+ callback_state.platform_delegate,
+ test_names,
+ callback_state.launch_flags));
}
} // namespace
@@ -576,9 +576,12 @@ size_t UnitTestLauncherDelegate::RunTests(
size_t UnitTestLauncherDelegate::RetryTests(
TestLauncher* test_launcher,
const std::vector<std::string>& test_names) {
- ThreadTaskRunnerHandle::Get()->PostTask(
+ MessageLoop::current()->PostTask(
FROM_HERE,
- Bind(&RunUnitTestsSerially, test_launcher, platform_delegate_, test_names,
+ Bind(&RunUnitTestsSerially,
+ test_launcher,
+ platform_delegate_,
+ test_names,
use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0));
return test_names.size();
}
diff --git a/base/test/sequenced_worker_pool_owner.cc b/base/test/sequenced_worker_pool_owner.cc
index b0d8b7a..4486323 100644
--- a/base/test/sequenced_worker_pool_owner.cc
+++ b/base/test/sequenced_worker_pool_owner.cc
@@ -6,7 +6,6 @@
#include "base/location.h"
#include "base/message_loop/message_loop.h"
-#include "base/single_thread_task_runner.h"
namespace base {
@@ -51,8 +50,9 @@ void SequencedWorkerPoolOwner::WillWaitForShutdown() {
}
void SequencedWorkerPoolOwner::OnDestruct() {
- constructor_message_loop_->task_runner()->PostTask(
- FROM_HERE, constructor_message_loop_->QuitWhenIdleClosure());
+ constructor_message_loop_->PostTask(
+ FROM_HERE,
+ constructor_message_loop_->QuitWhenIdleClosure());
}
} // namespace base
diff --git a/base/test/task_runner_test_template.h b/base/test/task_runner_test_template.h
index ee2b876..9bcf70b 100644
--- a/base/test/task_runner_test_template.h
+++ b/base/test/task_runner_test_template.h
@@ -53,9 +53,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/callback.h"
-#include "base/location.h"
#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/task_runner.h"
@@ -197,7 +195,7 @@ TYPED_TEST_P(TaskRunnerTest, RunsTasksOnCurrentThread) {
i);
for (int j = 0; j < i + 1; ++j) {
task_runner->PostTask(FROM_HERE, ith_task_runner_task);
- thread.task_runner()->PostTask(FROM_HERE, ith_non_task_runner_task);
+ thread.message_loop()->PostTask(FROM_HERE, ith_non_task_runner_task);
expected_task_run_counts[i] += 2;
}
}
diff --git a/base/test/thread_test_helper.cc b/base/test/thread_test_helper.cc
index 6a12190..2bd3ba5 100644
--- a/base/test/thread_test_helper.cc
+++ b/base/test/thread_test_helper.cc
@@ -11,9 +11,9 @@
namespace base {
ThreadTestHelper::ThreadTestHelper(
- scoped_refptr<SingleThreadTaskRunner> target_thread)
+ const scoped_refptr<MessageLoopProxy>& target_thread)
: test_result_(false),
- target_thread_(target_thread.Pass()),
+ target_thread_(target_thread),
done_event_(false, false) {
}
diff --git a/base/test/thread_test_helper.h b/base/test/thread_test_helper.h
index 926da73..f6817b5 100644
--- a/base/test/thread_test_helper.h
+++ b/base/test/thread_test_helper.h
@@ -7,7 +7,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/synchronization/waitable_event.h"
namespace base {
@@ -19,7 +19,7 @@ namespace base {
class ThreadTestHelper : public RefCountedThreadSafe<ThreadTestHelper> {
public:
explicit ThreadTestHelper(
- scoped_refptr<SingleThreadTaskRunner> target_thread);
+ const scoped_refptr<MessageLoopProxy>& target_thread);
// True if RunTest() was successfully executed on the target thread.
bool Run() WARN_UNUSED_RESULT;
@@ -38,7 +38,7 @@ class ThreadTestHelper : public RefCountedThreadSafe<ThreadTestHelper> {
void RunInThread();
bool test_result_;
- scoped_refptr<SingleThreadTaskRunner> target_thread_;
+ scoped_refptr<MessageLoopProxy> target_thread_;
WaitableEvent done_event_;
DISALLOW_COPY_AND_ASSIGN(ThreadTestHelper);
diff --git a/base/threading/post_task_and_reply_impl.cc b/base/threading/post_task_and_reply_impl.cc
index f3e88ab..a82a4fd 100644
--- a/base/threading/post_task_and_reply_impl.cc
+++ b/base/threading/post_task_and_reply_impl.cc
@@ -25,30 +25,30 @@ namespace {
class PostTaskAndReplyRelay {
public:
PostTaskAndReplyRelay(const tracked_objects::Location& from_here,
- const Closure& task,
- const Closure& reply)
+ const Closure& task, const Closure& reply)
: from_here_(from_here),
- origin_task_runner_(ThreadTaskRunnerHandle::Get()) {
+ origin_loop_(ThreadTaskRunnerHandle::Get()) {
task_ = task;
reply_ = reply;
}
~PostTaskAndReplyRelay() {
- DCHECK(origin_task_runner_->BelongsToCurrentThread());
+ DCHECK(origin_loop_->BelongsToCurrentThread());
task_.Reset();
reply_.Reset();
}
void Run() {
task_.Run();
- origin_task_runner_->PostTask(
- from_here_, Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct,
- base::Unretained(this)));
+ origin_loop_->PostTask(
+ from_here_,
+ Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct,
+ base::Unretained(this)));
}
private:
void RunReplyAndSelfDestruct() {
- DCHECK(origin_task_runner_->BelongsToCurrentThread());
+ DCHECK(origin_loop_->BelongsToCurrentThread());
// Force |task_| to be released before |reply_| is to ensure that no one
// accidentally depends on |task_| keeping one of its arguments alive while
@@ -62,7 +62,7 @@ class PostTaskAndReplyRelay {
}
tracked_objects::Location from_here_;
- scoped_refptr<SingleThreadTaskRunner> origin_task_runner_;
+ scoped_refptr<SingleThreadTaskRunner> origin_loop_;
Closure reply_;
Closure task_;
};
diff --git a/base/threading/post_task_and_reply_impl.h b/base/threading/post_task_and_reply_impl.h
index a5b9580..076a46d 100644
--- a/base/threading/post_task_and_reply_impl.h
+++ b/base/threading/post_task_and_reply_impl.h
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// This file contains the implementation shared by
-// TaskRunner::PostTaskAndReply and WorkerPool::PostTaskAndReply.
+// MessageLoopProxy::PostTaskAndReply and WorkerPool::PostTaskAndReply.
#ifndef BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_
#define BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_
@@ -21,11 +21,11 @@ namespace internal {
// MessageLoop.
//
// If you're looking for a concrete implementation of
-// PostTaskAndReply, you probably want base::SingleThreadTaskRunner, or you
+// PostTaskAndReply, you probably want base::MessageLoopProxy, or you
// may want base::WorkerPool.
class PostTaskAndReplyImpl {
public:
- // Implementation for TaskRunner::PostTaskAndReply and
+ // Implementation for MessageLoopProxy::PostTaskAndReply and
// WorkerPool::PostTaskAndReply.
bool PostTaskAndReply(const tracked_objects::Location& from_here,
const Closure& task,
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index 459c31b..6f4a248 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -17,11 +17,11 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/linked_ptr.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
#include "base/threading/simple_thread.h"
#include "base/threading/thread_local.h"
@@ -1158,27 +1158,29 @@ SequencedWorkerPool::GetSequenceTokenForCurrentThread() {
return *token;
}
-SequencedWorkerPool::SequencedWorkerPool(size_t max_threads,
- const std::string& thread_name_prefix)
- : constructor_task_runner_(ThreadTaskRunnerHandle::Get()),
+SequencedWorkerPool::SequencedWorkerPool(
+ size_t max_threads,
+ const std::string& thread_name_prefix)
+ : constructor_message_loop_(MessageLoopProxy::current()),
inner_(new Inner(this, max_threads, thread_name_prefix, NULL)) {
}
-SequencedWorkerPool::SequencedWorkerPool(size_t max_threads,
- const std::string& thread_name_prefix,
- TestingObserver* observer)
- : constructor_task_runner_(ThreadTaskRunnerHandle::Get()),
+SequencedWorkerPool::SequencedWorkerPool(
+ size_t max_threads,
+ const std::string& thread_name_prefix,
+ TestingObserver* observer)
+ : constructor_message_loop_(MessageLoopProxy::current()),
inner_(new Inner(this, max_threads, thread_name_prefix, observer)) {
}
SequencedWorkerPool::~SequencedWorkerPool() {}
void SequencedWorkerPool::OnDestruct() const {
- DCHECK(constructor_task_runner_);
+ DCHECK(constructor_message_loop_.get());
// Avoid deleting ourselves on a worker thread (which would
// deadlock).
if (RunsTasksOnCurrentThread()) {
- constructor_task_runner_->DeleteSoon(FROM_HERE, this);
+ constructor_message_loop_->DeleteSoon(FROM_HERE, this);
} else {
delete this;
}
@@ -1298,7 +1300,7 @@ void SequencedWorkerPool::SignalHasWorkForTesting() {
}
void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) {
- DCHECK(constructor_task_runner_->BelongsToCurrentThread());
+ DCHECK(constructor_message_loop_->BelongsToCurrentThread());
inner_->Shutdown(max_new_blocking_tasks_after_shutdown);
}
diff --git a/base/threading/sequenced_worker_pool.h b/base/threading/sequenced_worker_pool.h
index 2126b0d..0b6c5f9 100644
--- a/base/threading/sequenced_worker_pool.h
+++ b/base/threading/sequenced_worker_pool.h
@@ -11,10 +11,8 @@
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/callback_forward.h"
-#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/single_thread_task_runner.h"
#include "base/task_runner.h"
namespace tracked_objects {
@@ -23,7 +21,7 @@ class Location;
namespace base {
-class SingleThreadTaskRunner;
+class MessageLoopProxy;
template <class T> class DeleteHelper;
@@ -347,7 +345,7 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
class Inner;
class Worker;
- const scoped_refptr<SingleThreadTaskRunner> constructor_task_runner_;
+ const scoped_refptr<MessageLoopProxy> constructor_message_loop_;
// Avoid pulling in too many headers by putting (almost) everything
// into |inner_|.
diff --git a/base/threading/sequenced_worker_pool_unittest.cc b/base/threading/sequenced_worker_pool_unittest.cc
index 05989a5..c12156e 100644
--- a/base/threading/sequenced_worker_pool_unittest.cc
+++ b/base/threading/sequenced_worker_pool_unittest.cc
@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/test/sequenced_task_runner_test_template.h"
diff --git a/base/threading/thread.cc b/base/threading/thread.cc
index bab3991..d42ba4d 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/lazy_instance.h"
-#include "base/location.h"
#include "base/profiler/scoped_tracker.h"
#include "base/synchronization/waitable_event.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
@@ -163,7 +162,7 @@ void Thread::StopSoon() {
return;
stopping_ = true;
- task_runner()->PostTask(FROM_HERE, base::Bind(&ThreadQuitHelper));
+ message_loop_->PostTask(FROM_HERE, base::Bind(&ThreadQuitHelper));
}
bool Thread::IsRunning() const {
diff --git a/base/threading/thread.h b/base/threading/thread.h
index 4915606..5010f0e 100644
--- a/base/threading/thread.h
+++ b/base/threading/thread.h
@@ -11,8 +11,8 @@
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/message_loop/timer_slack.h"
-#include "base/single_thread_task_runner.h"
#include "base/threading/platform_thread.h"
namespace base {
@@ -156,7 +156,7 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// hold on to this even after the thread is gone; in this situation, attempts
// to PostTask() will fail.
scoped_refptr<SingleThreadTaskRunner> task_runner() const {
- return message_loop_->task_runner();
+ return message_loop_proxy();
}
// Returns the name of this thread (for display in debugger too).
diff --git a/base/threading/thread_perftest.cc b/base/threading/thread_perftest.cc
index 3bc9fb4..a08cc5b 100644
--- a/base/threading/thread_perftest.cc
+++ b/base/threading/thread_perftest.cc
@@ -5,9 +5,7 @@
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
-#include "base/location.h"
#include "base/memory/scoped_vector.h"
-#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
@@ -56,9 +54,12 @@ class ThreadPerfTest : public testing::Test {
base::TimeTicks ThreadNow(base::Thread* thread) {
base::WaitableEvent done(false, false);
base::TimeTicks ticks;
- thread->task_runner()->PostTask(
- FROM_HERE, base::Bind(&ThreadPerfTest::TimeOnThread,
- base::Unretained(this), &ticks, &done));
+ thread->message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadPerfTest::TimeOnThread,
+ base::Unretained(this),
+ &ticks,
+ &done));
done.Wait();
return ticks;
}
@@ -127,9 +128,10 @@ class TaskPerfTest : public ThreadPerfTest {
FinishMeasurement();
return;
}
- NextThread(hops)->task_runner()->PostTask(
- FROM_HERE, base::Bind(&ThreadPerfTest::PingPong, base::Unretained(this),
- hops - 1));
+ NextThread(hops)->message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &ThreadPerfTest::PingPong, base::Unretained(this), hops - 1));
}
};
@@ -196,9 +198,11 @@ class EventPerfTest : public ThreadPerfTest {
void PingPong(int hops) override {
remaining_hops_ = hops;
for (size_t i = 0; i < threads_.size(); i++) {
- threads_[i]->task_runner()->PostTask(
- FROM_HERE, base::Bind(&EventPerfTest::WaitAndSignalOnThread,
- base::Unretained(this), i));
+ threads_[i]->message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&EventPerfTest::WaitAndSignalOnThread,
+ base::Unretained(this),
+ i));
}
// Kick off the Signal ping-ponging.
diff --git a/base/threading/thread_unittest.cc b/base/threading/thread_unittest.cc
index a89768e..f4d024f 100644
--- a/base/threading/thread_unittest.cc
+++ b/base/threading/thread_unittest.cc
@@ -7,8 +7,7 @@
#include <vector>
#include "base/bind.h"
-#include "base/location.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -145,7 +144,7 @@ TEST_F(ThreadTest, StartWithOptions_StackSize) {
EXPECT_TRUE(a.IsRunning());
bool was_invoked = false;
- a.task_runner()->PostTask(FROM_HERE, base::Bind(&ToggleValue, &was_invoked));
+ a.message_loop()->PostTask(FROM_HERE, base::Bind(&ToggleValue, &was_invoked));
// wait for the task to run (we could use a kernel event here
// instead to avoid busy waiting, but this is sufficient for
@@ -166,12 +165,14 @@ TEST_F(ThreadTest, TwoTasks) {
// Test that all events are dispatched before the Thread object is
// destroyed. We do this by dispatching a sleep event before the
// event that will toggle our sentinel value.
- a.task_runner()->PostTask(
- FROM_HERE, base::Bind(static_cast<void (*)(base::TimeDelta)>(
- &base::PlatformThread::Sleep),
- base::TimeDelta::FromMilliseconds(20)));
- a.task_runner()->PostTask(FROM_HERE,
- base::Bind(&ToggleValue, &was_invoked));
+ a.message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ static_cast<void (*)(base::TimeDelta)>(
+ &base::PlatformThread::Sleep),
+ base::TimeDelta::FromMilliseconds(20)));
+ a.message_loop()->PostTask(FROM_HERE, base::Bind(&ToggleValue,
+ &was_invoked));
}
EXPECT_TRUE(was_invoked);
}
@@ -220,7 +221,7 @@ TEST_F(ThreadTest, CleanUp) {
// Register an observer that writes into |captured_events| once the
// thread's message loop is destroyed.
- t.task_runner()->PostTask(
+ t.message_loop()->PostTask(
FROM_HERE, base::Bind(&RegisterDestructionObserver,
base::Unretained(&loop_destruction_observer)));
diff --git a/base/threading/worker_pool.h b/base/threading/worker_pool.h
index a52a414..333b495 100644
--- a/base/threading/worker_pool.h
+++ b/base/threading/worker_pool.h
@@ -36,7 +36,7 @@ class BASE_EXPORT WorkerPool {
static bool PostTask(const tracked_objects::Location& from_here,
const base::Closure& task, bool task_is_slow);
- // Just like TaskRunner::PostTaskAndReply, except the destination
+ // Just like MessageLoopProxy::PostTaskAndReply, except the destination
// for |task| is a worker thread and you can specify |task_is_slow| just
// like you can for PostTask above.
static bool PostTaskAndReply(const tracked_objects::Location& from_here,
diff --git a/base/trace_event/trace_event_android.cc b/base/trace_event/trace_event_android.cc
index 26bd0c7..bcba436 100644
--- a/base/trace_event/trace_event_android.cc
+++ b/base/trace_event/trace_event_android.cc
@@ -114,7 +114,7 @@ void TraceLog::StopATrace() {
Thread end_chrome_tracing_thread("end_chrome_tracing");
WaitableEvent complete_event(false, false);
end_chrome_tracing_thread.Start();
- end_chrome_tracing_thread.task_runner()->PostTask(
+ end_chrome_tracing_thread.message_loop()->PostTask(
FROM_HERE, base::Bind(&EndChromeTracing, Unretained(this),
Unretained(&complete_event)));
complete_event.Wait();
diff --git a/base/trace_event/trace_event_impl.cc b/base/trace_event/trace_event_impl.cc
index f1c87dd..cbeeeab 100644
--- a/base/trace_event/trace_event_impl.cc
+++ b/base/trace_event/trace_event_impl.cc
@@ -14,8 +14,8 @@
#include "base/format_macros.h"
#include "base/json/string_escape.h"
#include "base/lazy_instance.h"
-#include "base/location.h"
#include "base/memory/singleton.h"
+#include "base/message_loop/message_loop.h"
#include "base/process/process_metrics.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
@@ -28,7 +28,6 @@
#include "base/synchronization/waitable_event.h"
#include "base/sys_info.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_id_name_manager.h"
#include "base/threading/worker_pool.h"
@@ -1407,7 +1406,7 @@ void TraceLog::SetEnabled(const CategoryFilter& category_filter,
AutoLock lock(lock_);
// Can't enable tracing when Flush() is in progress.
- DCHECK(!flush_task_runner_);
+ DCHECK(!flush_message_loop_proxy_.get());
InternalTraceOptions new_options =
GetInternalOptionsFromTraceOptions(options);
@@ -1681,9 +1680,9 @@ void TraceLog::SetEventCallbackDisabled() {
}
// Flush() works as the following:
-// 1. Flush() is called in thread A whose task runner is saved in
-// flush_task_runner_;
-// 2. If thread_message_loops_ is not empty, thread A posts task to each message
+// 1. Flush() is called in threadA whose message loop is saved in
+// flush_message_loop_proxy_;
+// 2. If thread_message_loops_ is not empty, threadA posts task to each message
// loop to flush the thread local buffers; otherwise finish the flush;
// 3. FlushCurrentThread() deletes the thread local event buffer:
// - The last batch of events of the thread are flushed into the main buffer;
@@ -1711,11 +1710,9 @@ void TraceLog::Flush(const TraceLog::OutputCallback& cb,
thread_message_loop_task_runners;
{
AutoLock lock(lock_);
- DCHECK(!flush_task_runner_);
- flush_task_runner_ = ThreadTaskRunnerHandle::IsSet()
- ? ThreadTaskRunnerHandle::Get()
- : nullptr;
- DCHECK_IMPLIES(thread_message_loops_.size(), flush_task_runner_);
+ DCHECK(!flush_message_loop_proxy_.get());
+ flush_message_loop_proxy_ = MessageLoopProxy::current();
+ DCHECK(!thread_message_loops_.size() || flush_message_loop_proxy_.get());
flush_output_callback_ = cb;
if (thread_shared_chunk_) {
@@ -1738,7 +1735,7 @@ void TraceLog::Flush(const TraceLog::OutputCallback& cb,
FROM_HERE,
Bind(&TraceLog::FlushCurrentThread, Unretained(this), generation));
}
- flush_task_runner_->PostDelayedTask(
+ flush_message_loop_proxy_->PostDelayedTask(
FROM_HERE,
Bind(&TraceLog::OnFlushTimeout, Unretained(this), generation),
TimeDelta::FromMilliseconds(kThreadFlushTimeoutMs));
@@ -1792,7 +1789,7 @@ void TraceLog::FinishFlush(int generation) {
UseNextTraceBuffer();
thread_message_loops_.clear();
- flush_task_runner_ = NULL;
+ flush_message_loop_proxy_ = NULL;
flush_output_callback = flush_output_callback_;
flush_output_callback_.Reset();
}
@@ -1815,7 +1812,7 @@ void TraceLog::FinishFlush(int generation) {
void TraceLog::FlushCurrentThread(int generation) {
{
AutoLock lock(lock_);
- if (!CheckGeneration(generation) || !flush_task_runner_) {
+ if (!CheckGeneration(generation) || !flush_message_loop_proxy_.get()) {
// This is late. The corresponding flush has finished.
return;
}
@@ -1825,18 +1822,19 @@ void TraceLog::FlushCurrentThread(int generation) {
delete thread_local_event_buffer_.Get();
AutoLock lock(lock_);
- if (!CheckGeneration(generation) || !flush_task_runner_ ||
+ if (!CheckGeneration(generation) || !flush_message_loop_proxy_.get() ||
thread_message_loops_.size())
return;
- flush_task_runner_->PostTask(
- FROM_HERE, Bind(&TraceLog::FinishFlush, Unretained(this), generation));
+ flush_message_loop_proxy_->PostTask(
+ FROM_HERE,
+ Bind(&TraceLog::FinishFlush, Unretained(this), generation));
}
void TraceLog::OnFlushTimeout(int generation) {
{
AutoLock lock(lock_);
- if (!CheckGeneration(generation) || !flush_task_runner_) {
+ if (!CheckGeneration(generation) || !flush_message_loop_proxy_.get()) {
// Flush has finished before timeout.
return;
}
diff --git a/base/trace_event/trace_event_impl.h b/base/trace_event/trace_event_impl.h
index 50d33ca..33a85c9 100644
--- a/base/trace_event/trace_event_impl.h
+++ b/base/trace_event/trace_event_impl.h
@@ -18,7 +18,6 @@
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_vector.h"
#include "base/observer_list.h"
-#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
@@ -799,8 +798,8 @@ class BASE_EXPORT TraceLog {
ThreadLocalBoolean thread_is_in_trace_event_;
// Contains the message loops of threads that have had at least one event
- // added into the local event buffer. Not using SingleThreadTaskRunner
- // because we need to know the life time of the message loops.
+ // added into the local event buffer. Not using MessageLoopProxy because we
+ // need to know the life time of the message loops.
hash_set<MessageLoop*> thread_message_loops_;
// For events which can't be added into the thread local buffer, e.g. events
@@ -810,7 +809,7 @@ class BASE_EXPORT TraceLog {
// Set when asynchronous Flush is in progress.
OutputCallback flush_output_callback_;
- scoped_refptr<SingleThreadTaskRunner> flush_task_runner_;
+ scoped_refptr<MessageLoopProxy> flush_message_loop_proxy_;
subtle::AtomicWord generation_;
bool use_worker_thread_;
diff --git a/base/trace_event/trace_event_memory.cc b/base/trace_event/trace_event_memory.cc
index ab8ba0d3..2bf6d38 100644
--- a/base/trace_event/trace_event_memory.cc
+++ b/base/trace_event/trace_event_memory.cc
@@ -6,10 +6,9 @@
#include "base/debug/leak_annotations.h"
#include "base/lazy_instance.h"
-#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/single_thread_task_runner.h"
+#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_local_storage.h"
@@ -145,11 +144,11 @@ int GetPseudoStack(int skip_count_ignored, void** stack_out) {
//////////////////////////////////////////////////////////////////////////////
TraceMemoryController::TraceMemoryController(
- scoped_refptr<SingleThreadTaskRunner> task_runner,
+ scoped_refptr<MessageLoopProxy> message_loop_proxy,
HeapProfilerStartFunction heap_profiler_start_function,
HeapProfilerStopFunction heap_profiler_stop_function,
GetHeapProfileFunction get_heap_profile_function)
- : task_runner_(task_runner.Pass()),
+ : message_loop_proxy_(message_loop_proxy),
heap_profiler_start_function_(heap_profiler_start_function),
heap_profiler_stop_function_(heap_profiler_stop_function),
get_heap_profile_function_(get_heap_profile_function),
@@ -175,9 +174,10 @@ void TraceMemoryController::OnTraceLogEnabled() {
if (!enabled)
return;
DVLOG(1) << "OnTraceLogEnabled";
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&TraceMemoryController::StartProfiling,
- weak_factory_.GetWeakPtr()));
+ message_loop_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&TraceMemoryController::StartProfiling,
+ weak_factory_.GetWeakPtr()));
}
void TraceMemoryController::OnTraceLogDisabled() {
@@ -185,9 +185,10 @@ void TraceMemoryController::OnTraceLogDisabled() {
// called, so we cannot tell if it was enabled before. Always try to turn
// off profiling.
DVLOG(1) << "OnTraceLogDisabled";
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&TraceMemoryController::StopProfiling,
- weak_factory_.GetWeakPtr()));
+ message_loop_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&TraceMemoryController::StopProfiling,
+ weak_factory_.GetWeakPtr()));
}
void TraceMemoryController::StartProfiling() {
diff --git a/base/trace_event/trace_event_memory.h b/base/trace_event/trace_event_memory.h
index e2b3ae9..8e70020 100644
--- a/base/trace_event/trace_event_memory.h
+++ b/base/trace_event/trace_event_memory.h
@@ -20,7 +20,7 @@
namespace base {
-class SingleThreadTaskRunner;
+class MessageLoopProxy;
namespace trace_event {
@@ -35,14 +35,15 @@ class BASE_EXPORT TraceMemoryController
typedef void (*HeapProfilerStopFunction)();
typedef char* (*GetHeapProfileFunction)();
- // |task_runner| must be a task runner for the primary thread for the client
+ // |message_loop_proxy| must be a proxy to the primary thread for the client
// process, e.g. the UI thread in a browser. The function pointers must be
// pointers to tcmalloc heap profiling functions; by avoiding direct calls to
// these functions we avoid a dependency on third_party/tcmalloc from base.
- TraceMemoryController(scoped_refptr<SingleThreadTaskRunner> task_runner,
- HeapProfilerStartFunction heap_profiler_start_function,
- HeapProfilerStopFunction heap_profiler_stop_function,
- GetHeapProfileFunction get_heap_profile_function);
+ TraceMemoryController(
+ scoped_refptr<MessageLoopProxy> message_loop_proxy,
+ HeapProfilerStartFunction heap_profiler_start_function,
+ HeapProfilerStopFunction heap_profiler_stop_function,
+ GetHeapProfileFunction get_heap_profile_function);
virtual ~TraceMemoryController();
// base::trace_event::TraceLog::EnabledStateChangedObserver overrides:
@@ -64,7 +65,7 @@ class BASE_EXPORT TraceMemoryController
bool IsTimerRunningForTest() const;
// Ensures the observer starts and stops tracing on the primary thread.
- scoped_refptr<SingleThreadTaskRunner> task_runner_;
+ scoped_refptr<MessageLoopProxy> message_loop_proxy_;
// Pointers to tcmalloc heap profiling functions. Allows this class to use
// tcmalloc functions without introducing a dependency from base to tcmalloc.
diff --git a/base/trace_event/trace_event_memory_unittest.cc b/base/trace_event/trace_event_memory_unittest.cc
index 781a054..4732733 100644
--- a/base/trace_event/trace_event_memory_unittest.cc
+++ b/base/trace_event/trace_event_memory_unittest.cc
@@ -7,6 +7,7 @@
#include <sstream>
#include <string>
+#include "base/message_loop/message_loop.h"
#include "base/trace_event/trace_event_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -39,9 +40,12 @@ TEST_F(TraceMemoryTest, TraceMemoryController) {
EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest());
// Creating a controller adds it to the TraceLog observer list.
- scoped_ptr<TraceMemoryController> controller(new TraceMemoryController(
- message_loop.task_runner(), ::HeapProfilerWithPseudoStackStart,
- ::HeapProfilerStop, ::GetHeapProfile));
+ scoped_ptr<TraceMemoryController> controller(
+ new TraceMemoryController(
+ message_loop.message_loop_proxy(),
+ ::HeapProfilerWithPseudoStackStart,
+ ::HeapProfilerStop,
+ ::GetHeapProfile));
EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest());
EXPECT_TRUE(
TraceLog::GetInstance()->HasEnabledStateObserver(controller.get()));
diff --git a/base/trace_event/trace_event_system_stats_monitor_unittest.cc b/base/trace_event/trace_event_system_stats_monitor_unittest.cc
index 03dff591..995f53b 100644
--- a/base/trace_event/trace_event_system_stats_monitor_unittest.cc
+++ b/base/trace_event/trace_event_system_stats_monitor_unittest.cc
@@ -7,6 +7,7 @@
#include <sstream>
#include <string>
+#include "base/message_loop/message_loop.h"
#include "base/trace_event/trace_event_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -35,7 +36,8 @@ TEST_F(TraceSystemStatsMonitorTest, TraceEventSystemStatsMonitor) {
// Creating a system stats monitor adds it to the TraceLog observer list.
scoped_ptr<TraceEventSystemStatsMonitor> system_stats_monitor(
- new TraceEventSystemStatsMonitor(message_loop.task_runner()));
+ new TraceEventSystemStatsMonitor(
+ message_loop.message_loop_proxy()));
EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest());
EXPECT_TRUE(
TraceLog::GetInstance()->HasEnabledStateObserver(
diff --git a/base/trace_event/trace_event_unittest.cc b/base/trace_event/trace_event_unittest.cc
index 17953e7..0d3b091 100644
--- a/base/trace_event/trace_event_unittest.cc
+++ b/base/trace_event/trace_event_unittest.cc
@@ -9,12 +9,10 @@
#include "base/command_line.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
-#include "base/location.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/process/process_handle.h"
-#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
@@ -97,9 +95,10 @@ class TraceEventTestFixture : public testing::Test {
WaitableEvent flush_complete_event(false, false);
Thread flush_thread("flush");
flush_thread.Start();
- flush_thread.task_runner()->PostTask(
- FROM_HERE, base::Bind(&TraceEventTestFixture::EndTraceAndFlushAsync,
- base::Unretained(this), &flush_complete_event));
+ flush_thread.message_loop()->PostTask(FROM_HERE,
+ base::Bind(&TraceEventTestFixture::EndTraceAndFlushAsync,
+ base::Unretained(this),
+ &flush_complete_event));
flush_complete_event.Wait();
}
@@ -1425,7 +1424,7 @@ TEST_F(TraceEventTestFixture, DataCapturedOnThread) {
WaitableEvent task_complete_event(false, false);
thread.Start();
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, base::Bind(&TraceWithAllMacroVariants, &task_complete_event));
task_complete_event.Wait();
thread.Stop();
@@ -1446,9 +1445,9 @@ TEST_F(TraceEventTestFixture, DataCapturedManyThreads) {
threads[i] = new Thread(StringPrintf("Thread %d", i));
task_complete_events[i] = new WaitableEvent(false, false);
threads[i]->Start();
- threads[i]->task_runner()->PostTask(
- FROM_HERE, base::Bind(&TraceManyInstantEvents, i, num_events,
- task_complete_events[i]));
+ threads[i]->message_loop()->PostTask(
+ FROM_HERE, base::Bind(&TraceManyInstantEvents,
+ i, num_events, task_complete_events[i]));
}
for (int i = 0; i < num_threads; i++) {
@@ -1494,9 +1493,9 @@ TEST_F(TraceEventTestFixture, ThreadNames) {
task_complete_events[i] = new WaitableEvent(false, false);
threads[i]->Start();
thread_ids[i] = threads[i]->thread_id();
- threads[i]->task_runner()->PostTask(
- FROM_HERE, base::Bind(&TraceManyInstantEvents, i, kNumEvents,
- task_complete_events[i]));
+ threads[i]->message_loop()->PostTask(
+ FROM_HERE, base::Bind(&TraceManyInstantEvents,
+ i, kNumEvents, task_complete_events[i]));
}
for (int i = 0; i < kNumThreads; i++) {
task_complete_events[i]->Wait();
@@ -2726,17 +2725,17 @@ TEST_F(TraceEventTestFixture, SetCurrentThreadBlocksMessageLoopBeforeTracing) {
Thread thread("1");
WaitableEvent task_complete_event(false, false);
thread.Start();
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, Bind(&TraceLog::SetCurrentThreadBlocksMessageLoop,
Unretained(TraceLog::GetInstance())));
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, Bind(&TraceWithAllMacroVariants, &task_complete_event));
task_complete_event.Wait();
WaitableEvent task_start_event(false, false);
WaitableEvent task_stop_event(false, false);
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, Bind(&BlockUntilStopped, &task_start_event, &task_stop_event));
task_start_event.Wait();
@@ -2797,15 +2796,15 @@ TEST_F(TraceEventTestFixture, SetCurrentThreadBlocksMessageLoopAfterTracing) {
WaitableEvent task_complete_event(false, false);
thread.Start();
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, Bind(&TraceWithAllMacroVariants, &task_complete_event));
task_complete_event.Wait();
WaitableEvent task_start_event(false, false);
WaitableEvent task_stop_event(false, false);
- thread.task_runner()->PostTask(
- FROM_HERE, Bind(&SetBlockingFlagAndBlockUntilStopped, &task_start_event,
- &task_stop_event));
+ thread.message_loop()->PostTask(
+ FROM_HERE, Bind(&SetBlockingFlagAndBlockUntilStopped,
+ &task_start_event, &task_stop_event));
task_start_event.Wait();
EndTraceAndFlush();
@@ -2822,14 +2821,14 @@ TEST_F(TraceEventTestFixture, ThreadOnceBlocking) {
WaitableEvent task_complete_event(false, false);
thread.Start();
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, Bind(&TraceWithAllMacroVariants, &task_complete_event));
task_complete_event.Wait();
task_complete_event.Reset();
WaitableEvent task_start_event(false, false);
WaitableEvent task_stop_event(false, false);
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, Bind(&BlockUntilStopped, &task_start_event, &task_stop_event));
task_start_event.Wait();
@@ -2844,7 +2843,7 @@ TEST_F(TraceEventTestFixture, ThreadOnceBlocking) {
// executed in the thread before continuing.
task_start_event.Reset();
task_stop_event.Reset();
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, Bind(&BlockUntilStopped, &task_start_event, &task_stop_event));
task_start_event.Wait();
task_stop_event.Signal();
@@ -2853,7 +2852,7 @@ TEST_F(TraceEventTestFixture, ThreadOnceBlocking) {
// TraceLog should discover the generation mismatch and recover the thread
// local buffer for the thread without any error.
BeginTrace();
- thread.task_runner()->PostTask(
+ thread.message_loop()->PostTask(
FROM_HERE, Bind(&TraceWithAllMacroVariants, &task_complete_event));
task_complete_event.Wait();
task_complete_event.Reset();
diff --git a/base/win/object_watcher.cc b/base/win/object_watcher.cc
index 5ebe185..35609fc 100644
--- a/base/win/object_watcher.cc
+++ b/base/win/object_watcher.cc
@@ -92,7 +92,7 @@ void CALLBACK ObjectWatcher::DoneWaiting(void* param, BOOLEAN timed_out) {
// The destructor blocks on any callbacks that are in flight, so we know that
// that is always a pointer to a valid ObjectWater.
ObjectWatcher* that = static_cast<ObjectWatcher*>(param);
- that->origin_loop_->task_runner()->PostTask(FROM_HERE, that->callback_);
+ that->origin_loop_->PostTask(FROM_HERE, that->callback_);
that->callback_.Reset();
}