OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 IPC_IPC_TEST_BASE_H_ | 5 #ifndef IPC_IPC_TEST_BASE_H_ |
6 #define IPC_IPC_TEST_BASE_H_ | 6 #define IPC_IPC_TEST_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 // (manually) destroy the channel proxy before the task runner's thread is | 69 // (manually) destroy the channel proxy before the task runner's thread is |
70 // destroyed. | 70 // destroyed. |
71 void CreateChannelProxy( | 71 void CreateChannelProxy( |
72 IPC::Listener* listener, | 72 IPC::Listener* listener, |
73 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); | 73 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); |
74 void DestroyChannelProxy(); | 74 void DestroyChannelProxy(); |
75 | 75 |
76 // Starts the client process, returning true if successful; this should be | 76 // Starts the client process, returning true if successful; this should be |
77 // done after connecting to the channel. | 77 // done after connecting to the channel. |
78 bool StartClient(); | 78 bool StartClient(); |
79 // A StartClient() variant that allows caller to pass the FD of IPC pipe | |
80 bool StartClient(int ipcfd); | |
viettrungluu
2014/09/15 20:19:43
a) Our style guide generally forbids overloads. (P
Hajime Morrita
2014/09/15 22:01:36
Right. Rearrange a bit to expose it to OS_POSIX pl
| |
79 | 81 |
80 // Waits for the client to shut down, returning true if successful. Note that | 82 // Waits for the client to shut down, returning true if successful. Note that |
81 // this does not initiate client shutdown; that must be done by the test | 83 // this does not initiate client shutdown; that must be done by the test |
82 // (somehow). This must be called before the end of the test whenever | 84 // (somehow). This must be called before the end of the test whenever |
83 // StartClient() was called successfully. | 85 // StartClient() was called successfully. |
84 bool WaitForClientShutdown(); | 86 bool WaitForClientShutdown(); |
85 | 87 |
88 IPC::ChannelHandle GetTestChannelHandle(); | |
89 | |
86 // Use this to send IPC messages (when you don't care if you're using a | 90 // Use this to send IPC messages (when you don't care if you're using a |
87 // channel or a proxy). | 91 // channel or a proxy). |
88 IPC::Sender* sender() { | 92 IPC::Sender* sender() { |
89 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : | 93 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : |
90 static_cast<IPC::Sender*>(channel_proxy_.get()); | 94 static_cast<IPC::Sender*>(channel_proxy_.get()); |
91 } | 95 } |
92 | 96 |
93 IPC::Channel* channel() { return channel_.get(); } | 97 IPC::Channel* channel() { return channel_.get(); } |
94 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } | 98 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } |
95 | 99 |
(...skipping 13 matching lines...) Expand all Loading... | |
109 base::ProcessHandle client_process_; | 113 base::ProcessHandle client_process_; |
110 | 114 |
111 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); | 115 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); |
112 }; | 116 }; |
113 | 117 |
114 // Use this to declare the client side for tests using IPCTestBase. | 118 // Use this to declare the client side for tests using IPCTestBase. |
115 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ | 119 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ |
116 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) | 120 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) |
117 | 121 |
118 #endif // IPC_IPC_TEST_BASE_H_ | 122 #endif // IPC_IPC_TEST_BASE_H_ |
OLD | NEW |