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

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

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years 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/awakable.h ('k') | mojo/edk/system/awakable_list_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/awakable_list.h" 5 #include "mojo/edk/system/awakable_list.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/edk/system/awakable.h" 8 #include "mojo/edk/system/awakable.h"
9 #include "mojo/edk/system/handle_signals_state.h" 9 #include "mojo/edk/system/handle_signals_state.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 namespace system { 12 namespace system {
13 13
14 AwakableList::AwakableList() { 14 AwakableList::AwakableList() {
15 } 15 }
16 16
17 AwakableList::~AwakableList() { 17 AwakableList::~AwakableList() {
18 DCHECK(awakables_.empty()); 18 DCHECK(awakables_.empty());
19 } 19 }
20 20
21 void AwakableList::AwakeForStateChange(const HandleSignalsState& state) { 21 void AwakableList::AwakeForStateChange(const HandleSignalsState& state) {
22 for (AwakeInfoList::iterator it = awakables_.begin(); it != awakables_.end(); 22 for (AwakeInfoList::iterator it = awakables_.begin();
23 ++it) { 23 it != awakables_.end();) {
24 bool keep = true;
24 if (state.satisfies(it->signals)) 25 if (state.satisfies(it->signals))
25 it->awakable->Awake(MOJO_RESULT_OK, it->context); 26 keep = it->awakable->Awake(MOJO_RESULT_OK, it->context);
26 else if (!state.can_satisfy(it->signals)) 27 else if (!state.can_satisfy(it->signals))
27 it->awakable->Awake(MOJO_RESULT_FAILED_PRECONDITION, it->context); 28 keep = it->awakable->Awake(MOJO_RESULT_FAILED_PRECONDITION, it->context);
29 AwakeInfoList::iterator maybe_delete = it;
30 ++it;
31
32 if (!keep)
33 awakables_.erase(maybe_delete);
28 } 34 }
29 } 35 }
30 36
31 void AwakableList::CancelAll() { 37 void AwakableList::CancelAll() {
32 for (AwakeInfoList::iterator it = awakables_.begin(); it != awakables_.end(); 38 for (AwakeInfoList::iterator it = awakables_.begin(); it != awakables_.end();
33 ++it) { 39 ++it) {
34 it->awakable->Awake(MOJO_RESULT_CANCELLED, it->context); 40 it->awakable->Awake(MOJO_RESULT_CANCELLED, it->context);
35 } 41 }
36 awakables_.clear(); 42 awakables_.clear();
37 } 43 }
(...skipping 11 matching lines...) Expand all
49 it != awakables_.end();) { 55 it != awakables_.end();) {
50 AwakeInfoList::iterator maybe_delete = it; 56 AwakeInfoList::iterator maybe_delete = it;
51 ++it; 57 ++it;
52 if (maybe_delete->awakable == awakable) 58 if (maybe_delete->awakable == awakable)
53 awakables_.erase(maybe_delete); 59 awakables_.erase(maybe_delete);
54 } 60 }
55 } 61 }
56 62
57 } // namespace system 63 } // namespace system
58 } // namespace mojo 64 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/awakable.h ('k') | mojo/edk/system/awakable_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698