Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: mojo/system/message_pipe_dispatcher.cc

Issue 591573002: Mojo: Remove Channel::AttachMessagePipeEndpoint(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/system/channel_unittest.cc ('k') | mojo/system/message_pipe_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/constants.h" 10 #include "mojo/system/constants.h"
10 #include "mojo/system/local_message_pipe_endpoint.h" 11 #include "mojo/system/local_message_pipe_endpoint.h"
11 #include "mojo/system/memory.h" 12 #include "mojo/system/memory.h"
12 #include "mojo/system/message_in_transit.h" 13 #include "mojo/system/message_in_transit.h"
13 #include "mojo/system/message_pipe.h" 14 #include "mojo/system/message_pipe.h"
14 #include "mojo/system/options_validation.h" 15 #include "mojo/system/options_validation.h"
15 #include "mojo/system/proxy_message_pipe_endpoint.h" 16 #include "mojo/system/proxy_message_pipe_endpoint.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace system { 19 namespace system {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 static_cast<const SerializedMessagePipeDispatcher*>(source)->endpoint_id; 110 static_cast<const SerializedMessagePipeDispatcher*>(source)->endpoint_id;
110 if (remote_id == MessageInTransit::kInvalidEndpointId) { 111 if (remote_id == MessageInTransit::kInvalidEndpointId) {
111 // This means that the other end was closed, and there were no messages 112 // This means that the other end was closed, and there were no messages
112 // enqueued for us. 113 // enqueued for us.
113 // TODO(vtl): This is wrong. We should produce a "dead" message pipe 114 // TODO(vtl): This is wrong. We should produce a "dead" message pipe
114 // dispatcher. 115 // dispatcher.
115 NOTIMPLEMENTED(); 116 NOTIMPLEMENTED();
116 return scoped_refptr<MessagePipeDispatcher>(); 117 return scoped_refptr<MessagePipeDispatcher>();
117 } 118 }
118 MessageInTransit::EndpointId local_id = 119 MessageInTransit::EndpointId local_id =
119 channel->AttachMessagePipeEndpoint(remote_message_pipe.second, 1); 120 channel->AttachEndpoint(make_scoped_refptr(
121 new ChannelEndpoint(remote_message_pipe.second.get(), 1)));
120 if (local_id == MessageInTransit::kInvalidEndpointId) { 122 if (local_id == MessageInTransit::kInvalidEndpointId) {
121 LOG(ERROR) << "Failed to deserialize message pipe dispatcher (failed to " 123 LOG(ERROR) << "Failed to deserialize message pipe dispatcher (failed to "
122 "attach; remote ID = " << remote_id << ")"; 124 "attach; remote ID = " << remote_id << ")";
123 return scoped_refptr<MessagePipeDispatcher>(); 125 return scoped_refptr<MessagePipeDispatcher>();
124 } 126 }
125 DVLOG(2) << "Deserializing message pipe dispatcher (remote ID = " << remote_id 127 DVLOG(2) << "Deserializing message pipe dispatcher (remote ID = " << remote_id
126 << ", new local ID = " << local_id << ")"; 128 << ", new local ID = " << local_id << ")";
127 129
128 if (!channel->RunMessagePipeEndpoint(local_id, remote_id)) { 130 if (!channel->RunMessagePipeEndpoint(local_id, remote_id)) {
129 // In general, this shouldn't fail, since we generated |local_id| locally. 131 // In general, this shouldn't fail, since we generated |local_id| locally.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 Channel* channel, 244 Channel* channel,
243 void* destination, 245 void* destination,
244 size_t* actual_size, 246 size_t* actual_size,
245 embedder::PlatformHandleVector* /*platform_handles*/) { 247 embedder::PlatformHandleVector* /*platform_handles*/) {
246 DCHECK(HasOneRef()); // Only one ref => no need to take the lock. 248 DCHECK(HasOneRef()); // Only one ref => no need to take the lock.
247 249
248 // 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).
249 message_pipe_->ConvertLocalToProxy(port_); 251 message_pipe_->ConvertLocalToProxy(port_);
250 252
251 // Attach the new proxy endpoint to the channel. 253 // Attach the new proxy endpoint to the channel.
252 MessageInTransit::EndpointId endpoint_id = 254 MessageInTransit::EndpointId endpoint_id = channel->AttachEndpoint(
253 channel->AttachMessagePipeEndpoint(message_pipe_, port_); 255 make_scoped_refptr(new ChannelEndpoint(message_pipe_.get(), port_)));
254 // Note: It's okay to get an endpoint ID of |kInvalidEndpointId|. (It's 256 // Note: It's okay to get an endpoint ID of |kInvalidEndpointId|. (It's
255 // possible that the other endpoint -- the one that we're not sending -- was 257 // possible that the other endpoint -- the one that we're not sending -- was
256 // closed in the intervening time.) In that case, we need to deserialize a 258 // closed in the intervening time.) In that case, we need to deserialize a
257 // "dead" message pipe dispatcher on the other end. (Note that this is 259 // "dead" message pipe dispatcher on the other end. (Note that this is
258 // different from just producing |MOJO_HANDLE_INVALID|.) 260 // different from just producing |MOJO_HANDLE_INVALID|.)
259 DVLOG(2) << "Serializing message pipe dispatcher (local ID = " << endpoint_id 261 DVLOG(2) << "Serializing message pipe dispatcher (local ID = " << endpoint_id
260 << ")"; 262 << ")";
261 263
262 // We now have a local ID. Before we can run the proxy endpoint, we need to 264 // We now have a local ID. Before we can run the proxy endpoint, we need to
263 // get an ack back from the other side with the remote ID. 265 // get an ack back from the other side with the remote ID.
(...skipping 10 matching lines...) Expand all
274 // MessagePipeDispatcherTransport ---------------------------------------------- 276 // MessagePipeDispatcherTransport ----------------------------------------------
275 277
276 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( 278 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport(
277 DispatcherTransport transport) 279 DispatcherTransport transport)
278 : DispatcherTransport(transport) { 280 : DispatcherTransport(transport) {
279 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); 281 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe);
280 } 282 }
281 283
282 } // namespace system 284 } // namespace system
283 } // namespace mojo 285 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/channel_unittest.cc ('k') | mojo/system/message_pipe_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698