| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "mojo/edk/system/message_pipe_test_utils.h" | 5 #include "mojo/edk/system/message_pipe_test_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "mojo/edk/system/channel.h" | 9 #include "mojo/edk/system/channel.h" |
| 10 #include "mojo/edk/system/channel_endpoint.h" | 10 #include "mojo/edk/system/channel_endpoint.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 | 78 |
| 79 void ChannelThread::InitChannelOnIOThread( | 79 void ChannelThread::InitChannelOnIOThread( |
| 80 ScopedPlatformHandle platform_handle, | 80 ScopedPlatformHandle platform_handle, |
| 81 RefPtr<ChannelEndpoint>&& channel_endpoint) { | 81 RefPtr<ChannelEndpoint>&& channel_endpoint) { |
| 82 CHECK(test_io_thread_.IsCurrentAndRunning()); | 82 CHECK(test_io_thread_.IsCurrentAndRunning()); |
| 83 CHECK(platform_handle.is_valid()); | 83 CHECK(platform_handle.is_valid()); |
| 84 | 84 |
| 85 // Create and initialize |Channel|. | 85 // Create and initialize |Channel|. |
| 86 channel_ = MakeRefCounted<Channel>(platform_support_); | 86 channel_ = MakeRefCounted<Channel>(platform_support_); |
| 87 channel_->Init(RawChannel::Create(platform_handle.Pass())); | 87 channel_->Init(test_io_thread_.task_runner().Clone(), |
| 88 test_io_thread_.platform_handle_watcher(), |
| 89 RawChannel::Create(platform_handle.Pass())); |
| 88 | 90 |
| 89 // Start the bootstrap endpoint. | 91 // Start the bootstrap endpoint. |
| 90 // Note: On the "server" (parent process) side, we need not attach/run the | 92 // Note: On the "server" (parent process) side, we need not attach/run the |
| 91 // endpoint immediately. However, on the "client" (child process) side, this | 93 // endpoint immediately. However, on the "client" (child process) side, this |
| 92 // *must* be done here -- otherwise, the |Channel| may receive/process | 94 // *must* be done here -- otherwise, the |Channel| may receive/process |
| 93 // messages (which it can do as soon as it's hooked up to the IO thread | 95 // messages (which it can do as soon as it's hooked up to the IO thread |
| 94 // message loop, and that message loop runs) before the endpoint is attached. | 96 // message loop, and that message loop runs) before the endpoint is attached. |
| 95 channel_->SetBootstrapEndpoint(std::move(channel_endpoint)); | 97 channel_->SetBootstrapEndpoint(std::move(channel_endpoint)); |
| 96 } | 98 } |
| 97 | 99 |
| 98 #if !defined(OS_IOS) | 100 #if !defined(OS_IOS) |
| 99 MultiprocessMessagePipeTestBase::MultiprocessMessagePipeTestBase() | 101 MultiprocessMessagePipeTestBase::MultiprocessMessagePipeTestBase() |
| 100 : channel_thread_(&platform_support_) { | 102 : channel_thread_(&platform_support_) { |
| 101 } | 103 } |
| 102 | 104 |
| 103 MultiprocessMessagePipeTestBase::~MultiprocessMessagePipeTestBase() { | 105 MultiprocessMessagePipeTestBase::~MultiprocessMessagePipeTestBase() { |
| 104 } | 106 } |
| 105 | 107 |
| 106 void MultiprocessMessagePipeTestBase::Init(RefPtr<ChannelEndpoint>&& ep) { | 108 void MultiprocessMessagePipeTestBase::Init(RefPtr<ChannelEndpoint>&& ep) { |
| 107 channel_thread_.Start(helper_.server_platform_handle.Pass(), std::move(ep)); | 109 channel_thread_.Start(helper_.server_platform_handle.Pass(), std::move(ep)); |
| 108 } | 110 } |
| 109 #endif // !defined(OS_IOS) | 111 #endif // !defined(OS_IOS) |
| 110 | 112 |
| 111 } // namespace test | 113 } // namespace test |
| 112 } // namespace system | 114 } // namespace system |
| 113 } // namespace mojo | 115 } // namespace mojo |
| OLD | NEW |