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

Side by Side Diff: mojo/system/core.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 | « no previous file | mojo/system/core_test_base.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/core.h" 5 #include "mojo/system/core.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 if (!VerifyUserPointer<uint32_t>(num_handles, 1)) 262 if (!VerifyUserPointer<uint32_t>(num_handles, 1))
263 return MOJO_RESULT_INVALID_ARGUMENT; 263 return MOJO_RESULT_INVALID_ARGUMENT;
264 if (!VerifyUserPointer<MojoHandle>(handles, *num_handles)) 264 if (!VerifyUserPointer<MojoHandle>(handles, *num_handles))
265 return MOJO_RESULT_INVALID_ARGUMENT; 265 return MOJO_RESULT_INVALID_ARGUMENT;
266 } 266 }
267 267
268 // Easy case: won't receive any handles. 268 // Easy case: won't receive any handles.
269 if (!num_handles || *num_handles == 0) 269 if (!num_handles || *num_handles == 0)
270 return dispatcher->ReadMessage(bytes, num_bytes, NULL, num_handles, flags); 270 return dispatcher->ReadMessage(bytes, num_bytes, NULL, num_handles, flags);
271 271
272 std::vector<scoped_refptr<Dispatcher> > dispatchers; 272 DispatcherVector dispatchers;
273 MojoResult rv = dispatcher->ReadMessage(bytes, num_bytes, 273 MojoResult rv = dispatcher->ReadMessage(bytes, num_bytes,
274 &dispatchers, num_handles, 274 &dispatchers, num_handles,
275 flags); 275 flags);
276 if (!dispatchers.empty()) { 276 if (!dispatchers.empty()) {
277 DCHECK_EQ(rv, MOJO_RESULT_OK); 277 DCHECK_EQ(rv, MOJO_RESULT_OK);
278 DCHECK(num_handles); 278 DCHECK(num_handles);
279 DCHECK_LE(dispatchers.size(), static_cast<size_t>(*num_handles)); 279 DCHECK_LE(dispatchers.size(), static_cast<size_t>(*num_handles));
280 280
281 bool success; 281 bool success;
282 { 282 {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // Note: We allow |handles| to repeat the same handle multiple times, since 530 // Note: We allow |handles| to repeat the same handle multiple times, since
531 // different flags may be specified. 531 // different flags may be specified.
532 // TODO(vtl): This incurs a performance cost in |RemoveWaiter()|. Analyze this 532 // TODO(vtl): This incurs a performance cost in |RemoveWaiter()|. Analyze this
533 // more carefully and address it if necessary. 533 // more carefully and address it if necessary.
534 MojoResult Core::WaitManyInternal(const MojoHandle* handles, 534 MojoResult Core::WaitManyInternal(const MojoHandle* handles,
535 const MojoWaitFlags* flags, 535 const MojoWaitFlags* flags,
536 uint32_t num_handles, 536 uint32_t num_handles,
537 MojoDeadline deadline) { 537 MojoDeadline deadline) {
538 DCHECK_GT(num_handles, 0u); 538 DCHECK_GT(num_handles, 0u);
539 539
540 std::vector<scoped_refptr<Dispatcher> > dispatchers; 540 DispatcherVector dispatchers;
541 dispatchers.reserve(num_handles); 541 dispatchers.reserve(num_handles);
542 for (uint32_t i = 0; i < num_handles; i++) { 542 for (uint32_t i = 0; i < num_handles; i++) {
543 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handles[i]); 543 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handles[i]);
544 if (!dispatcher.get()) 544 if (!dispatcher.get())
545 return MOJO_RESULT_INVALID_ARGUMENT; 545 return MOJO_RESULT_INVALID_ARGUMENT;
546 dispatchers.push_back(dispatcher); 546 dispatchers.push_back(dispatcher);
547 } 547 }
548 548
549 // TODO(vtl): Should make the waiter live (permanently) in TLS. 549 // TODO(vtl): Should make the waiter live (permanently) in TLS.
550 Waiter waiter; 550 Waiter waiter;
(...skipping 19 matching lines...) Expand all
570 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be 570 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be
571 // destroyed, but this would still be required if the waiter were in TLS.) 571 // destroyed, but this would still be required if the waiter were in TLS.)
572 for (i = 0; i < num_added; i++) 572 for (i = 0; i < num_added; i++)
573 dispatchers[i]->RemoveWaiter(&waiter); 573 dispatchers[i]->RemoveWaiter(&waiter);
574 574
575 return rv; 575 return rv;
576 } 576 }
577 577
578 } // namespace system 578 } // namespace system
579 } // namespace mojo 579 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/system/core_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698