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

Side by Side Diff: base/test/test_io_thread.h

Issue 488003003: Add ChannelProxy benchmark to ipc_perftests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolved conflicts 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
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
viettrungluu 2014/08/27 16:52:12 nit: Also, no "(c)".
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_TEST_TEST_IO_THREAD_H_
6 #define BASE_TEST_TEST_IO_THREAD_H_
7
8 #include "base/callback_forward.h"
9 #include "base/compiler_specific.h"
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/task_runner.h"
13 #include "base/threading/thread.h"
14 #include "base/time/time.h"
15
16 namespace base {
17
18 class TestIOThread {
viettrungluu 2014/08/27 16:47:18 Could use a class-level comment.
Hajime Morrita 2014/08/27 17:47:43 Done.
19 public:
20 enum Mode { kAutoStart, kManualStart };
21 explicit TestIOThread(Mode mode);
22 // Stops the I/O thread if necessary.
23 ~TestIOThread();
24
25 // |Start()|/|Stop()| should only be called from the main (creation) thread.
26 // After |Stop()|, |Start()| may be called again to start a new I/O thread.
27 // |Stop()| may be called even when the I/O thread is not started.
28 void Start();
29 void Stop();
30
31 void PostTask(const tracked_objects::Location& from_here,
viettrungluu 2014/08/27 16:47:18 Probably these should have comments, especially |P
Hajime Morrita 2014/08/27 17:47:43 Done.
32 const base::Closure& task);
33 void PostTaskAndWait(const tracked_objects::Location& from_here,
34 const base::Closure& task);
35
36 base::MessageLoopForIO* message_loop() {
37 return static_cast<base::MessageLoopForIO*>(io_thread_.message_loop());
38 }
39
40 scoped_refptr<SingleThreadTaskRunner> task_runner() {
41 return message_loop()->task_runner();
42 }
43
44 private:
45 base::Thread io_thread_;
46 bool io_thread_started_;
47
48 DISALLOW_COPY_AND_ASSIGN(TestIOThread);
49 };
50
51 } // namespace base
52
53 #endif // BASE_TEST_TEST_IO_THREAD_H_
OLDNEW
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/test_io_thread.cc » ('j') | base/test/test_io_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698