OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/message_loop/message_loop_task_runner.h" | 5 #include "base/message_loop/message_loop_task_runner.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 void DeleteCurrentMessageLoop() { current_loop_.reset(); } | 31 void DeleteCurrentMessageLoop() { current_loop_.reset(); } |
32 | 32 |
33 protected: | 33 protected: |
34 void SetUp() override { | 34 void SetUp() override { |
35 // Use SetUp() instead of the constructor to avoid posting a task to a | 35 // Use SetUp() instead of the constructor to avoid posting a task to a |
36 // partially constructed object. | 36 // partially constructed object. |
37 task_thread_.Start(); | 37 task_thread_.Start(); |
38 | 38 |
39 // Allow us to pause the |task_thread_|'s MessageLoop. | 39 // Allow us to pause the |task_thread_|'s MessageLoop. |
40 task_thread_.message_loop()->task_runner()->PostTask( | 40 task_thread_.task_runner()->PostTask( |
41 FROM_HERE, Bind(&MessageLoopTaskRunnerTest::BlockTaskThreadHelper, | 41 FROM_HERE, Bind(&MessageLoopTaskRunnerTest::BlockTaskThreadHelper, |
42 Unretained(this))); | 42 Unretained(this))); |
43 } | 43 } |
44 | 44 |
45 void TearDown() override { | 45 void TearDown() override { |
46 // Make sure the |task_thread_| is not blocked, and stop the thread | 46 // Make sure the |task_thread_| is not blocked, and stop the thread |
47 // fully before destruction because its tasks may still depend on the | 47 // fully before destruction because its tasks may still depend on the |
48 // |thread_sync_| event. | 48 // |thread_sync_| event. |
49 thread_sync_.Signal(); | 49 thread_sync_.Signal(); |
50 task_thread_.Stop(); | 50 task_thread_.Stop(); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 new Thread("MessageLoopTaskRunnerThreadingTest_Dummy")); | 353 new Thread("MessageLoopTaskRunnerThreadingTest_Dummy")); |
354 test_thread->Start(); | 354 test_thread->Start(); |
355 task_runner = test_thread->task_runner(); | 355 task_runner = test_thread->task_runner(); |
356 } | 356 } |
357 bool ret = task_runner->PostTask( | 357 bool ret = task_runner->PostTask( |
358 FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun)); | 358 FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun)); |
359 EXPECT_FALSE(ret); | 359 EXPECT_FALSE(ret); |
360 } | 360 } |
361 | 361 |
362 } // namespace base | 362 } // namespace base |
OLD | NEW |