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

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

Issue 262093003: Mojo: Add/use |typedef std::vector<scoped_refptr<Dispatcher> > DispatcherVector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « mojo/system/message_pipe.h ('k') | mojo/system/message_pipe_dispatcher.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" 8 #include "mojo/system/channel.h"
9 #include "mojo/system/local_message_pipe_endpoint.h" 9 #include "mojo/system/local_message_pipe_endpoint.h"
10 #include "mojo/system/message_in_transit.h" 10 #include "mojo/system/message_in_transit.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return EnqueueMessageInternal( 75 return EnqueueMessageInternal(
76 GetPeerPort(port), 76 GetPeerPort(port),
77 make_scoped_ptr(new MessageInTransit( 77 make_scoped_ptr(new MessageInTransit(
78 MessageInTransit::kTypeMessagePipeEndpoint, 78 MessageInTransit::kTypeMessagePipeEndpoint,
79 MessageInTransit::kSubtypeMessagePipeEndpointData, 79 MessageInTransit::kSubtypeMessagePipeEndpointData,
80 num_bytes, 80 num_bytes,
81 bytes)), 81 bytes)),
82 transports); 82 transports);
83 } 83 }
84 84
85 MojoResult MessagePipe::ReadMessage( 85 MojoResult MessagePipe::ReadMessage(unsigned port,
86 unsigned port, 86 void* bytes,
87 void* bytes, 87 uint32_t* num_bytes,
88 uint32_t* num_bytes, 88 DispatcherVector* dispatchers,
89 std::vector<scoped_refptr<Dispatcher> >* dispatchers, 89 uint32_t* num_dispatchers,
90 uint32_t* num_dispatchers, 90 MojoReadMessageFlags flags) {
91 MojoReadMessageFlags flags) {
92 DCHECK(port == 0 || port == 1); 91 DCHECK(port == 0 || port == 1);
93 92
94 base::AutoLock locker(lock_); 93 base::AutoLock locker(lock_);
95 DCHECK(endpoints_[port].get()); 94 DCHECK(endpoints_[port].get());
96 95
97 return endpoints_[port]->ReadMessage(bytes, num_bytes, dispatchers, 96 return endpoints_[port]->ReadMessage(bytes, num_bytes, dispatchers,
98 num_dispatchers, flags); 97 num_dispatchers, flags);
99 } 98 }
100 99
101 MojoResult MessagePipe::AddWaiter(unsigned port, 100 MojoResult MessagePipe::AddWaiter(unsigned port,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // The other case should have been disallowed by |Core|. (Note: |port| 251 // The other case should have been disallowed by |Core|. (Note: |port|
253 // is the peer port of the handle given to |WriteMessage()|.) 252 // is the peer port of the handle given to |WriteMessage()|.)
254 DCHECK_EQ(mp_transport.GetPort(), port); 253 DCHECK_EQ(mp_transport.GetPort(), port);
255 return MOJO_RESULT_INVALID_ARGUMENT; 254 return MOJO_RESULT_INVALID_ARGUMENT;
256 } 255 }
257 } 256 }
258 } 257 }
259 258
260 // Clone the dispatchers and attach them to the message. (This must be done as 259 // Clone the dispatchers and attach them to the message. (This must be done as
261 // a separate loop, since we want to leave the dispatchers alone on failure.) 260 // a separate loop, since we want to leave the dispatchers alone on failure.)
262 scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > 261 scoped_ptr<DispatcherVector> dispatchers(new DispatcherVector());
263 dispatchers(new std::vector<scoped_refptr<Dispatcher> >());
264 dispatchers->reserve(transports->size()); 262 dispatchers->reserve(transports->size());
265 for (size_t i = 0; i < transports->size(); i++) { 263 for (size_t i = 0; i < transports->size(); i++) {
266 if ((*transports)[i].is_valid()) { 264 if ((*transports)[i].is_valid()) {
267 dispatchers->push_back( 265 dispatchers->push_back(
268 (*transports)[i].CreateEquivalentDispatcherAndClose()); 266 (*transports)[i].CreateEquivalentDispatcherAndClose());
269 } else { 267 } else {
270 LOG(WARNING) << "Enqueueing null dispatcher"; 268 LOG(WARNING) << "Enqueueing null dispatcher";
271 dispatchers->push_back(scoped_refptr<Dispatcher>()); 269 dispatchers->push_back(scoped_refptr<Dispatcher>());
272 } 270 }
273 } 271 }
274 message->SetDispatchers(dispatchers.Pass()); 272 message->SetDispatchers(dispatchers.Pass());
275 return MOJO_RESULT_OK; 273 return MOJO_RESULT_OK;
276 } 274 }
277 275
278 MojoResult MessagePipe::HandleControlMessage( 276 MojoResult MessagePipe::HandleControlMessage(
279 unsigned /*port*/, 277 unsigned /*port*/,
280 scoped_ptr<MessageInTransit> message) { 278 scoped_ptr<MessageInTransit> message) {
281 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " 279 LOG(WARNING) << "Unrecognized MessagePipe control message subtype "
282 << message->subtype(); 280 << message->subtype();
283 return MOJO_RESULT_UNKNOWN; 281 return MOJO_RESULT_UNKNOWN;
284 } 282 }
285 283
286 } // namespace system 284 } // namespace system
287 } // namespace mojo 285 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/message_pipe.h ('k') | mojo/system/message_pipe_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698