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

Side by Side Diff: mojo/system/test_utils.cc

Issue 281893002: Mojo: Base our epsilon timeouts off of TestTimeouts::tiny_timeout(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « mojo/system/test_utils.h ('k') | mojo/system/waiter_list_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/system/test_utils.h" 5 #include "mojo/system/test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/test/test_timeouts.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 namespace system { 13 namespace system {
13 namespace test { 14 namespace test {
14 15
15 namespace { 16 namespace {
16 17
17 void PostTaskAndWaitHelper(base::WaitableEvent* event, 18 void PostTaskAndWaitHelper(base::WaitableEvent* event,
18 const base::Closure& task) { 19 const base::Closure& task) {
19 task.Run(); 20 task.Run();
20 event->Signal(); 21 event->Signal();
21 } 22 }
22 23
23 } // namespace 24 } // namespace
24 25
25 void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner, 26 void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner,
26 const tracked_objects::Location& from_here, 27 const tracked_objects::Location& from_here,
27 const base::Closure& task) { 28 const base::Closure& task) {
28 base::WaitableEvent event(false, false); 29 base::WaitableEvent event(false, false);
29 task_runner->PostTask(from_here, 30 task_runner->PostTask(from_here,
30 base::Bind(&PostTaskAndWaitHelper, &event, task)); 31 base::Bind(&PostTaskAndWaitHelper, &event, task));
31 event.Wait(); 32 event.Wait();
32 } 33 }
33 34
35 base::TimeDelta EpsilonTimeout() {
36 // Originally, our epsilon timeout was 10 ms, which was mostly fine but flaky
37 // on some Windows bots. So I bumped it up to 30 ms, which made things
38 // reliable. Currently, |tiny_timeout()| is 100 ms, which means that this will
39 // be 25 ms, which will hopefully be okay.
40 return TestTimeouts::tiny_timeout() / 4;
41 }
42
34 // TestIOThread ---------------------------------------------------------------- 43 // TestIOThread ----------------------------------------------------------------
35 44
36 TestIOThread::TestIOThread(Mode mode) 45 TestIOThread::TestIOThread(Mode mode)
37 : io_thread_("test_io_thread"), 46 : io_thread_("test_io_thread"),
38 io_thread_started_(false) { 47 io_thread_started_(false) {
39 switch (mode) { 48 switch (mode) {
40 case kAutoStart: 49 case kAutoStart:
41 Start(); 50 Start();
42 return; 51 return;
43 case kManualStart: 52 case kManualStart:
(...skipping 25 matching lines...) Expand all
69 } 78 }
70 79
71 void TestIOThread::PostTaskAndWait(const tracked_objects::Location& from_here, 80 void TestIOThread::PostTaskAndWait(const tracked_objects::Location& from_here,
72 const base::Closure& task) { 81 const base::Closure& task) {
73 ::mojo::system::test::PostTaskAndWait(task_runner(), from_here, task); 82 ::mojo::system::test::PostTaskAndWait(task_runner(), from_here, task);
74 } 83 }
75 84
76 } // namespace test 85 } // namespace test
77 } // namespace system 86 } // namespace system
78 } // namespace mojo 87 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/test_utils.h ('k') | mojo/system/waiter_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698