| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 // Use this to send IPC messages (when you don't care if you're using a | 97 // Use this to send IPC messages (when you don't care if you're using a |
| 98 // channel or a proxy). | 98 // channel or a proxy). |
| 99 IPC::Sender* sender() { | 99 IPC::Sender* sender() { |
| 100 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : | 100 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : |
| 101 static_cast<IPC::Sender*>(channel_proxy_.get()); | 101 static_cast<IPC::Sender*>(channel_proxy_.get()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 IPC::Channel* channel() { return channel_.get(); } | 104 IPC::Channel* channel() { return channel_.get(); } |
| 105 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } | 105 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } |
| 106 void set_attachment_broker(IPC::AttachmentBroker* broker) { | |
| 107 attachment_broker_ = broker; | |
| 108 } | |
| 109 | 106 |
| 110 const base::Process& client_process() const { return client_process_; } | 107 const base::Process& client_process() const { return client_process_; } |
| 111 scoped_refptr<base::SequencedTaskRunner> task_runner(); | 108 scoped_refptr<base::SequencedTaskRunner> task_runner(); |
| 112 | 109 |
| 113 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 110 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
| 114 const IPC::ChannelHandle& handle, base::SequencedTaskRunner* runner); | 111 const IPC::ChannelHandle& handle, base::SequencedTaskRunner* runner); |
| 115 | 112 |
| 116 virtual bool DidStartClient(); | 113 virtual bool DidStartClient(); |
| 117 | 114 |
| 118 private: | 115 private: |
| 119 std::string GetTestMainName() const; | 116 std::string GetTestMainName() const; |
| 120 | 117 |
| 121 std::string test_client_name_; | 118 std::string test_client_name_; |
| 122 scoped_ptr<base::MessageLoop> message_loop_; | 119 scoped_ptr<base::MessageLoop> message_loop_; |
| 123 | 120 |
| 124 scoped_ptr<IPC::Channel> channel_; | 121 scoped_ptr<IPC::Channel> channel_; |
| 125 scoped_ptr<IPC::ChannelProxy> channel_proxy_; | 122 scoped_ptr<IPC::ChannelProxy> channel_proxy_; |
| 126 | 123 |
| 127 // The AttachmentBroker that should be passed to |channel_| when it is | |
| 128 // created. | |
| 129 IPC::AttachmentBroker* attachment_broker_; | |
| 130 | |
| 131 base::Process client_process_; | 124 base::Process client_process_; |
| 132 | 125 |
| 133 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); | 126 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); |
| 134 }; | 127 }; |
| 135 | 128 |
| 136 // Use this to declare the client side for tests using IPCTestBase. | 129 // Use this to declare the client side for tests using IPCTestBase. |
| 137 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ | 130 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ |
| 138 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) | 131 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) |
| 139 | 132 |
| 140 #endif // IPC_IPC_TEST_BASE_H_ | 133 #endif // IPC_IPC_TEST_BASE_H_ |
| OLD | NEW |