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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/threading/platform_thread.h" // For |Sleep()|. | 8 #include "base/threading/platform_thread.h" // For |Sleep()|. |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void ChannelThread::InitChannelOnIOThread( | 69 void ChannelThread::InitChannelOnIOThread( |
70 embedder::ScopedPlatformHandle platform_handle, | 70 embedder::ScopedPlatformHandle platform_handle, |
71 scoped_refptr<ChannelEndpoint> channel_endpoint) { | 71 scoped_refptr<ChannelEndpoint> channel_endpoint) { |
72 CHECK_EQ(base::MessageLoop::current(), test_io_thread_.message_loop()); | 72 CHECK_EQ(base::MessageLoop::current(), test_io_thread_.message_loop()); |
73 CHECK(platform_handle.is_valid()); | 73 CHECK(platform_handle.is_valid()); |
74 | 74 |
75 // Create and initialize |Channel|. | 75 // Create and initialize |Channel|. |
76 channel_ = new Channel(platform_support_); | 76 channel_ = new Channel(platform_support_); |
77 CHECK(channel_->Init(RawChannel::Create(platform_handle.Pass()))); | 77 CHECK(channel_->Init(RawChannel::Create(platform_handle.Pass()))); |
78 | 78 |
79 // Attach and run the endpoint. | 79 // Start the bootstrap endpoint. |
80 // Note: On the "server" (parent process) side, we need not attach/run the | 80 // Note: On the "server" (parent process) side, we need not attach/run the |
81 // endpoint immediately. However, on the "client" (child process) side, this | 81 // endpoint immediately. However, on the "client" (child process) side, this |
82 // *must* be done here -- otherwise, the |Channel| may receive/process | 82 // *must* be done here -- otherwise, the |Channel| may receive/process |
83 // messages (which it can do as soon as it's hooked up to the IO thread | 83 // messages (which it can do as soon as it's hooked up to the IO thread |
84 // message loop, and that message loop runs) before the endpoint is attached. | 84 // message loop, and that message loop runs) before the endpoint is attached. |
85 channel_->AttachAndRunEndpoint(channel_endpoint, true); | 85 channel_->SetBootstrapEndpoint(channel_endpoint); |
86 } | 86 } |
87 | 87 |
88 void ChannelThread::ShutdownChannelOnIOThread() { | 88 void ChannelThread::ShutdownChannelOnIOThread() { |
89 CHECK(channel_); | 89 CHECK(channel_); |
90 channel_->Shutdown(); | 90 channel_->Shutdown(); |
91 channel_ = nullptr; | 91 channel_ = nullptr; |
92 } | 92 } |
93 | 93 |
94 #if !defined(OS_IOS) | 94 #if !defined(OS_IOS) |
95 MultiprocessMessagePipeTestBase::MultiprocessMessagePipeTestBase() | 95 MultiprocessMessagePipeTestBase::MultiprocessMessagePipeTestBase() |
96 : channel_thread_(&platform_support_) { | 96 : channel_thread_(&platform_support_) { |
97 } | 97 } |
98 | 98 |
99 MultiprocessMessagePipeTestBase::~MultiprocessMessagePipeTestBase() { | 99 MultiprocessMessagePipeTestBase::~MultiprocessMessagePipeTestBase() { |
100 } | 100 } |
101 | 101 |
102 void MultiprocessMessagePipeTestBase::Init(scoped_refptr<ChannelEndpoint> ep) { | 102 void MultiprocessMessagePipeTestBase::Init(scoped_refptr<ChannelEndpoint> ep) { |
103 channel_thread_.Start(helper_.server_platform_handle.Pass(), ep); | 103 channel_thread_.Start(helper_.server_platform_handle.Pass(), ep); |
104 } | 104 } |
105 #endif | 105 #endif |
106 | 106 |
107 } // namespace test | 107 } // namespace test |
108 } // namespace system | 108 } // namespace system |
109 } // namespace mojo | 109 } // namespace mojo |
OLD | NEW |