| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/threading/platform_thread.h" // For |Sleep()|. | 13 #include "base/threading/platform_thread.h" // For |Sleep()|. |
| 14 #include "mojo/common/test/multiprocess_test_helper.h" | 14 #include "mojo/common/test/multiprocess_test_helper.h" |
| 15 #include "mojo/embedder/scoped_platform_handle.h" | 15 #include "mojo/embedder/scoped_platform_handle.h" |
| 16 #include "mojo/system/channel.h" | 16 #include "mojo/system/channel.h" |
| 17 #include "mojo/system/local_message_pipe_endpoint.h" | 17 #include "mojo/system/local_message_pipe_endpoint.h" |
| 18 #include "mojo/system/message_pipe.h" | 18 #include "mojo/system/message_pipe.h" |
| 19 #include "mojo/system/proxy_message_pipe_endpoint.h" | 19 #include "mojo/system/proxy_message_pipe_endpoint.h" |
| 20 #include "mojo/system/raw_channel.h" |
| 20 #include "mojo/system/test_utils.h" | 21 #include "mojo/system/test_utils.h" |
| 21 #include "mojo/system/waiter.h" | 22 #include "mojo/system/waiter.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 24 |
| 24 namespace mojo { | 25 namespace mojo { |
| 25 namespace system { | 26 namespace system { |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 class ChannelThread { | 29 class ChannelThread { |
| 29 public: | 30 public: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 59 } | 60 } |
| 60 | 61 |
| 61 private: | 62 private: |
| 62 void InitChannelOnIOThread(embedder::ScopedPlatformHandle platform_handle, | 63 void InitChannelOnIOThread(embedder::ScopedPlatformHandle platform_handle, |
| 63 scoped_refptr<MessagePipe> message_pipe) { | 64 scoped_refptr<MessagePipe> message_pipe) { |
| 64 CHECK_EQ(base::MessageLoop::current(), test_io_thread_.message_loop()); | 65 CHECK_EQ(base::MessageLoop::current(), test_io_thread_.message_loop()); |
| 65 CHECK(platform_handle.is_valid()); | 66 CHECK(platform_handle.is_valid()); |
| 66 | 67 |
| 67 // Create and initialize |Channel|. | 68 // Create and initialize |Channel|. |
| 68 channel_ = new Channel(); | 69 channel_ = new Channel(); |
| 69 CHECK(channel_->Init(platform_handle.Pass())); | 70 CHECK(channel_->Init(RawChannel::Create(platform_handle.Pass()))); |
| 70 | 71 |
| 71 // Attach the message pipe endpoint. | 72 // Attach the message pipe endpoint. |
| 72 // Note: On the "server" (parent process) side, we need not attach the | 73 // Note: On the "server" (parent process) side, we need not attach the |
| 73 // message pipe endpoint immediately. However, on the "client" (child | 74 // message pipe endpoint immediately. However, on the "client" (child |
| 74 // process) side, this *must* be done here -- otherwise, the |Channel| may | 75 // process) side, this *must* be done here -- otherwise, the |Channel| may |
| 75 // receive/process messages (which it can do as soon as it's hooked up to | 76 // receive/process messages (which it can do as soon as it's hooked up to |
| 76 // the IO thread message loop, and that message loop runs) before the | 77 // the IO thread message loop, and that message loop runs) before the |
| 77 // message pipe endpoint is attached. | 78 // message pipe endpoint is attached. |
| 78 CHECK_EQ(channel_->AttachMessagePipeEndpoint(message_pipe, 1), | 79 CHECK_EQ(channel_->AttachMessagePipeEndpoint(message_pipe, 1), |
| 79 Channel::kBootstrapEndpointId); | 80 Channel::kBootstrapEndpointId); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 268 |
| 268 mp->Close(0); | 269 mp->Close(0); |
| 269 | 270 |
| 270 EXPECT_EQ(static_cast<int>(kNumMessages % 100), | 271 EXPECT_EQ(static_cast<int>(kNumMessages % 100), |
| 271 helper()->WaitForChildShutdown()); | 272 helper()->WaitForChildShutdown()); |
| 272 } | 273 } |
| 273 | 274 |
| 274 } // namespace | 275 } // namespace |
| 275 } // namespace system | 276 } // namespace system |
| 276 } // namespace mojo | 277 } // namespace mojo |
| OLD | NEW |