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

Side by Side Diff: ipc/ipc_test_base.h

Issue 553283002: IPC::ChannelMojo: Introduce IPC::MojoBootstrap for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build error 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 | « content/child/child_thread.cc ('k') | ipc/ipc_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 79
80 #if defined(OS_POSIX)
81 // A StartClient() variant that allows caller to pass the FD of IPC pipe
82 bool StartClientWithFD(int ipcfd);
83 #endif
84
80 // Waits for the client to shut down, returning true if successful. Note that 85 // 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 86 // 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 87 // (somehow). This must be called before the end of the test whenever
83 // StartClient() was called successfully. 88 // StartClient() was called successfully.
84 bool WaitForClientShutdown(); 89 bool WaitForClientShutdown();
85 90
91 IPC::ChannelHandle GetTestChannelHandle();
92
86 // Use this to send IPC messages (when you don't care if you're using a 93 // Use this to send IPC messages (when you don't care if you're using a
87 // channel or a proxy). 94 // channel or a proxy).
88 IPC::Sender* sender() { 95 IPC::Sender* sender() {
89 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : 96 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) :
90 static_cast<IPC::Sender*>(channel_proxy_.get()); 97 static_cast<IPC::Sender*>(channel_proxy_.get());
91 } 98 }
92 99
93 IPC::Channel* channel() { return channel_.get(); } 100 IPC::Channel* channel() { return channel_.get(); }
94 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } 101 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); }
95 102
96 const base::ProcessHandle& client_process() const { return client_process_; } 103 const base::ProcessHandle& client_process() const { return client_process_; }
97 scoped_refptr<base::TaskRunner> task_runner(); 104 scoped_refptr<base::TaskRunner> task_runner();
98 105
99 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( 106 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
100 const IPC::ChannelHandle& handle, base::TaskRunner* runner); 107 const IPC::ChannelHandle& handle, base::TaskRunner* runner);
101 108
109 virtual bool DidStartClient();
110
102 private: 111 private:
112 std::string GetTestMainName() const;
113
103 std::string test_client_name_; 114 std::string test_client_name_;
104 scoped_ptr<base::MessageLoop> message_loop_; 115 scoped_ptr<base::MessageLoop> message_loop_;
105 116
106 scoped_ptr<IPC::Channel> channel_; 117 scoped_ptr<IPC::Channel> channel_;
107 scoped_ptr<IPC::ChannelProxy> channel_proxy_; 118 scoped_ptr<IPC::ChannelProxy> channel_proxy_;
108 119
109 base::ProcessHandle client_process_; 120 base::ProcessHandle client_process_;
110 121
111 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); 122 DISALLOW_COPY_AND_ASSIGN(IPCTestBase);
112 }; 123 };
113 124
114 // Use this to declare the client side for tests using IPCTestBase. 125 // Use this to declare the client side for tests using IPCTestBase.
115 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ 126 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \
116 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) 127 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain)
117 128
118 #endif // IPC_IPC_TEST_BASE_H_ 129 #endif // IPC_IPC_TEST_BASE_H_
OLDNEW
« no previous file with comments | « content/child/child_thread.cc ('k') | ipc/ipc_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698