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

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

Issue 488003003: Add ChannelProxy benchmark to ipc_perftests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing. Created 6 years, 3 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 | « mojo/system/test_utils.h ('k') | no next file » | 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 #include "base/test/test_timeouts.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Currently, |tiny_timeout()| is usually 100 ms (possibly scaled under ASAN, 42 // Currently, |tiny_timeout()| is usually 100 ms (possibly scaled under ASAN,
43 // etc.). Based on this, set it to (usually be) 30 ms on Windows and 20 ms 43 // etc.). Based on this, set it to (usually be) 30 ms on Windows and 20 ms
44 // elsewhere. 44 // elsewhere.
45 #if defined(OS_WIN) 45 #if defined(OS_WIN)
46 return (TestTimeouts::tiny_timeout() * 3) / 10; 46 return (TestTimeouts::tiny_timeout() * 3) / 10;
47 #else 47 #else
48 return (TestTimeouts::tiny_timeout() * 2) / 10; 48 return (TestTimeouts::tiny_timeout() * 2) / 10;
49 #endif 49 #endif
50 } 50 }
51 51
52 // TestIOThread ----------------------------------------------------------------
53
54 TestIOThread::TestIOThread(Mode mode)
55 : io_thread_("test_io_thread"), io_thread_started_(false) {
56 switch (mode) {
57 case kAutoStart:
58 Start();
59 return;
60 case kManualStart:
61 return;
62 }
63 CHECK(false) << "Invalid mode";
64 }
65
66 TestIOThread::~TestIOThread() {
67 Stop();
68 }
69
70 void TestIOThread::Start() {
71 CHECK(!io_thread_started_);
72 io_thread_started_ = true;
73 CHECK(io_thread_.StartWithOptions(
74 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)));
75 }
76
77 void TestIOThread::Stop() {
78 // Note: It's okay to call |Stop()| even if the thread isn't running.
79 io_thread_.Stop();
80 io_thread_started_ = false;
81 }
82
83 void TestIOThread::PostTask(const tracked_objects::Location& from_here,
84 const base::Closure& task) {
85 task_runner()->PostTask(from_here, task);
86 }
87
88 void TestIOThread::PostTaskAndWait(const tracked_objects::Location& from_here,
89 const base::Closure& task) {
90 ::mojo::system::test::PostTaskAndWait(task_runner(), from_here, task);
91 }
92
93 } // namespace test 52 } // namespace test
94 } // namespace system 53 } // namespace system
95 } // namespace mojo 54 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698