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

Side by Side Diff: ppapi/shared_impl/callback_tracker.cc

Issue 174213003: PPAPI: Use clang-format on ppapi/shared_impl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove DEPS Created 6 years, 10 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 | « ppapi/shared_impl/array_writer.cc ('k') | ppapi/shared_impl/dictionary_var.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "ppapi/shared_impl/callback_tracker.h" 5 #include "ppapi/shared_impl/callback_tracker.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/shared_impl/tracked_callback.h" 14 #include "ppapi/shared_impl/tracked_callback.h"
15 15
16 namespace ppapi { 16 namespace ppapi {
17 17
18 // CallbackTracker ------------------------------------------------------------- 18 // CallbackTracker -------------------------------------------------------------
19 19
20 CallbackTracker::CallbackTracker() { 20 CallbackTracker::CallbackTracker() {}
21 }
22 21
23 void CallbackTracker::AbortAll() { 22 void CallbackTracker::AbortAll() {
24 // Iterate over a copy since |Abort()| calls |Remove()| (indirectly). 23 // Iterate over a copy since |Abort()| calls |Remove()| (indirectly).
25 // TODO(viettrungluu): This obviously isn't so efficient. 24 // TODO(viettrungluu): This obviously isn't so efficient.
26 CallbackSetMap pending_callbacks_copy = pending_callbacks_; 25 CallbackSetMap pending_callbacks_copy = pending_callbacks_;
27 for (CallbackSetMap::iterator it1 = pending_callbacks_copy.begin(); 26 for (CallbackSetMap::iterator it1 = pending_callbacks_copy.begin();
28 it1 != pending_callbacks_copy.end(); ++it1) { 27 it1 != pending_callbacks_copy.end();
28 ++it1) {
29 for (CallbackSet::iterator it2 = it1->second.begin(); 29 for (CallbackSet::iterator it2 = it1->second.begin();
30 it2 != it1->second.end(); ++it2) { 30 it2 != it1->second.end();
31 ++it2) {
31 (*it2)->Abort(); 32 (*it2)->Abort();
32 } 33 }
33 } 34 }
34 } 35 }
35 36
36 void CallbackTracker::PostAbortForResource(PP_Resource resource_id) { 37 void CallbackTracker::PostAbortForResource(PP_Resource resource_id) {
37 CHECK(resource_id != 0); 38 CHECK(resource_id != 0);
38 CallbackSetMap::iterator it1 = pending_callbacks_.find(resource_id); 39 CallbackSetMap::iterator it1 = pending_callbacks_.find(resource_id);
39 if (it1 == pending_callbacks_.end()) 40 if (it1 == pending_callbacks_.end())
40 return; 41 return;
41 for (CallbackSet::iterator it2 = it1->second.begin(); 42 for (CallbackSet::iterator it2 = it1->second.begin();
42 it2 != it1->second.end(); ++it2) { 43 it2 != it1->second.end();
44 ++it2) {
43 // Post the abort. 45 // Post the abort.
44 (*it2)->PostAbort(); 46 (*it2)->PostAbort();
45 } 47 }
46 } 48 }
47 49
48 CallbackTracker::~CallbackTracker() { 50 CallbackTracker::~CallbackTracker() {
49 // All callbacks must be aborted before destruction. 51 // All callbacks must be aborted before destruction.
50 CHECK_EQ(0u, pending_callbacks_.size()); 52 CHECK_EQ(0u, pending_callbacks_.size());
51 } 53 }
52 54
(...skipping 13 matching lines...) Expand all
66 CallbackSet::iterator it = map_it->second.find(tracked_callback); 68 CallbackSet::iterator it = map_it->second.find(tracked_callback);
67 DCHECK(it != map_it->second.end()); 69 DCHECK(it != map_it->second.end());
68 map_it->second.erase(it); 70 map_it->second.erase(it);
69 71
70 // If there are no pending callbacks left for this ID, get rid of the entry. 72 // If there are no pending callbacks left for this ID, get rid of the entry.
71 if (map_it->second.empty()) 73 if (map_it->second.empty())
72 pending_callbacks_.erase(map_it); 74 pending_callbacks_.erase(map_it);
73 } 75 }
74 76
75 } // namespace ppapi 77 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/array_writer.cc ('k') | ppapi/shared_impl/dictionary_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698