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

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

Issue 580123004: Mojo: Remove knowledge of Channel, etc. from ProxyMessagePipeEndpoint. (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/local_message_pipe_endpoint.h" 8 #include "mojo/system/local_message_pipe_endpoint.h"
9 #include "mojo/system/message_in_transit.h" 9 #include "mojo/system/message_in_transit.h"
10 #include "mojo/system/message_pipe_dispatcher.h" 10 #include "mojo/system/message_pipe_dispatcher.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 static_cast<LocalMessagePipeEndpoint*>(endpoints_[port].get()), 169 static_cast<LocalMessagePipeEndpoint*>(endpoints_[port].get()),
170 is_peer_open)); 170 is_peer_open));
171 endpoints_[port].swap(replacement_endpoint); 171 endpoints_[port].swap(replacement_endpoint);
172 } 172 }
173 173
174 MojoResult MessagePipe::EnqueueMessage(unsigned port, 174 MojoResult MessagePipe::EnqueueMessage(unsigned port,
175 scoped_ptr<MessageInTransit> message) { 175 scoped_ptr<MessageInTransit> message) {
176 return EnqueueMessageInternal(port, message.Pass(), NULL); 176 return EnqueueMessageInternal(port, message.Pass(), NULL);
177 } 177 }
178 178
179 bool MessagePipe::Attach(unsigned port, 179 bool MessagePipe::Attach(unsigned port, ChannelEndpoint* channel_endpoint) {
180 ChannelEndpoint* channel_endpoint,
181 Channel* channel,
182 MessageInTransit::EndpointId local_id) {
183 DCHECK(port == 0 || port == 1); 180 DCHECK(port == 0 || port == 1);
184 DCHECK(channel_endpoint); 181 DCHECK(channel_endpoint);
185 DCHECK(channel);
186 DCHECK_NE(local_id, MessageInTransit::kInvalidEndpointId);
187 182
188 base::AutoLock locker(lock_); 183 base::AutoLock locker(lock_);
189 if (!endpoints_[port]) 184 if (!endpoints_[port])
190 return false; 185 return false;
191 186
192 DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeProxy); 187 DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeProxy);
193 endpoints_[port]->Attach(channel_endpoint, channel, local_id); 188 endpoints_[port]->Attach(channel_endpoint);
194 return true; 189 return true;
195 } 190 }
196 191
197 void MessagePipe::Run(unsigned port, MessageInTransit::EndpointId remote_id) { 192 void MessagePipe::Run(unsigned port) {
198 DCHECK(port == 0 || port == 1); 193 DCHECK(port == 0 || port == 1);
199 DCHECK_NE(remote_id, MessageInTransit::kInvalidEndpointId);
200 194
201 base::AutoLock locker(lock_); 195 base::AutoLock locker(lock_);
202 DCHECK(endpoints_[port]); 196 DCHECK(endpoints_[port]);
203 if (!endpoints_[port]->Run(remote_id)) 197 if (!endpoints_[port]->Run())
204 endpoints_[port].reset(); 198 endpoints_[port].reset();
205 } 199 }
206 200
207 void MessagePipe::OnRemove(unsigned port) { 201 void MessagePipe::OnRemove(unsigned port) {
208 unsigned destination_port = GetPeerPort(port); 202 unsigned destination_port = GetPeerPort(port);
209 203
210 base::AutoLock locker(lock_); 204 base::AutoLock locker(lock_);
211 // A |OnPeerClose()| can come in first, before |OnRemove()| gets called. 205 // A |OnPeerClose()| can come in first, before |OnRemove()| gets called.
212 if (!endpoints_[port]) 206 if (!endpoints_[port])
213 return; 207 return;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 MojoResult MessagePipe::HandleControlMessage( 301 MojoResult MessagePipe::HandleControlMessage(
308 unsigned /*port*/, 302 unsigned /*port*/,
309 scoped_ptr<MessageInTransit> message) { 303 scoped_ptr<MessageInTransit> message) {
310 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " 304 LOG(WARNING) << "Unrecognized MessagePipe control message subtype "
311 << message->subtype(); 305 << message->subtype();
312 return MOJO_RESULT_UNKNOWN; 306 return MOJO_RESULT_UNKNOWN;
313 } 307 }
314 308
315 } // namespace system 309 } // namespace system
316 } // namespace mojo 310 } // 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