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

Side by Side Diff: base/message_loop/message_loop_task_runner_unittest.cc

Issue 1255673004: Proof-reading comments in base/message_loop/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: imcoming -> incoming Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « base/message_loop/message_loop.cc ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/debug/leak_annotations.h" 9 #include "base/debug/leak_annotations.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 12 matching lines...) Expand all
23 MessageLoopTaskRunnerTest() 23 MessageLoopTaskRunnerTest()
24 : current_loop_(new MessageLoop()), 24 : current_loop_(new MessageLoop()),
25 task_thread_("task_thread"), 25 task_thread_("task_thread"),
26 thread_sync_(true, false) {} 26 thread_sync_(true, false) {}
27 27
28 void DeleteCurrentMessageLoop() { current_loop_.reset(); } 28 void DeleteCurrentMessageLoop() { current_loop_.reset(); }
29 29
30 protected: 30 protected:
31 void SetUp() override { 31 void SetUp() override {
32 // Use SetUp() instead of the constructor to avoid posting a task to a 32 // Use SetUp() instead of the constructor to avoid posting a task to a
33 // partialy constructed object. 33 // partially constructed object.
34 task_thread_.Start(); 34 task_thread_.Start();
35 35
36 // Allow us to pause the |task_thread_|'s MessageLoop. 36 // Allow us to pause the |task_thread_|'s MessageLoop.
37 task_thread_.message_loop()->PostTask( 37 task_thread_.message_loop()->PostTask(
38 FROM_HERE, Bind(&MessageLoopTaskRunnerTest::BlockTaskThreadHelper, 38 FROM_HERE, Bind(&MessageLoopTaskRunnerTest::BlockTaskThreadHelper,
39 Unretained(this))); 39 Unretained(this)));
40 } 40 }
41 41
42 void TearDown() override { 42 void TearDown() override {
43 // Make sure the |task_thread_| is not blocked, and stop the thread 43 // Make sure the |task_thread_| is not blocked, and stop the thread
44 // fully before destuction because its tasks may still depend on the 44 // fully before destruction because its tasks may still depend on the
45 // |thread_sync_| event. 45 // |thread_sync_| event.
46 thread_sync_.Signal(); 46 thread_sync_.Signal();
47 task_thread_.Stop(); 47 task_thread_.Stop();
48 DeleteCurrentMessageLoop(); 48 DeleteCurrentMessageLoop();
49 } 49 }
50 50
51 // Make LoopRecorder threadsafe so that there is defined behavior even if a 51 // Make LoopRecorder threadsafe so that there is defined behavior even if a
52 // threading mistake sneaks into the PostTaskAndReplyRelay implementation. 52 // threading mistake sneaks into the PostTaskAndReplyRelay implementation.
53 class LoopRecorder : public RefCountedThreadSafe<LoopRecorder> { 53 class LoopRecorder : public RefCountedThreadSafe<LoopRecorder> {
54 public: 54 public:
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 EXPECT_EQ(task_loop, task_run_on); 237 EXPECT_EQ(task_loop, task_run_on);
238 ASSERT_FALSE(task_deleted_on); 238 ASSERT_FALSE(task_deleted_on);
239 EXPECT_FALSE(reply_run_on); 239 EXPECT_FALSE(reply_run_on);
240 ASSERT_FALSE(reply_deleted_on); 240 ASSERT_FALSE(reply_deleted_on);
241 EXPECT_EQ(task_delete_order, reply_delete_order); 241 EXPECT_EQ(task_delete_order, reply_delete_order);
242 242
243 // The PostTaskAndReplyRelay is leaked here. Even if we had a reference to 243 // The PostTaskAndReplyRelay is leaked here. Even if we had a reference to
244 // it, we cannot just delete it because PostTaskAndReplyRelay's destructor 244 // it, we cannot just delete it because PostTaskAndReplyRelay's destructor
245 // checks that MessageLoop::current() is the the same as when the 245 // checks that MessageLoop::current() is the the same as when the
246 // PostTaskAndReplyRelay object was constructed. However, this loop must have 246 // PostTaskAndReplyRelay object was constructed. However, this loop must have
247 // aleady been deleted in order to perform this test. See 247 // already been deleted in order to perform this test. See
248 // http://crbug.com/86301. 248 // http://crbug.com/86301.
249 } 249 }
250 250
251 class MessageLoopTaskRunnerThreadingTest : public testing::Test { 251 class MessageLoopTaskRunnerThreadingTest : public testing::Test {
252 public: 252 public:
253 void Release() const { 253 void Release() const {
254 AssertOnIOThread(); 254 AssertOnIOThread();
255 Quit(); 255 Quit();
256 } 256 }
257 257
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 new Thread("MessageLoopTaskRunnerThreadingTest_Dummy")); 349 new Thread("MessageLoopTaskRunnerThreadingTest_Dummy"));
350 test_thread->Start(); 350 test_thread->Start();
351 task_runner = test_thread->task_runner(); 351 task_runner = test_thread->task_runner();
352 } 352 }
353 bool ret = task_runner->PostTask( 353 bool ret = task_runner->PostTask(
354 FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun)); 354 FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun));
355 EXPECT_FALSE(ret); 355 EXPECT_FALSE(ret);
356 } 356 }
357 357
358 } // namespace base 358 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.cc ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698