[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ipc/mojo/ipc_channel_mojo.h" |
| 6 | |
| 7 | #include "base/base_paths.h" |
| 8 | #include "base/files/file.h" |
skyostil | e687bdff | 2015-05-12 11:29:21 | [diff] [blame] | 9 | #include "base/location.h" |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 10 | #include "base/path_service.h" |
| 11 | #include "base/pickle.h" |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 12 | #include "base/run_loop.h" |
skyostil | e687bdff | 2015-05-12 11:29:21 | [diff] [blame] | 13 | #include "base/single_thread_task_runner.h" |
morrita | 0bd20bd | 2015-02-25 20:11:27 | [diff] [blame] | 14 | #include "base/test/test_timeouts.h" |
skyostil | e687bdff | 2015-05-12 11:29:21 | [diff] [blame] | 15 | #include "base/thread_task_runner_handle.h" |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 16 | #include "base/threading/thread.h" |
| 17 | #include "ipc/ipc_message.h" |
| 18 | #include "ipc/ipc_test_base.h" |
| 19 | #include "ipc/ipc_test_channel_listener.h" |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 20 | #include "ipc/mojo/ipc_mojo_handle_attachment.h" |
| 21 | #include "ipc/mojo/ipc_mojo_message_helper.h" |
morrita | 438a2ee | 2015-04-03 05:28:21 | [diff] [blame] | 22 | #include "ipc/mojo/ipc_mojo_param_traits.h" |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 23 | #include "ipc/mojo/scoped_ipc_support.h" |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 24 | |
| 25 | #if defined(OS_POSIX) |
| 26 | #include "base/file_descriptor_posix.h" |
morrita | 1aa788c | 2015-01-31 05:45:42 | [diff] [blame] | 27 | #include "ipc/ipc_platform_file_attachment_posix.h" |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 28 | #endif |
| 29 | |
| 30 | namespace { |
| 31 | |
| 32 | class ListenerThatExpectsOK : public IPC::Listener { |
| 33 | public: |
[email protected] | e5c2775 | 2014-08-08 21:45:13 | [diff] [blame] | 34 | ListenerThatExpectsOK() |
| 35 | : received_ok_(false) {} |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 36 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 37 | ~ListenerThatExpectsOK() override {} |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 38 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 39 | bool OnMessageReceived(const IPC::Message& message) override { |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 40 | base::PickleIterator iter(message); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 41 | std::string should_be_ok; |
| 42 | EXPECT_TRUE(iter.ReadString(&should_be_ok)); |
| 43 | EXPECT_EQ(should_be_ok, "OK"); |
[email protected] | e5c2775 | 2014-08-08 21:45:13 | [diff] [blame] | 44 | received_ok_ = true; |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 45 | base::MessageLoop::current()->Quit(); |
| 46 | return true; |
| 47 | } |
| 48 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 49 | void OnChannelError() override { |
[email protected] | e5c2775 | 2014-08-08 21:45:13 | [diff] [blame] | 50 | // The connection should be healthy while the listener is waiting |
| 51 | // message. An error can occur after that because the peer |
| 52 | // process dies. |
| 53 | DCHECK(received_ok_); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | static void SendOK(IPC::Sender* sender) { |
| 57 | IPC::Message* message = new IPC::Message( |
| 58 | 0, 2, IPC::Message::PRIORITY_NORMAL); |
| 59 | message->WriteString(std::string("OK")); |
| 60 | ASSERT_TRUE(sender->Send(message)); |
| 61 | } |
[email protected] | e5c2775 | 2014-08-08 21:45:13 | [diff] [blame] | 62 | |
| 63 | private: |
| 64 | bool received_ok_; |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 65 | }; |
| 66 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 67 | class ChannelClient { |
| 68 | public: |
| 69 | explicit ChannelClient(IPC::Listener* listener, const char* name) { |
leon.han | d20a6c4c | 2015-06-19 02:25:48 | [diff] [blame^] | 70 | channel_ = IPC::ChannelMojo::Create( |
| 71 | main_message_loop_.task_runner(), IPCTestBase::GetChannelName(name), |
| 72 | IPC::Channel::MODE_CLIENT, listener, nullptr); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void Connect() { |
| 76 | CHECK(channel_->Connect()); |
| 77 | } |
| 78 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 79 | void Close() { |
| 80 | channel_->Close(); |
| 81 | |
| 82 | base::RunLoop run_loop; |
skyostil | e687bdff | 2015-05-12 11:29:21 | [diff] [blame] | 83 | base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 84 | run_loop.QuitClosure()); |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 85 | run_loop.Run(); |
| 86 | } |
| 87 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 88 | IPC::ChannelMojo* channel() const { return channel_.get(); } |
| 89 | |
| 90 | private: |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 91 | base::MessageLoopForIO main_message_loop_; |
morrita | 54f6f80c | 2014-09-23 21:16:00 | [diff] [blame] | 92 | scoped_ptr<IPC::ChannelMojo> channel_; |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 93 | }; |
| 94 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 95 | class IPCChannelMojoTestBase : public IPCTestBase { |
| 96 | public: |
| 97 | void InitWithMojo(const std::string& test_client_name) { |
| 98 | Init(test_client_name); |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | void TearDown() override { |
| 102 | // Make sure Mojo IPC support is properly shutdown on the I/O loop before |
| 103 | // TearDown continues. |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 104 | base::RunLoop run_loop; |
| 105 | task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure()); |
| 106 | run_loop.Run(); |
| 107 | |
| 108 | IPCTestBase::TearDown(); |
| 109 | } |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | class IPCChannelMojoTest : public IPCChannelMojoTestBase { |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 113 | protected: |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 114 | scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
morrita | 373af03b | 2014-09-09 19:35:24 | [diff] [blame] | 115 | const IPC::ChannelHandle& handle, |
morrita | c4db547 | 2015-03-13 20:44:39 | [diff] [blame] | 116 | base::SequencedTaskRunner* runner) override { |
leon.han | d20a6c4c | 2015-06-19 02:25:48 | [diff] [blame^] | 117 | return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle, |
| 118 | nullptr); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 119 | } |
morrita | 54f6f80c | 2014-09-23 21:16:00 | [diff] [blame] | 120 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 121 | bool DidStartClient() override { |
morrita | 54f6f80c | 2014-09-23 21:16:00 | [diff] [blame] | 122 | bool ok = IPCTestBase::DidStartClient(); |
| 123 | DCHECK(ok); |
morrita | 54f6f80c | 2014-09-23 21:16:00 | [diff] [blame] | 124 | return ok; |
| 125 | } |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 129 | class TestChannelListenerWithExtraExpectations |
| 130 | : public IPC::TestChannelListener { |
| 131 | public: |
| 132 | TestChannelListenerWithExtraExpectations() |
| 133 | : is_connected_called_(false) { |
| 134 | } |
| 135 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 136 | void OnChannelConnected(int32 peer_pid) override { |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 137 | IPC::TestChannelListener::OnChannelConnected(peer_pid); |
| 138 | EXPECT_TRUE(base::kNullProcessId != peer_pid); |
| 139 | is_connected_called_ = true; |
| 140 | } |
| 141 | |
| 142 | bool is_connected_called() const { return is_connected_called_; } |
| 143 | |
| 144 | private: |
| 145 | bool is_connected_called_; |
| 146 | }; |
| 147 | |
| 148 | TEST_F(IPCChannelMojoTest, ConnectedFromClient) { |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 149 | InitWithMojo("IPCChannelMojoTestClient"); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 150 | |
| 151 | // Set up IPC channel and start client. |
| 152 | TestChannelListenerWithExtraExpectations listener; |
morrita | 373af03b | 2014-09-09 19:35:24 | [diff] [blame] | 153 | CreateChannel(&listener); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 154 | listener.Init(sender()); |
| 155 | ASSERT_TRUE(ConnectChannel()); |
| 156 | ASSERT_TRUE(StartClient()); |
| 157 | |
| 158 | IPC::TestChannelListener::SendOneMessage( |
| 159 | sender(), "hello from parent"); |
| 160 | |
| 161 | base::MessageLoop::current()->Run(); |
| 162 | EXPECT_TRUE(base::kNullProcessId != this->channel()->GetPeerPID()); |
| 163 | |
| 164 | this->channel()->Close(); |
| 165 | |
| 166 | EXPECT_TRUE(WaitForClientShutdown()); |
| 167 | EXPECT_TRUE(listener.is_connected_called()); |
| 168 | EXPECT_TRUE(listener.HasSentAll()); |
| 169 | |
| 170 | DestroyChannel(); |
| 171 | } |
| 172 | |
| 173 | // A long running process that connects to us |
| 174 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestClient) { |
| 175 | TestChannelListenerWithExtraExpectations listener; |
| 176 | ChannelClient client(&listener, "IPCChannelMojoTestClient"); |
| 177 | client.Connect(); |
| 178 | listener.Init(client.channel()); |
| 179 | |
| 180 | IPC::TestChannelListener::SendOneMessage( |
| 181 | client.channel(), "hello from child"); |
| 182 | base::MessageLoop::current()->Run(); |
| 183 | EXPECT_TRUE(listener.is_connected_called()); |
| 184 | EXPECT_TRUE(listener.HasSentAll()); |
| 185 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 186 | client.Close(); |
| 187 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 188 | return 0; |
| 189 | } |
| 190 | |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 191 | class ListenerExpectingErrors : public IPC::Listener { |
| 192 | public: |
| 193 | ListenerExpectingErrors() |
| 194 | : has_error_(false) { |
| 195 | } |
| 196 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 197 | void OnChannelConnected(int32 peer_pid) override { |
morrita | be6c4cc | 2014-09-24 23:38:44 | [diff] [blame] | 198 | base::MessageLoop::current()->Quit(); |
| 199 | } |
| 200 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 201 | bool OnMessageReceived(const IPC::Message& message) override { return true; } |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 202 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 203 | void OnChannelError() override { |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 204 | has_error_ = true; |
| 205 | base::MessageLoop::current()->Quit(); |
| 206 | } |
| 207 | |
| 208 | bool has_error() const { return has_error_; } |
| 209 | |
| 210 | private: |
| 211 | bool has_error_; |
| 212 | }; |
| 213 | |
| 214 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 215 | class IPCChannelMojoErrorTest : public IPCChannelMojoTestBase { |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 216 | protected: |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 217 | scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 218 | const IPC::ChannelHandle& handle, |
morrita | c4db547 | 2015-03-13 20:44:39 | [diff] [blame] | 219 | base::SequencedTaskRunner* runner) override { |
leon.han | d20a6c4c | 2015-06-19 02:25:48 | [diff] [blame^] | 220 | return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle, |
| 221 | nullptr); |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 222 | } |
morrita | 54f6f80c | 2014-09-23 21:16:00 | [diff] [blame] | 223 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 224 | bool DidStartClient() override { |
morrita | 54f6f80c | 2014-09-23 21:16:00 | [diff] [blame] | 225 | bool ok = IPCTestBase::DidStartClient(); |
| 226 | DCHECK(ok); |
morrita | 54f6f80c | 2014-09-23 21:16:00 | [diff] [blame] | 227 | return ok; |
| 228 | } |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | class ListenerThatQuits : public IPC::Listener { |
| 232 | public: |
| 233 | ListenerThatQuits() { |
| 234 | } |
| 235 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 236 | bool OnMessageReceived(const IPC::Message& message) override { |
dcheng | f3076af | 2014-10-21 18:02:42 | [diff] [blame] | 237 | return true; |
| 238 | } |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 239 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 240 | void OnChannelConnected(int32 peer_pid) override { |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 241 | base::MessageLoop::current()->Quit(); |
| 242 | } |
| 243 | }; |
| 244 | |
| 245 | // A long running process that connects to us. |
| 246 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoErraticTestClient) { |
| 247 | ListenerThatQuits listener; |
| 248 | ChannelClient client(&listener, "IPCChannelMojoErraticTestClient"); |
| 249 | client.Connect(); |
| 250 | |
| 251 | base::MessageLoop::current()->Run(); |
| 252 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 253 | client.Close(); |
| 254 | |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 255 | return 0; |
| 256 | } |
| 257 | |
morrita | be6c4cc | 2014-09-24 23:38:44 | [diff] [blame] | 258 | TEST_F(IPCChannelMojoErrorTest, SendFailWithPendingMessages) { |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 259 | InitWithMojo("IPCChannelMojoErraticTestClient"); |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 260 | |
| 261 | // Set up IPC channel and start client. |
| 262 | ListenerExpectingErrors listener; |
| 263 | CreateChannel(&listener); |
| 264 | ASSERT_TRUE(ConnectChannel()); |
| 265 | |
jamesr | a03ae49 | 2014-10-03 04:26:48 | [diff] [blame] | 266 | // This matches a value in mojo/edk/system/constants.h |
morrita | be6c4cc | 2014-09-24 23:38:44 | [diff] [blame] | 267 | const int kMaxMessageNumBytes = 4 * 1024 * 1024; |
| 268 | std::string overly_large_data(kMaxMessageNumBytes, '*'); |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 269 | // This messages are queued as pending. |
morrita | be6c4cc | 2014-09-24 23:38:44 | [diff] [blame] | 270 | for (size_t i = 0; i < 10; ++i) { |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 271 | IPC::TestChannelListener::SendOneMessage( |
morrita | be6c4cc | 2014-09-24 23:38:44 | [diff] [blame] | 272 | sender(), overly_large_data.c_str()); |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | ASSERT_TRUE(StartClient()); |
| 276 | base::MessageLoop::current()->Run(); |
| 277 | |
| 278 | this->channel()->Close(); |
| 279 | |
| 280 | EXPECT_TRUE(WaitForClientShutdown()); |
| 281 | EXPECT_TRUE(listener.has_error()); |
| 282 | |
| 283 | DestroyChannel(); |
| 284 | } |
| 285 | |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 286 | struct TestingMessagePipe { |
| 287 | TestingMessagePipe() { |
| 288 | EXPECT_EQ(MOJO_RESULT_OK, mojo::CreateMessagePipe(nullptr, &self, &peer)); |
| 289 | } |
| 290 | |
| 291 | mojo::ScopedMessagePipeHandle self; |
| 292 | mojo::ScopedMessagePipeHandle peer; |
| 293 | }; |
| 294 | |
| 295 | class HandleSendingHelper { |
| 296 | public: |
| 297 | static std::string GetSendingFileContent() { return "Hello"; } |
| 298 | |
| 299 | static void WritePipe(IPC::Message* message, TestingMessagePipe* pipe) { |
| 300 | std::string content = HandleSendingHelper::GetSendingFileContent(); |
| 301 | EXPECT_EQ(MOJO_RESULT_OK, |
| 302 | mojo::WriteMessageRaw(pipe->self.get(), &content[0], |
| 303 | static_cast<uint32_t>(content.size()), |
| 304 | nullptr, 0, 0)); |
| 305 | EXPECT_TRUE( |
| 306 | IPC::MojoMessageHelper::WriteMessagePipeTo(message, pipe->peer.Pass())); |
| 307 | } |
| 308 | |
| 309 | static void WritePipeThenSend(IPC::Sender* sender, TestingMessagePipe* pipe) { |
| 310 | IPC::Message* message = |
| 311 | new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); |
| 312 | WritePipe(message, pipe); |
| 313 | ASSERT_TRUE(sender->Send(message)); |
| 314 | } |
| 315 | |
| 316 | static void ReadReceivedPipe(const IPC::Message& message, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 317 | base::PickleIterator* iter) { |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 318 | mojo::ScopedMessagePipeHandle pipe; |
| 319 | EXPECT_TRUE( |
| 320 | IPC::MojoMessageHelper::ReadMessagePipeFrom(&message, iter, &pipe)); |
| 321 | std::string content(GetSendingFileContent().size(), ' '); |
| 322 | |
| 323 | uint32_t num_bytes = static_cast<uint32_t>(content.size()); |
| 324 | EXPECT_EQ(MOJO_RESULT_OK, |
| 325 | mojo::ReadMessageRaw(pipe.get(), &content[0], &num_bytes, nullptr, |
| 326 | nullptr, 0)); |
| 327 | EXPECT_EQ(content, GetSendingFileContent()); |
| 328 | } |
| 329 | |
| 330 | #if defined(OS_POSIX) |
| 331 | static base::FilePath GetSendingFilePath() { |
| 332 | base::FilePath path; |
| 333 | bool ok = PathService::Get(base::DIR_CACHE, &path); |
| 334 | EXPECT_TRUE(ok); |
| 335 | return path.Append("ListenerThatExpectsFile.txt"); |
| 336 | } |
| 337 | |
| 338 | static void WriteFile(IPC::Message* message, base::File& file) { |
| 339 | std::string content = GetSendingFileContent(); |
| 340 | file.WriteAtCurrentPos(content.data(), content.size()); |
| 341 | file.Flush(); |
| 342 | message->WriteAttachment(new IPC::internal::PlatformFileAttachment( |
| 343 | base::ScopedFD(file.TakePlatformFile()))); |
| 344 | } |
| 345 | |
| 346 | static void WriteFileThenSend(IPC::Sender* sender, base::File& file) { |
| 347 | IPC::Message* message = |
| 348 | new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); |
| 349 | WriteFile(message, file); |
| 350 | ASSERT_TRUE(sender->Send(message)); |
| 351 | } |
| 352 | |
| 353 | static void WriteFileAndPipeThenSend(IPC::Sender* sender, |
| 354 | base::File& file, |
| 355 | TestingMessagePipe* pipe) { |
| 356 | IPC::Message* message = |
| 357 | new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); |
| 358 | WriteFile(message, file); |
| 359 | WritePipe(message, pipe); |
| 360 | ASSERT_TRUE(sender->Send(message)); |
| 361 | } |
| 362 | |
| 363 | static void ReadReceivedFile(const IPC::Message& message, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 364 | base::PickleIterator* iter) { |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 365 | base::ScopedFD fd; |
| 366 | scoped_refptr<IPC::MessageAttachment> attachment; |
| 367 | EXPECT_TRUE(message.ReadAttachment(iter, &attachment)); |
| 368 | base::File file(attachment->TakePlatformFile()); |
| 369 | std::string content(GetSendingFileContent().size(), ' '); |
| 370 | file.Read(0, &content[0], content.size()); |
| 371 | EXPECT_EQ(content, GetSendingFileContent()); |
| 372 | } |
| 373 | #endif |
| 374 | }; |
| 375 | |
| 376 | class ListenerThatExpectsMessagePipe : public IPC::Listener { |
| 377 | public: |
| 378 | ListenerThatExpectsMessagePipe() : sender_(NULL) {} |
| 379 | |
| 380 | ~ListenerThatExpectsMessagePipe() override {} |
| 381 | |
| 382 | bool OnMessageReceived(const IPC::Message& message) override { |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 383 | base::PickleIterator iter(message); |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 384 | HandleSendingHelper::ReadReceivedPipe(message, &iter); |
| 385 | base::MessageLoop::current()->Quit(); |
| 386 | ListenerThatExpectsOK::SendOK(sender_); |
| 387 | return true; |
| 388 | } |
| 389 | |
| 390 | void OnChannelError() override { NOTREACHED(); } |
| 391 | |
| 392 | void set_sender(IPC::Sender* sender) { sender_ = sender; } |
| 393 | |
| 394 | private: |
| 395 | IPC::Sender* sender_; |
| 396 | }; |
| 397 | |
| 398 | TEST_F(IPCChannelMojoTest, SendMessagePipe) { |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 399 | InitWithMojo("IPCChannelMojoTestSendMessagePipeClient"); |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 400 | |
| 401 | ListenerThatExpectsOK listener; |
| 402 | CreateChannel(&listener); |
| 403 | ASSERT_TRUE(ConnectChannel()); |
| 404 | ASSERT_TRUE(StartClient()); |
| 405 | |
| 406 | TestingMessagePipe pipe; |
| 407 | HandleSendingHelper::WritePipeThenSend(channel(), &pipe); |
| 408 | |
| 409 | base::MessageLoop::current()->Run(); |
| 410 | this->channel()->Close(); |
| 411 | |
| 412 | EXPECT_TRUE(WaitForClientShutdown()); |
| 413 | DestroyChannel(); |
| 414 | } |
| 415 | |
| 416 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestSendMessagePipeClient) { |
| 417 | ListenerThatExpectsMessagePipe listener; |
morrita | e73c0b4 | 2015-03-05 02:55:19 | [diff] [blame] | 418 | ChannelClient client(&listener, "IPCChannelMojoTestSendMessagePipeClient"); |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 419 | client.Connect(); |
| 420 | listener.set_sender(client.channel()); |
| 421 | |
| 422 | base::MessageLoop::current()->Run(); |
| 423 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 424 | client.Close(); |
| 425 | |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 426 | return 0; |
| 427 | } |
| 428 | |
morrita | 438a2ee | 2015-04-03 05:28:21 | [diff] [blame] | 429 | void ReadOK(mojo::MessagePipeHandle pipe) { |
| 430 | std::string should_be_ok("xx"); |
| 431 | uint32_t num_bytes = static_cast<uint32_t>(should_be_ok.size()); |
| 432 | CHECK_EQ(MOJO_RESULT_OK, |
| 433 | mojo::ReadMessageRaw(pipe, &should_be_ok[0], &num_bytes, nullptr, |
| 434 | nullptr, 0)); |
| 435 | EXPECT_EQ(should_be_ok, std::string("OK")); |
| 436 | } |
| 437 | |
| 438 | void WriteOK(mojo::MessagePipeHandle pipe) { |
| 439 | std::string ok("OK"); |
| 440 | CHECK_EQ(MOJO_RESULT_OK, |
| 441 | mojo::WriteMessageRaw(pipe, &ok[0], static_cast<uint32_t>(ok.size()), |
| 442 | nullptr, 0, 0)); |
| 443 | } |
| 444 | |
| 445 | class ListenerThatExpectsMessagePipeUsingParamTrait : public IPC::Listener { |
| 446 | public: |
| 447 | explicit ListenerThatExpectsMessagePipeUsingParamTrait(bool receiving_valid) |
| 448 | : sender_(NULL), receiving_valid_(receiving_valid) {} |
| 449 | |
| 450 | ~ListenerThatExpectsMessagePipeUsingParamTrait() override {} |
| 451 | |
| 452 | bool OnMessageReceived(const IPC::Message& message) override { |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 453 | base::PickleIterator iter(message); |
morrita | 438a2ee | 2015-04-03 05:28:21 | [diff] [blame] | 454 | mojo::MessagePipeHandle handle; |
| 455 | EXPECT_TRUE(IPC::ParamTraits<mojo::MessagePipeHandle>::Read(&message, &iter, |
| 456 | &handle)); |
| 457 | EXPECT_EQ(handle.is_valid(), receiving_valid_); |
| 458 | if (receiving_valid_) { |
| 459 | ReadOK(handle); |
| 460 | MojoClose(handle.value()); |
| 461 | } |
| 462 | |
| 463 | base::MessageLoop::current()->Quit(); |
| 464 | ListenerThatExpectsOK::SendOK(sender_); |
| 465 | return true; |
| 466 | } |
| 467 | |
| 468 | void OnChannelError() override { NOTREACHED(); } |
| 469 | void set_sender(IPC::Sender* sender) { sender_ = sender; } |
| 470 | |
| 471 | private: |
| 472 | IPC::Sender* sender_; |
| 473 | bool receiving_valid_; |
| 474 | }; |
| 475 | |
| 476 | void ParamTraitMessagePipeClient(bool receiving_valid_handle, |
| 477 | const char* channel_name) { |
| 478 | ListenerThatExpectsMessagePipeUsingParamTrait listener( |
| 479 | receiving_valid_handle); |
| 480 | ChannelClient client(&listener, channel_name); |
| 481 | client.Connect(); |
| 482 | listener.set_sender(client.channel()); |
| 483 | |
| 484 | base::MessageLoop::current()->Run(); |
| 485 | |
| 486 | client.Close(); |
| 487 | } |
| 488 | |
| 489 | TEST_F(IPCChannelMojoTest, ParamTraitValidMessagePipe) { |
| 490 | InitWithMojo("ParamTraitValidMessagePipeClient"); |
| 491 | |
| 492 | ListenerThatExpectsOK listener; |
| 493 | CreateChannel(&listener); |
| 494 | ASSERT_TRUE(ConnectChannel()); |
| 495 | ASSERT_TRUE(StartClient()); |
| 496 | |
| 497 | TestingMessagePipe pipe; |
| 498 | |
| 499 | scoped_ptr<IPC::Message> message(new IPC::Message()); |
| 500 | IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), |
| 501 | pipe.peer.release()); |
| 502 | WriteOK(pipe.self.get()); |
| 503 | |
| 504 | this->channel()->Send(message.release()); |
| 505 | base::MessageLoop::current()->Run(); |
| 506 | this->channel()->Close(); |
| 507 | |
| 508 | EXPECT_TRUE(WaitForClientShutdown()); |
| 509 | DestroyChannel(); |
| 510 | } |
| 511 | |
| 512 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitValidMessagePipeClient) { |
| 513 | ParamTraitMessagePipeClient(true, "ParamTraitValidMessagePipeClient"); |
| 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | TEST_F(IPCChannelMojoTest, ParamTraitInvalidMessagePipe) { |
| 518 | InitWithMojo("ParamTraitInvalidMessagePipeClient"); |
| 519 | |
| 520 | ListenerThatExpectsOK listener; |
| 521 | CreateChannel(&listener); |
| 522 | ASSERT_TRUE(ConnectChannel()); |
| 523 | ASSERT_TRUE(StartClient()); |
| 524 | |
| 525 | mojo::MessagePipeHandle invalid_handle; |
| 526 | scoped_ptr<IPC::Message> message(new IPC::Message()); |
| 527 | IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), |
| 528 | invalid_handle); |
| 529 | |
| 530 | this->channel()->Send(message.release()); |
| 531 | base::MessageLoop::current()->Run(); |
| 532 | this->channel()->Close(); |
| 533 | |
| 534 | EXPECT_TRUE(WaitForClientShutdown()); |
| 535 | DestroyChannel(); |
| 536 | } |
| 537 | |
| 538 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitInvalidMessagePipeClient) { |
| 539 | ParamTraitMessagePipeClient(false, "ParamTraitInvalidMessagePipeClient"); |
| 540 | return 0; |
| 541 | } |
| 542 | |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 543 | #if defined(OS_WIN) |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 544 | class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase { |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 545 | protected: |
nick | d60f717 | 2015-04-23 16:42:48 | [diff] [blame] | 546 | scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 547 | const IPC::ChannelHandle& handle, |
morrita | c4db547 | 2015-03-13 20:44:39 | [diff] [blame] | 548 | base::SequencedTaskRunner* runner) override { |
leon.han | d20a6c4c | 2015-06-19 02:25:48 | [diff] [blame^] | 549 | return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle, |
| 550 | nullptr); |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 551 | } |
| 552 | |
nick | d60f717 | 2015-04-23 16:42:48 | [diff] [blame] | 553 | bool DidStartClient() override { |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 554 | IPCTestBase::DidStartClient(); |
leon.han | d20a6c4c | 2015-06-19 02:25:48 | [diff] [blame^] | 555 | // const base::ProcessHandle client = client_process().Handle(); |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 556 | // Forces GetFileHandleForProcess() fail. It happens occasionally |
| 557 | // in production, so we should exercise it somehow. |
morrita | e73c0b4 | 2015-03-05 02:55:19 | [diff] [blame] | 558 | // TODO(morrita): figure out how to safely test this. See crbug.com/464109. |
rvargas | 07b589c | 2015-01-12 22:23:23 | [diff] [blame] | 559 | // ::CloseHandle(client); |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 560 | return true; |
| 561 | } |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 562 | }; |
| 563 | |
| 564 | TEST_F(IPCChannelMojoDeadHandleTest, InvalidClientHandle) { |
| 565 | // Any client type is fine as it is going to be killed anyway. |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 566 | InitWithMojo("IPCChannelMojoTestDoNothingClient"); |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 567 | |
| 568 | // Set up IPC channel and start client. |
| 569 | ListenerExpectingErrors listener; |
| 570 | CreateChannel(&listener); |
| 571 | ASSERT_TRUE(ConnectChannel()); |
| 572 | |
| 573 | ASSERT_TRUE(StartClient()); |
| 574 | base::MessageLoop::current()->Run(); |
| 575 | |
| 576 | this->channel()->Close(); |
| 577 | |
morrita | e73c0b4 | 2015-03-05 02:55:19 | [diff] [blame] | 578 | // TODO(morrita): We need CloseHandle() call in DidStartClient(), |
| 579 | // which has been disabled since crrev.com/843113003, to |
| 580 | // make this fail. See crbug.com/464109. |
| 581 | // EXPECT_FALSE(WaitForClientShutdown()); |
| 582 | WaitForClientShutdown(); |
morrita | 2580367 | 2014-10-15 18:50:19 | [diff] [blame] | 583 | EXPECT_TRUE(listener.has_error()); |
| 584 | |
| 585 | DestroyChannel(); |
| 586 | } |
| 587 | |
| 588 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestDoNothingClient) { |
| 589 | ListenerThatQuits listener; |
| 590 | ChannelClient client(&listener, "IPCChannelMojoTestDoNothingClient"); |
| 591 | client.Connect(); |
| 592 | |
| 593 | // Quits without running the message loop as this client won't |
| 594 | // receive any messages from the server. |
| 595 | |
| 596 | return 0; |
| 597 | } |
| 598 | #endif |
morrita | 0a24cfc9 | 2014-09-16 03:20:48 | [diff] [blame] | 599 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 600 | #if defined(OS_POSIX) |
| 601 | class ListenerThatExpectsFile : public IPC::Listener { |
| 602 | public: |
| 603 | ListenerThatExpectsFile() |
| 604 | : sender_(NULL) {} |
| 605 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 606 | ~ListenerThatExpectsFile() override {} |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 607 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 608 | bool OnMessageReceived(const IPC::Message& message) override { |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 609 | base::PickleIterator iter(message); |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 610 | HandleSendingHelper::ReadReceivedFile(message, &iter); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 611 | base::MessageLoop::current()->Quit(); |
| 612 | ListenerThatExpectsOK::SendOK(sender_); |
| 613 | return true; |
| 614 | } |
| 615 | |
dcheng | fe61fca | 2014-10-22 02:29:52 | [diff] [blame] | 616 | void OnChannelError() override { |
dcheng | f3076af | 2014-10-21 18:02:42 | [diff] [blame] | 617 | NOTREACHED(); |
| 618 | } |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 619 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 620 | void set_sender(IPC::Sender* sender) { sender_ = sender; } |
| 621 | |
| 622 | private: |
| 623 | IPC::Sender* sender_; |
| 624 | }; |
| 625 | |
| 626 | |
| 627 | TEST_F(IPCChannelMojoTest, SendPlatformHandle) { |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 628 | InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient"); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 629 | |
| 630 | ListenerThatExpectsOK listener; |
morrita | 373af03b | 2014-09-09 19:35:24 | [diff] [blame] | 631 | CreateChannel(&listener); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 632 | ASSERT_TRUE(ConnectChannel()); |
| 633 | ASSERT_TRUE(StartClient()); |
| 634 | |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 635 | base::File file(HandleSendingHelper::GetSendingFilePath(), |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 636 | base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 637 | base::File::FLAG_READ); |
| 638 | HandleSendingHelper::WriteFileThenSend(channel(), file); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 639 | base::MessageLoop::current()->Run(); |
| 640 | |
| 641 | this->channel()->Close(); |
| 642 | |
| 643 | EXPECT_TRUE(WaitForClientShutdown()); |
| 644 | DestroyChannel(); |
| 645 | } |
| 646 | |
| 647 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestSendPlatformHandleClient) { |
| 648 | ListenerThatExpectsFile listener; |
| 649 | ChannelClient client( |
| 650 | &listener, "IPCChannelMojoTestSendPlatformHandleClient"); |
| 651 | client.Connect(); |
| 652 | listener.set_sender(client.channel()); |
| 653 | |
| 654 | base::MessageLoop::current()->Run(); |
| 655 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 656 | client.Close(); |
| 657 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 658 | return 0; |
| 659 | } |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 660 | |
| 661 | class ListenerThatExpectsFileAndPipe : public IPC::Listener { |
| 662 | public: |
| 663 | ListenerThatExpectsFileAndPipe() : sender_(NULL) {} |
| 664 | |
| 665 | ~ListenerThatExpectsFileAndPipe() override {} |
| 666 | |
| 667 | bool OnMessageReceived(const IPC::Message& message) override { |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 668 | base::PickleIterator iter(message); |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 669 | HandleSendingHelper::ReadReceivedFile(message, &iter); |
| 670 | HandleSendingHelper::ReadReceivedPipe(message, &iter); |
| 671 | base::MessageLoop::current()->Quit(); |
| 672 | ListenerThatExpectsOK::SendOK(sender_); |
| 673 | return true; |
| 674 | } |
| 675 | |
| 676 | void OnChannelError() override { NOTREACHED(); } |
| 677 | |
| 678 | void set_sender(IPC::Sender* sender) { sender_ = sender; } |
| 679 | |
| 680 | private: |
| 681 | IPC::Sender* sender_; |
| 682 | }; |
| 683 | |
| 684 | TEST_F(IPCChannelMojoTest, SendPlatformHandleAndPipe) { |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 685 | InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient"); |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 686 | |
| 687 | ListenerThatExpectsOK listener; |
| 688 | CreateChannel(&listener); |
| 689 | ASSERT_TRUE(ConnectChannel()); |
| 690 | ASSERT_TRUE(StartClient()); |
| 691 | |
| 692 | base::File file(HandleSendingHelper::GetSendingFilePath(), |
| 693 | base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | |
| 694 | base::File::FLAG_READ); |
| 695 | TestingMessagePipe pipe; |
| 696 | HandleSendingHelper::WriteFileAndPipeThenSend(channel(), file, &pipe); |
| 697 | |
| 698 | base::MessageLoop::current()->Run(); |
| 699 | this->channel()->Close(); |
| 700 | |
| 701 | EXPECT_TRUE(WaitForClientShutdown()); |
| 702 | DestroyChannel(); |
| 703 | } |
| 704 | |
| 705 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN( |
| 706 | IPCChannelMojoTestSendPlatformHandleAndPipeClient) { |
| 707 | ListenerThatExpectsFileAndPipe listener; |
| 708 | ChannelClient client(&listener, |
| 709 | "IPCChannelMojoTestSendPlatformHandleAndPipeClient"); |
| 710 | client.Connect(); |
| 711 | listener.set_sender(client.channel()); |
| 712 | |
| 713 | base::MessageLoop::current()->Run(); |
| 714 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 715 | client.Close(); |
| 716 | |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 717 | return 0; |
| 718 | } |
| 719 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 720 | #endif |
| 721 | |
morrita | 0bd20bd | 2015-02-25 20:11:27 | [diff] [blame] | 722 | #if defined(OS_LINUX) |
| 723 | |
| 724 | const base::ProcessId kMagicChildId = 54321; |
| 725 | |
| 726 | class ListenerThatVerifiesPeerPid : public IPC::Listener { |
| 727 | public: |
| 728 | void OnChannelConnected(int32 peer_pid) override { |
| 729 | EXPECT_EQ(peer_pid, kMagicChildId); |
| 730 | base::MessageLoop::current()->Quit(); |
| 731 | } |
| 732 | |
| 733 | bool OnMessageReceived(const IPC::Message& message) override { |
| 734 | NOTREACHED(); |
| 735 | return true; |
| 736 | } |
| 737 | }; |
| 738 | |
| 739 | TEST_F(IPCChannelMojoTest, VerifyGlobalPid) { |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 740 | InitWithMojo("IPCChannelMojoTestVerifyGlobalPidClient"); |
morrita | 0bd20bd | 2015-02-25 20:11:27 | [diff] [blame] | 741 | |
| 742 | ListenerThatVerifiesPeerPid listener; |
| 743 | CreateChannel(&listener); |
| 744 | ASSERT_TRUE(ConnectChannel()); |
| 745 | ASSERT_TRUE(StartClient()); |
| 746 | |
| 747 | base::MessageLoop::current()->Run(); |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 748 | channel()->Close(); |
morrita | 0bd20bd | 2015-02-25 20:11:27 | [diff] [blame] | 749 | |
| 750 | EXPECT_TRUE(WaitForClientShutdown()); |
| 751 | DestroyChannel(); |
| 752 | } |
| 753 | |
| 754 | MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestVerifyGlobalPidClient) { |
| 755 | IPC::Channel::SetGlobalPid(kMagicChildId); |
| 756 | ListenerThatQuits listener; |
| 757 | ChannelClient client(&listener, |
| 758 | "IPCChannelMojoTestVerifyGlobalPidClient"); |
| 759 | client.Connect(); |
| 760 | |
| 761 | base::MessageLoop::current()->Run(); |
| 762 | |
rockot | cbca72f | 2015-03-03 16:31:04 | [diff] [blame] | 763 | client.Close(); |
| 764 | |
morrita | 0bd20bd | 2015-02-25 20:11:27 | [diff] [blame] | 765 | return 0; |
| 766 | } |
| 767 | |
| 768 | #endif // OS_LINUX |
| 769 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 770 | } // namespace |