summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
authorskyostil <skyostil@chromium.org>2015-04-30 12:06:15 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-30 19:07:34 +0000
commit054861d0934c663de3cea933e1d65fd8319856a6 (patch)
tree2a6a6a435179172b93bb3ed8adc5341ecfeab564 /base/threading
parent98bfd203088a09d06965e6fd6004471c1da13aa7 (diff)
downloadchromium_src-054861d0934c663de3cea933e1d65fd8319856a6.zip
chromium_src-054861d0934c663de3cea933e1d65fd8319856a6.tar.gz
chromium_src-054861d0934c663de3cea933e1d65fd8319856a6.tar.bz2
base: Remove most uses of MessageLoopProxy
Replace most 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 Review URL: https://codereview.chromium.org/1100773004 Cr-Commit-Position: refs/heads/master@{#327755}
Diffstat (limited to 'base/threading')
-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_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
8 files changed, 38 insertions, 43 deletions
diff --git a/base/threading/post_task_and_reply_impl.cc b/base/threading/post_task_and_reply_impl.cc
index a82a4fd..f3e88ab 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_loop_(ThreadTaskRunnerHandle::Get()) {
+ origin_task_runner_(ThreadTaskRunnerHandle::Get()) {
task_ = task;
reply_ = reply;
}
~PostTaskAndReplyRelay() {
- DCHECK(origin_loop_->BelongsToCurrentThread());
+ DCHECK(origin_task_runner_->BelongsToCurrentThread());
task_.Reset();
reply_.Reset();
}
void Run() {
task_.Run();
- origin_loop_->PostTask(
- from_here_,
- Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct,
- base::Unretained(this)));
+ origin_task_runner_->PostTask(
+ from_here_, Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct,
+ base::Unretained(this)));
}
private:
void RunReplyAndSelfDestruct() {
- DCHECK(origin_loop_->BelongsToCurrentThread());
+ DCHECK(origin_task_runner_->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_loop_;
+ scoped_refptr<SingleThreadTaskRunner> origin_task_runner_;
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 076a46d..a5b9580 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
-// MessageLoopProxy::PostTaskAndReply and WorkerPool::PostTaskAndReply.
+// TaskRunner::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::MessageLoopProxy, or you
+// PostTaskAndReply, you probably want base::SingleThreadTaskRunner, or you
// may want base::WorkerPool.
class PostTaskAndReplyImpl {
public:
- // Implementation for MessageLoopProxy::PostTaskAndReply and
+ // Implementation for TaskRunner::PostTaskAndReply and
// WorkerPool::PostTaskAndReply.
bool PostTaskAndReply(const tracked_objects::Location& from_here,
const Closure& task,
diff --git a/base/threading/sequenced_worker_pool_unittest.cc b/base/threading/sequenced_worker_pool_unittest.cc
index c12156e..05989a5 100644
--- a/base/threading/sequenced_worker_pool_unittest.cc
+++ b/base/threading/sequenced_worker_pool_unittest.cc
@@ -11,7 +11,6 @@
#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 d42ba4d..bab3991 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -6,6 +6,7 @@
#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"
@@ -162,7 +163,7 @@ void Thread::StopSoon() {
return;
stopping_ = true;
- message_loop_->PostTask(FROM_HERE, base::Bind(&ThreadQuitHelper));
+ task_runner()->PostTask(FROM_HERE, base::Bind(&ThreadQuitHelper));
}
bool Thread::IsRunning() const {
diff --git a/base/threading/thread.h b/base/threading/thread.h
index 5010f0e..4915606 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_proxy();
+ return message_loop_->task_runner();
}
// 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 a08cc5b..3bc9fb4 100644
--- a/base/threading/thread_perftest.cc
+++ b/base/threading/thread_perftest.cc
@@ -5,7 +5,9 @@
#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"
@@ -54,12 +56,9 @@ class ThreadPerfTest : public testing::Test {
base::TimeTicks ThreadNow(base::Thread* thread) {
base::WaitableEvent done(false, false);
base::TimeTicks ticks;
- thread->message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(&ThreadPerfTest::TimeOnThread,
- base::Unretained(this),
- &ticks,
- &done));
+ thread->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&ThreadPerfTest::TimeOnThread,
+ base::Unretained(this), &ticks, &done));
done.Wait();
return ticks;
}
@@ -128,10 +127,9 @@ class TaskPerfTest : public ThreadPerfTest {
FinishMeasurement();
return;
}
- NextThread(hops)->message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(
- &ThreadPerfTest::PingPong, base::Unretained(this), hops - 1));
+ NextThread(hops)->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&ThreadPerfTest::PingPong, base::Unretained(this),
+ hops - 1));
}
};
@@ -198,11 +196,9 @@ class EventPerfTest : public ThreadPerfTest {
void PingPong(int hops) override {
remaining_hops_ = hops;
for (size_t i = 0; i < threads_.size(); i++) {
- threads_[i]->message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(&EventPerfTest::WaitAndSignalOnThread,
- base::Unretained(this),
- i));
+ threads_[i]->task_runner()->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 f4d024f..a89768e 100644
--- a/base/threading/thread_unittest.cc
+++ b/base/threading/thread_unittest.cc
@@ -7,7 +7,8 @@
#include <vector>
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
+#include "base/location.h"
+#include "base/single_thread_task_runner.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -144,7 +145,7 @@ TEST_F(ThreadTest, StartWithOptions_StackSize) {
EXPECT_TRUE(a.IsRunning());
bool was_invoked = false;
- a.message_loop()->PostTask(FROM_HERE, base::Bind(&ToggleValue, &was_invoked));
+ a.task_runner()->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
@@ -165,14 +166,12 @@ 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.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));
+ 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));
}
EXPECT_TRUE(was_invoked);
}
@@ -221,7 +220,7 @@ TEST_F(ThreadTest, CleanUp) {
// Register an observer that writes into |captured_events| once the
// thread's message loop is destroyed.
- t.message_loop()->PostTask(
+ t.task_runner()->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 333b495..a52a414 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 MessageLoopProxy::PostTaskAndReply, except the destination
+ // Just like TaskRunner::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,