OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TEST_SCOPED_IPC_SUPPORT_H_ | 5 #ifndef MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
6 #define MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ | 6 #define MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
12 #include "mojo/edk/embedder/process_delegate.h" | 12 #include "mojo/edk/embedder/process_delegate.h" |
13 #include "mojo/edk/embedder/scoped_platform_handle.h" | 13 #include "mojo/edk/embedder/scoped_platform_handle.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 namespace edk { | 16 namespace edk { |
17 namespace test { | 17 namespace test { |
18 | 18 |
19 base::TaskRunner* GetIoTaskRunner(); | 19 base::TaskRunner* GetIoTaskRunner(); |
20 | 20 |
21 namespace internal { | |
22 | |
23 class ScopedIPCSupportHelper { | |
24 public: | |
25 ScopedIPCSupportHelper(); | |
26 ~ScopedIPCSupportHelper(); | |
27 | |
28 void Init(ProcessDelegate* process_delegate, | |
29 scoped_refptr<base::TaskRunner> io_thread_task_runner); | |
30 | |
31 void OnShutdownCompleteImpl(); | |
32 | |
33 private: | |
34 scoped_refptr<base::TaskRunner> io_thread_task_runner_; | |
35 | |
36 base::RunLoop run_loop_; | |
37 | |
38 DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupportHelper); | |
39 }; | |
40 | |
41 } // namespace internal | |
42 | |
43 // A simple class that calls |InitIPCSupport()| on construction and | 21 // A simple class that calls |InitIPCSupport()| on construction and |
44 // |ShutdownIPCSupport()| on destruction. | 22 // |ShutdownIPCSupport()| on destruction. |
45 class ScopedIPCSupport : public ProcessDelegate { | 23 class ScopedIPCSupport : public ProcessDelegate { |
46 public: | 24 public: |
47 explicit ScopedIPCSupport( | 25 explicit ScopedIPCSupport( |
48 scoped_refptr<base::TaskRunner> io_thread_task_runner); | 26 scoped_refptr<base::TaskRunner> io_thread_task_runner); |
49 ~ScopedIPCSupport() override; | 27 ~ScopedIPCSupport() override; |
50 | 28 |
51 private: | 29 private: |
52 // |ProcessDelegate| implementation: | 30 // |ProcessDelegate| implementation: |
53 // Note: Executed on the I/O thread. | 31 // Note: Executed on the I/O thread. |
54 void OnShutdownComplete() override; | 32 void OnShutdownComplete() override; |
55 | 33 |
56 internal::ScopedIPCSupportHelper helper_; | 34 base::Closure quit_closure; |
57 | 35 |
58 DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport); | 36 DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport); |
59 }; | 37 }; |
60 | 38 |
61 } // namespace test | 39 } // namespace test |
62 } // namespace edk | 40 } // namespace edk |
63 } // namespace mojo | 41 } // namespace mojo |
64 | 42 |
65 #endif // MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ | 43 #endif // MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
OLD | NEW |