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

Unified Diff: base/message_loop/message_loop_task_runner_unittest.cc

Issue 2657603004: Clear PostTaskAndReply task on the destination thread (3) (Closed)
Patch Set: reorder delete_flag check. +comment Created 3 years, 9 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
« no previous file with comments | « no previous file | base/threading/post_task_and_reply_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_loop_task_runner_unittest.cc
diff --git a/base/message_loop/message_loop_task_runner_unittest.cc b/base/message_loop/message_loop_task_runner_unittest.cc
index 54551daadd21da085ee3577886c187f7aacbc1bd..d403c707002792ff4150c937259a362f979e70e4 100644
--- a/base/message_loop/message_loop_task_runner_unittest.cc
+++ b/base/message_loop/message_loop_task_runner_unittest.cc
@@ -127,7 +127,7 @@ TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReply_Basic) {
RunLoop().Run();
EXPECT_EQ(task_thread_.message_loop(), task_run_on);
- EXPECT_EQ(current_loop_.get(), task_deleted_on);
+ EXPECT_EQ(task_thread_.message_loop(), task_deleted_on);
EXPECT_EQ(current_loop_.get(), reply_run_on);
EXPECT_EQ(current_loop_.get(), reply_deleted_on);
EXPECT_LT(task_delete_order, reply_delete_order);
@@ -200,7 +200,8 @@ TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReply_SameLoop) {
EXPECT_LT(task_delete_order, reply_delete_order);
}
-TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReply_DeadReplyLoopDoesNotDelete) {
+TEST_F(MessageLoopTaskRunnerTest,
+ PostTaskAndReply_DeadReplyTaskRunnerBehavior) {
// Annotate the scope as having memory leaks to suppress heapchecker reports.
ANNOTATE_SCOPED_MEMORY_LEAK;
MessageLoop* task_run_on = NULL;
@@ -237,11 +238,13 @@ TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReply_DeadReplyLoopDoesNotDelete) {
MessageLoop* task_loop = task_thread_.message_loop();
task_thread_.Stop();
+ // Even if the reply task runner is already gone, the original task should
+ // already be deleted. However, the reply which hasn't executed yet should
+ // leak to avoid thread-safety issues.
EXPECT_EQ(task_loop, task_run_on);
- ASSERT_FALSE(task_deleted_on);
+ EXPECT_EQ(task_loop, task_deleted_on);
EXPECT_FALSE(reply_run_on);
ASSERT_FALSE(reply_deleted_on);
- EXPECT_EQ(task_delete_order, reply_delete_order);
// The PostTaskAndReplyRelay is leaked here. Even if we had a reference to
// it, we cannot just delete it because PostTaskAndReplyRelay's destructor
« no previous file with comments | « no previous file | base/threading/post_task_and_reply_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698