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

Side by Side Diff: ipc/ipc_test_base.h

Issue 382333002: Introduce ChannelMojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 29 matching lines...) Expand all
40 void Init(const std::string& test_client_name); 40 void Init(const std::string& test_client_name);
41 41
42 // Creates a channel with the given listener and connects to the channel 42 // Creates a channel with the given listener and connects to the channel
43 // (returning true if successful), respectively. Use these to use a channel 43 // (returning true if successful), respectively. Use these to use a channel
44 // directly. Since the listener must outlive the channel, you must destroy the 44 // directly. Since the listener must outlive the channel, you must destroy the
45 // channel before the listener gets destroyed. 45 // channel before the listener gets destroyed.
46 void CreateChannel(IPC::Listener* listener); 46 void CreateChannel(IPC::Listener* listener);
47 bool ConnectChannel(); 47 bool ConnectChannel();
48 void DestroyChannel(); 48 void DestroyChannel();
49 49
50 // Releases or replaces existing channel.
51 // These are useful for testing specific types of channel subclasses.
52 scoped_ptr<IPC::Channel> ReleaseChannel();
53 void SetChannel(scoped_ptr<IPC::Channel> channel);
54
50 // Use this instead of CreateChannel() if you want to use some different 55 // Use this instead of CreateChannel() if you want to use some different
51 // channel specification (then use ConnectChannel() as usual). 56 // channel specification (then use ConnectChannel() as usual).
52 void CreateChannelFromChannelHandle(const IPC::ChannelHandle& channel_handle, 57 void CreateChannelFromChannelHandle(const IPC::ChannelHandle& channel_handle,
53 IPC::Listener* listener); 58 IPC::Listener* listener);
54 59
55 // Creates a channel proxy with the given listener and task runner. (The 60 // Creates a channel proxy with the given listener and task runner. (The
56 // channel proxy will automatically create and connect a channel.) You must 61 // channel proxy will automatically create and connect a channel.) You must
57 // (manually) destroy the channel proxy before the task runner's thread is 62 // (manually) destroy the channel proxy before the task runner's thread is
58 // destroyed. 63 // destroyed.
59 void CreateChannelProxy(IPC::Listener* listener, 64 void CreateChannelProxy(IPC::Listener* listener,
(...skipping 14 matching lines...) Expand all
74 // channel or a proxy). 79 // channel or a proxy).
75 IPC::Sender* sender() { 80 IPC::Sender* sender() {
76 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : 81 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) :
77 static_cast<IPC::Sender*>(channel_proxy_.get()); 82 static_cast<IPC::Sender*>(channel_proxy_.get());
78 } 83 }
79 84
80 IPC::Channel* channel() { return channel_.get(); } 85 IPC::Channel* channel() { return channel_.get(); }
81 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } 86 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); }
82 87
83 const base::ProcessHandle& client_process() const { return client_process_; } 88 const base::ProcessHandle& client_process() const { return client_process_; }
89 scoped_refptr<base::TaskRunner> io_thread_task_runner();
84 90
85 private: 91 private:
86 std::string test_client_name_; 92 std::string test_client_name_;
87 scoped_ptr<base::MessageLoopForIO> message_loop_; 93 scoped_ptr<base::MessageLoopForIO> message_loop_;
88 94
89 scoped_ptr<IPC::Channel> channel_; 95 scoped_ptr<IPC::Channel> channel_;
90 scoped_ptr<IPC::ChannelProxy> channel_proxy_; 96 scoped_ptr<IPC::ChannelProxy> channel_proxy_;
91 97
92 base::ProcessHandle client_process_; 98 base::ProcessHandle client_process_;
93 99
94 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); 100 DISALLOW_COPY_AND_ASSIGN(IPCTestBase);
95 }; 101 };
96 102
97 // Use this to declare the client side for tests using IPCTestBase. 103 // Use this to declare the client side for tests using IPCTestBase.
98 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ 104 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \
99 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) 105 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain)
100 106
101 #endif // IPC_IPC_TEST_BASE_H_ 107 #endif // IPC_IPC_TEST_BASE_H_
OLDNEW
« ipc/ipc_channel.h ('K') | « ipc/ipc_sync_channel.cc ('k') | ipc/ipc_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698