| OLD | NEW |
| 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/proxy_lock.h" | 14 #include "ppapi/shared_impl/proxy_lock.h" |
| 15 #include "ppapi/shared_impl/tracked_callback.h" | 15 #include "ppapi/shared_impl/tracked_callback.h" |
| 16 | 16 |
| 17 namespace ppapi { | 17 namespace ppapi { |
| 18 | 18 |
| 19 // CallbackTracker ------------------------------------------------------------- | 19 // CallbackTracker ------------------------------------------------------------- |
| 20 | 20 |
| 21 CallbackTracker::CallbackTracker() : abort_all_called_(false) { | 21 CallbackTracker::CallbackTracker() : abort_all_called_(false) {} |
| 22 } | |
| 23 | 22 |
| 24 void CallbackTracker::AbortAll() { | 23 void CallbackTracker::AbortAll() { |
| 25 // Iterate over a copy: | 24 // Iterate over a copy: |
| 26 // 1) because |Abort()| calls |Remove()| (indirectly). | 25 // 1) because |Abort()| calls |Remove()| (indirectly). |
| 27 // 2) So we can drop the lock before calling in to TrackedCallback. | 26 // 2) So we can drop the lock before calling in to TrackedCallback. |
| 28 CallbackSetMap pending_callbacks_copy; | 27 CallbackSetMap pending_callbacks_copy; |
| 29 { | 28 { |
| 30 base::AutoLock acquire(lock_); | 29 base::AutoLock acquire(lock_); |
| 31 pending_callbacks_copy = pending_callbacks_; | 30 pending_callbacks_copy = pending_callbacks_; |
| 32 abort_all_called_ = true; | 31 abort_all_called_ = true; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 CallbackSet::iterator it = map_it->second.find(tracked_callback); | 86 CallbackSet::iterator it = map_it->second.find(tracked_callback); |
| 88 DCHECK(it != map_it->second.end()); | 87 DCHECK(it != map_it->second.end()); |
| 89 map_it->second.erase(it); | 88 map_it->second.erase(it); |
| 90 | 89 |
| 91 // If there are no pending callbacks left for this ID, get rid of the entry. | 90 // If there are no pending callbacks left for this ID, get rid of the entry. |
| 92 if (map_it->second.empty()) | 91 if (map_it->second.empty()) |
| 93 pending_callbacks_.erase(map_it); | 92 pending_callbacks_.erase(map_it); |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace ppapi | 95 } // namespace ppapi |
| OLD | NEW |