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_dispatcher.h" | 5 #include "mojo/system/message_pipe_dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/system/channel.h" | 8 #include "mojo/system/channel.h" |
9 #include "mojo/system/channel_endpoint.h" | 9 #include "mojo/system/channel_endpoint.h" |
10 #include "mojo/system/constants.h" | 10 #include "mojo/system/constants.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 *max_platform_handles = 0; | 240 *max_platform_handles = 0; |
241 } | 241 } |
242 | 242 |
243 bool MessagePipeDispatcher::EndSerializeAndCloseImplNoLock( | 243 bool MessagePipeDispatcher::EndSerializeAndCloseImplNoLock( |
244 Channel* channel, | 244 Channel* channel, |
245 void* destination, | 245 void* destination, |
246 size_t* actual_size, | 246 size_t* actual_size, |
247 embedder::PlatformHandleVector* /*platform_handles*/) { | 247 embedder::PlatformHandleVector* /*platform_handles*/) { |
248 DCHECK(HasOneRef()); // Only one ref => no need to take the lock. | 248 DCHECK(HasOneRef()); // Only one ref => no need to take the lock. |
249 | 249 |
250 // Convert the local endpoint to a proxy endpoint (moving the message queue). | 250 // Convert the local endpoint to a proxy endpoint (moving the message queue) |
251 message_pipe_->ConvertLocalToProxy(port_); | 251 // and attach it to the channel. |
252 | 252 MessageInTransit::EndpointId endpoint_id = |
253 // Attach the new proxy endpoint to the channel. | 253 channel->AttachEndpoint(message_pipe_->ConvertLocalToProxy(port_)); |
254 MessageInTransit::EndpointId endpoint_id = channel->AttachEndpoint( | |
255 make_scoped_refptr(new ChannelEndpoint(message_pipe_.get(), port_))); | |
256 // Note: It's okay to get an endpoint ID of |kInvalidEndpointId|. (It's | 254 // Note: It's okay to get an endpoint ID of |kInvalidEndpointId|. (It's |
257 // possible that the other endpoint -- the one that we're not sending -- was | 255 // possible that the other endpoint -- the one that we're not sending -- was |
258 // closed in the intervening time.) In that case, we need to deserialize a | 256 // closed in the intervening time.) In that case, we need to deserialize a |
259 // "dead" message pipe dispatcher on the other end. (Note that this is | 257 // "dead" message pipe dispatcher on the other end. (Note that this is |
260 // different from just producing |MOJO_HANDLE_INVALID|.) | 258 // different from just producing |MOJO_HANDLE_INVALID|.) |
261 DVLOG(2) << "Serializing message pipe dispatcher (local ID = " << endpoint_id | 259 DVLOG(2) << "Serializing message pipe dispatcher (local ID = " << endpoint_id |
262 << ")"; | 260 << ")"; |
263 | 261 |
264 // We now have a local ID. Before we can run the proxy endpoint, we need to | 262 // We now have a local ID. Before we can run the proxy endpoint, we need to |
265 // get an ack back from the other side with the remote ID. | 263 // get an ack back from the other side with the remote ID. |
(...skipping 10 matching lines...) Expand all Loading... |
276 // MessagePipeDispatcherTransport ---------------------------------------------- | 274 // MessagePipeDispatcherTransport ---------------------------------------------- |
277 | 275 |
278 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( | 276 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( |
279 DispatcherTransport transport) | 277 DispatcherTransport transport) |
280 : DispatcherTransport(transport) { | 278 : DispatcherTransport(transport) { |
281 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); | 279 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); |
282 } | 280 } |
283 | 281 |
284 } // namespace system | 282 } // namespace system |
285 } // namespace mojo | 283 } // namespace mojo |
OLD | NEW |