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 "mojo/system/message_pipe.h" | 5 #include "mojo/system/message_pipe.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/system/channel_endpoint.h" | 8 #include "mojo/system/channel_endpoint.h" |
9 #include "mojo/system/local_message_pipe_endpoint.h" | 9 #include "mojo/system/local_message_pipe_endpoint.h" |
10 #include "mojo/system/message_in_transit.h" | 10 #include "mojo/system/message_in_transit.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // TODO(vtl): Allowing this case is a temporary hack. It'll set up a | 163 // TODO(vtl): Allowing this case is a temporary hack. It'll set up a |
164 // |MessagePipe| with two proxy endpoints, which will then act as a proxy | 164 // |MessagePipe| with two proxy endpoints, which will then act as a proxy |
165 // (rather than trying to connect the two ends directly). | 165 // (rather than trying to connect the two ends directly). |
166 DLOG_IF(WARNING, | 166 DLOG_IF(WARNING, |
167 is_peer_open && | 167 is_peer_open && |
168 endpoints_[GetPeerPort(port)]->GetType() != | 168 endpoints_[GetPeerPort(port)]->GetType() != |
169 MessagePipeEndpoint::kTypeLocal) | 169 MessagePipeEndpoint::kTypeLocal) |
170 << "Direct message pipe passing across multiple channels not yet " | 170 << "Direct message pipe passing across multiple channels not yet " |
171 "implemented; will proxy"; | 171 "implemented; will proxy"; |
172 | 172 |
| 173 scoped_ptr<MessagePipeEndpoint> old_endpoint(endpoints_[port].Pass()); |
173 scoped_refptr<ChannelEndpoint> channel_endpoint( | 174 scoped_refptr<ChannelEndpoint> channel_endpoint( |
174 new ChannelEndpoint(this, port)); | 175 new ChannelEndpoint(this, port)); |
175 scoped_ptr<MessagePipeEndpoint> replacement_endpoint( | 176 endpoints_[port].reset( |
176 new ProxyMessagePipeEndpoint( | 177 new ProxyMessagePipeEndpoint(channel_endpoint.get(), is_peer_open)); |
177 channel_endpoint.get(), | 178 channel_endpoint->TakeMessages(static_cast<LocalMessagePipeEndpoint*>( |
178 static_cast<LocalMessagePipeEndpoint*>(endpoints_[port].get()), | 179 old_endpoint.get())->message_queue()); |
179 is_peer_open)); | 180 old_endpoint->Close(); |
180 endpoints_[port].swap(replacement_endpoint); | |
181 | 181 |
182 return channel_endpoint; | 182 return channel_endpoint; |
183 } | 183 } |
184 | 184 |
185 MojoResult MessagePipe::EnqueueMessage(unsigned port, | 185 MojoResult MessagePipe::EnqueueMessage(unsigned port, |
186 scoped_ptr<MessageInTransit> message) { | 186 scoped_ptr<MessageInTransit> message) { |
187 return EnqueueMessageInternal(port, message.Pass(), nullptr); | 187 return EnqueueMessageInternal(port, message.Pass(), nullptr); |
188 } | 188 } |
189 | 189 |
190 bool MessagePipe::Attach(unsigned port, ChannelEndpoint* channel_endpoint) { | 190 bool MessagePipe::Attach(unsigned port, ChannelEndpoint* channel_endpoint) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 MojoResult MessagePipe::HandleControlMessage( | 314 MojoResult MessagePipe::HandleControlMessage( |
315 unsigned /*port*/, | 315 unsigned /*port*/, |
316 scoped_ptr<MessageInTransit> message) { | 316 scoped_ptr<MessageInTransit> message) { |
317 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " | 317 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " |
318 << message->subtype(); | 318 << message->subtype(); |
319 return MOJO_RESULT_UNKNOWN; | 319 return MOJO_RESULT_UNKNOWN; |
320 } | 320 } |
321 | 321 |
322 } // namespace system | 322 } // namespace system |
323 } // namespace mojo | 323 } // namespace mojo |
OLD | NEW |