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

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

Issue 694923002: Update mojo sdk to rev 91d94d6993c9b0c4135a95687a7d541ce90629b (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/edk/system/channel_endpoint.cc ('k') | mojo/edk/system/remote_message_pipe_unittest.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/edk/system/message_pipe.h" 5 #include "mojo/edk/system/message_pipe.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/edk/system/channel_endpoint.h" 8 #include "mojo/edk/system/channel_endpoint.h"
9 #include "mojo/edk/system/local_message_pipe_endpoint.h" 9 #include "mojo/edk/system/local_message_pipe_endpoint.h"
10 #include "mojo/edk/system/message_in_transit.h" 10 #include "mojo/edk/system/message_in_transit.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 endpoints_[port]->RemoveWaiter(waiter, signals_state); 154 endpoints_[port]->RemoveWaiter(waiter, signals_state);
155 } 155 }
156 156
157 scoped_refptr<ChannelEndpoint> MessagePipe::ConvertLocalToProxy(unsigned port) { 157 scoped_refptr<ChannelEndpoint> MessagePipe::ConvertLocalToProxy(unsigned port) {
158 DCHECK(port == 0 || port == 1); 158 DCHECK(port == 0 || port == 1);
159 159
160 base::AutoLock locker(lock_); 160 base::AutoLock locker(lock_);
161 DCHECK(endpoints_[port]); 161 DCHECK(endpoints_[port]);
162 DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeLocal); 162 DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeLocal);
163 163
164 // The local peer is already closed, so just make a |ChannelEndpoint| that'll
165 // send the already-queued messages.
166 if (!endpoints_[GetPeerPort(port)]) {
167 scoped_refptr<ChannelEndpoint> channel_endpoint(new ChannelEndpoint(
168 nullptr,
169 0,
170 static_cast<LocalMessagePipeEndpoint*>(endpoints_[port].get())
171 ->message_queue()));
172 endpoints_[port]->Close();
173 endpoints_[port].reset();
174 return channel_endpoint;
175 }
176
164 // TODO(vtl): Allowing this case is a temporary hack. It'll set up a 177 // TODO(vtl): Allowing this case is a temporary hack. It'll set up a
165 // |MessagePipe| with two proxy endpoints, which will then act as a proxy 178 // |MessagePipe| with two proxy endpoints, which will then act as a proxy
166 // (rather than trying to connect the two ends directly). 179 // (rather than trying to connect the two ends directly).
167 DLOG_IF(WARNING, 180 DLOG_IF(WARNING,
168 !!endpoints_[GetPeerPort(port)] && 181 endpoints_[GetPeerPort(port)]->GetType() !=
169 endpoints_[GetPeerPort(port)]->GetType() != 182 MessagePipeEndpoint::kTypeLocal)
170 MessagePipeEndpoint::kTypeLocal)
171 << "Direct message pipe passing across multiple channels not yet " 183 << "Direct message pipe passing across multiple channels not yet "
172 "implemented; will proxy"; 184 "implemented; will proxy";
173 185
174 scoped_ptr<MessagePipeEndpoint> old_endpoint(endpoints_[port].Pass()); 186 scoped_ptr<MessagePipeEndpoint> old_endpoint(endpoints_[port].Pass());
175 scoped_refptr<ChannelEndpoint> channel_endpoint( 187 scoped_refptr<ChannelEndpoint> channel_endpoint(new ChannelEndpoint(
176 new ChannelEndpoint(this, port)); 188 this,
189 port,
190 static_cast<LocalMessagePipeEndpoint*>(old_endpoint.get())
191 ->message_queue()));
177 endpoints_[port].reset(new ProxyMessagePipeEndpoint(channel_endpoint.get())); 192 endpoints_[port].reset(new ProxyMessagePipeEndpoint(channel_endpoint.get()));
178 channel_endpoint->TakeMessages(static_cast<LocalMessagePipeEndpoint*>(
179 old_endpoint.get())->message_queue());
180 old_endpoint->Close(); 193 old_endpoint->Close();
181 194
182 return channel_endpoint; 195 return channel_endpoint;
183 } 196 }
184 197
185 MojoResult MessagePipe::EnqueueMessage(unsigned port, 198 MojoResult MessagePipe::EnqueueMessage(unsigned port,
186 scoped_ptr<MessageInTransit> message) { 199 scoped_ptr<MessageInTransit> message) {
187 return EnqueueMessageInternal(port, message.Pass(), nullptr); 200 return EnqueueMessageInternal(port, message.Pass(), nullptr);
188 } 201 }
189 202
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 MojoResult MessagePipe::HandleControlMessage( 290 MojoResult MessagePipe::HandleControlMessage(
278 unsigned /*port*/, 291 unsigned /*port*/,
279 scoped_ptr<MessageInTransit> message) { 292 scoped_ptr<MessageInTransit> message) {
280 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " 293 LOG(WARNING) << "Unrecognized MessagePipe control message subtype "
281 << message->subtype(); 294 << message->subtype();
282 return MOJO_RESULT_UNKNOWN; 295 return MOJO_RESULT_UNKNOWN;
283 } 296 }
284 297
285 } // namespace system 298 } // namespace system
286 } // namespace mojo 299 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_endpoint.cc ('k') | mojo/edk/system/remote_message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698