Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: base/task/cancelable_task_tracker_unittest.cc

Issue 1100773004: base: Remove most uses of MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/task/cancelable_task_tracker_unittest.cc
diff --git a/base/task/cancelable_task_tracker_unittest.cc b/base/task/cancelable_task_tracker_unittest.cc
index 8b2b86a6a52ed7e717261d49ef69a331ec93ffb7..ff9e40b855eaebce8d77f362ed827757f151cb5f 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,15 +84,13 @@ TEST_F(CancelableTaskTrackerTest, NoCancel) {
Thread worker_thread("worker thread");
ASSERT_TRUE(worker_thread.Start());
- ignore_result(task_tracker_.PostTask(worker_thread.message_loop_proxy().get(),
+ ignore_result(task_tracker_.PostTask(worker_thread.task_runner().get(),
FROM_HERE,
MakeExpectedRunClosure(FROM_HERE)));
- ignore_result(
- task_tracker_.PostTaskAndReply(worker_thread.message_loop_proxy().get(),
- FROM_HERE,
- MakeExpectedRunClosure(FROM_HERE),
- MakeExpectedRunClosure(FROM_HERE)));
+ ignore_result(task_tracker_.PostTaskAndReply(
+ worker_thread.task_runner().get(), FROM_HERE,
+ MakeExpectedRunClosure(FROM_HERE), MakeExpectedRunClosure(FROM_HERE)));
CancelableTaskTracker::IsCanceledCallback is_canceled;
ignore_result(task_tracker_.NewTrackedTaskId(&is_canceled));
@@ -166,11 +164,9 @@ TEST_F(CancelableTaskTrackerTest, CancelReplyDifferentThread) {
Thread worker_thread("worker thread");
ASSERT_TRUE(worker_thread.Start());
- CancelableTaskTracker::TaskId task_id =
- task_tracker_.PostTaskAndReply(worker_thread.message_loop_proxy().get(),
- FROM_HERE,
- Bind(&DoNothing),
- MakeExpectedNotRunClosure(FROM_HERE));
+ CancelableTaskTracker::TaskId task_id = task_tracker_.PostTaskAndReply(
+ worker_thread.task_runner().get(), FROM_HERE, Bind(&DoNothing),
+ MakeExpectedNotRunClosure(FROM_HERE));
EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_id);
task_tracker_.TryCancel(task_id);
@@ -196,14 +192,14 @@ TEST_F(CancelableTaskTrackerTest, NewTrackedTaskIdDifferentThread) {
Thread other_thread("other thread");
ASSERT_TRUE(other_thread.Start());
- other_thread.message_loop_proxy()->PostTask(
+ other_thread.task_runner()->PostTask(
FROM_HERE, Bind(&ExpectIsCanceled, is_canceled, false));
other_thread.Stop();
task_tracker_.TryCancel(task_id);
ASSERT_TRUE(other_thread.Start());
- other_thread.message_loop_proxy()->PostTask(
+ other_thread.task_runner()->PostTask(
FROM_HERE, Bind(&ExpectIsCanceled, is_canceled, true));
other_thread.Stop();
}
@@ -378,11 +374,9 @@ TEST_F(CancelableTaskTrackerDeathTest, PostFromDifferentThread) {
Thread bad_thread("bad thread");
ASSERT_TRUE(bad_thread.Start());
- bad_thread.message_loop_proxy()->PostTask(
- FROM_HERE,
- Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
- Unretained(&task_tracker_),
- Bind(&PostDoNothingTask)));
+ bad_thread.task_runner()->PostTask(
+ FROM_HERE, Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
+ Unretained(&task_tracker_), Bind(&PostDoNothingTask)));
}
void TryCancel(CancelableTaskTracker::TaskId task_id,
@@ -401,11 +395,9 @@ TEST_F(CancelableTaskTrackerDeathTest, CancelOnDifferentThread) {
test_task_runner.get(), FROM_HERE, Bind(&DoNothing));
EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_id);
- bad_thread.message_loop_proxy()->PostTask(
- FROM_HERE,
- Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
- Unretained(&task_tracker_),
- Bind(&TryCancel, task_id)));
+ bad_thread.task_runner()->PostTask(
+ FROM_HERE, Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
+ Unretained(&task_tracker_), Bind(&TryCancel, task_id)));
test_task_runner->RunUntilIdle();
}
@@ -421,10 +413,9 @@ TEST_F(CancelableTaskTrackerDeathTest, CancelAllOnDifferentThread) {
test_task_runner.get(), FROM_HERE, Bind(&DoNothing));
EXPECT_NE(CancelableTaskTracker::kBadTaskId, task_id);
- bad_thread.message_loop_proxy()->PostTask(
+ bad_thread.task_runner()->PostTask(
FROM_HERE,
- Bind(&MaybeRunDeadlyTaskTrackerMemberFunction,
- Unretained(&task_tracker_),
+ Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, Unretained(&task_tracker_),
Bind(&CancelableTaskTracker::TryCancelAll)));
test_task_runner->RunUntilIdle();

Powered by Google App Engine
This is Rietveld 408576698