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

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

Issue 577313002: Mojo: Give ChannelEndpoint the remote ID and ProxyMessagePipeEndpoint the ChannelEndpoint. (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/message_pipe.h ('k') | mojo/system/message_pipe_endpoint.h » ('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.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.h"
9 #include "mojo/system/local_message_pipe_endpoint.h" 8 #include "mojo/system/local_message_pipe_endpoint.h"
10 #include "mojo/system/message_in_transit.h" 9 #include "mojo/system/message_in_transit.h"
11 #include "mojo/system/message_pipe_dispatcher.h" 10 #include "mojo/system/message_pipe_dispatcher.h"
12 #include "mojo/system/message_pipe_endpoint.h" 11 #include "mojo/system/message_pipe_endpoint.h"
13 #include "mojo/system/proxy_message_pipe_endpoint.h" 12 #include "mojo/system/proxy_message_pipe_endpoint.h"
14 13
15 namespace mojo { 14 namespace mojo {
16 namespace system { 15 namespace system {
17 16
18 MessagePipe::MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0, 17 MessagePipe::MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 is_peer_open)); 170 is_peer_open));
172 endpoints_[port].swap(replacement_endpoint); 171 endpoints_[port].swap(replacement_endpoint);
173 } 172 }
174 173
175 MojoResult MessagePipe::EnqueueMessage(unsigned port, 174 MojoResult MessagePipe::EnqueueMessage(unsigned port,
176 scoped_ptr<MessageInTransit> message) { 175 scoped_ptr<MessageInTransit> message) {
177 return EnqueueMessageInternal(port, message.Pass(), NULL); 176 return EnqueueMessageInternal(port, message.Pass(), NULL);
178 } 177 }
179 178
180 bool MessagePipe::Attach(unsigned port, 179 bool MessagePipe::Attach(unsigned port,
181 scoped_refptr<Channel> channel, 180 ChannelEndpoint* channel_endpoint,
181 Channel* channel,
182 MessageInTransit::EndpointId local_id) { 182 MessageInTransit::EndpointId local_id) {
183 DCHECK(port == 0 || port == 1); 183 DCHECK(port == 0 || port == 1);
184 DCHECK(channel.get()); 184 DCHECK(channel_endpoint);
185 DCHECK(channel);
185 DCHECK_NE(local_id, MessageInTransit::kInvalidEndpointId); 186 DCHECK_NE(local_id, MessageInTransit::kInvalidEndpointId);
186 187
187 base::AutoLock locker(lock_); 188 base::AutoLock locker(lock_);
188 if (!endpoints_[port]) 189 if (!endpoints_[port])
189 return false; 190 return false;
190 191
191 DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeProxy); 192 DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeProxy);
192 endpoints_[port]->Attach(channel, local_id); 193 endpoints_[port]->Attach(channel_endpoint, channel, local_id);
193 return true; 194 return true;
194 } 195 }
195 196
196 void MessagePipe::Run(unsigned port, MessageInTransit::EndpointId remote_id) { 197 void MessagePipe::Run(unsigned port, MessageInTransit::EndpointId remote_id) {
197 DCHECK(port == 0 || port == 1); 198 DCHECK(port == 0 || port == 1);
198 DCHECK_NE(remote_id, MessageInTransit::kInvalidEndpointId); 199 DCHECK_NE(remote_id, MessageInTransit::kInvalidEndpointId);
199 200
200 base::AutoLock locker(lock_); 201 base::AutoLock locker(lock_);
201 DCHECK(endpoints_[port]); 202 DCHECK(endpoints_[port]);
202 if (!endpoints_[port]->Run(remote_id)) 203 if (!endpoints_[port]->Run(remote_id))
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 MojoResult MessagePipe::HandleControlMessage( 307 MojoResult MessagePipe::HandleControlMessage(
307 unsigned /*port*/, 308 unsigned /*port*/,
308 scoped_ptr<MessageInTransit> message) { 309 scoped_ptr<MessageInTransit> message) {
309 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " 310 LOG(WARNING) << "Unrecognized MessagePipe control message subtype "
310 << message->subtype(); 311 << message->subtype();
311 return MOJO_RESULT_UNKNOWN; 312 return MOJO_RESULT_UNKNOWN;
312 } 313 }
313 314
314 } // namespace system 315 } // namespace system
315 } // namespace mojo 316 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/message_pipe.h ('k') | mojo/system/message_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698