OLD | NEW |
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 #ifndef MOJO_EDK_SYSTEM_TEST_TEST_IO_THREAD_H_ | 5 #ifndef MOJO_EDK_SYSTEM_TEST_TEST_IO_THREAD_H_ |
6 #define MOJO_EDK_SYSTEM_TEST_TEST_IO_THREAD_H_ | 6 #define MOJO_EDK_SYSTEM_TEST_TEST_IO_THREAD_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "mojo/edk/embedder/platform_task_runner.h" | 10 #include "mojo/edk/embedder/platform_task_runner.h" |
11 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace system { | 14 namespace system { |
15 namespace test { | 15 namespace test { |
16 | 16 |
17 // Class to help create/run threads with I/O |MessageLoop|s in tests. | 17 // Class to help create/run threads with I/O |MessageLoop|s in tests. |
18 class TestIOThread { | 18 class TestIOThread final { |
19 public: | 19 public: |
20 enum class StartMode { AUTO, MANUAL }; | 20 enum class StartMode { AUTO, MANUAL }; |
21 explicit TestIOThread(StartMode start_mode); | 21 explicit TestIOThread(StartMode start_mode); |
22 // Stops the I/O thread if necessary. | 22 // Stops the I/O thread if necessary. |
23 ~TestIOThread(); | 23 ~TestIOThread(); |
24 | 24 |
25 // |Start()|/|Stop()| should only be called from the main (creation) thread. | 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. | 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. | 27 // |Stop()| may be called even when the I/O thread is not started. |
28 void Start(); | 28 void Start(); |
(...skipping 19 matching lines...) Expand all Loading... |
48 bool io_thread_started_; | 48 bool io_thread_started_; |
49 | 49 |
50 MOJO_DISALLOW_COPY_AND_ASSIGN(TestIOThread); | 50 MOJO_DISALLOW_COPY_AND_ASSIGN(TestIOThread); |
51 }; | 51 }; |
52 | 52 |
53 } // namespace test | 53 } // namespace test |
54 } // namespace system | 54 } // namespace system |
55 } // namespace mojo | 55 } // namespace mojo |
56 | 56 |
57 #endif // MOJO_EDK_SYSTEM_TEST_TEST_IO_THREAD_H_ | 57 #endif // MOJO_EDK_SYSTEM_TEST_TEST_IO_THREAD_H_ |
OLD | NEW |