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

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

Issue 869883003: Never lock the Pepper proxy lock on the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some pre-review cleanup Created 5 years, 9 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
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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 { 45 {
46 base::AutoLock acquire(lock_); 46 base::AutoLock acquire(lock_);
47 CallbackSetMap::iterator iter = pending_callbacks_.find(resource_id); 47 CallbackSetMap::iterator iter = pending_callbacks_.find(resource_id);
48 // The resource may have no callbacks, so it won't be found, and we're done. 48 // The resource may have no callbacks, so it won't be found, and we're done.
49 if (iter == pending_callbacks_.end()) 49 if (iter == pending_callbacks_.end())
50 return; 50 return;
51 // Copy the set so we can drop the lock before calling in to 51 // Copy the set so we can drop the lock before calling in to
52 // TrackedCallback. 52 // TrackedCallback.
53 callbacks_for_resource = iter->second; 53 callbacks_for_resource = iter->second;
54 } 54 }
55 for (const auto& iter : callbacks_for_resource) { 55 for (const auto& iter : callbacks_for_resource)
56 iter->PostAbort(); 56 iter->PostAbort();
57 }
58 } 57 }
59 58
60 CallbackTracker::~CallbackTracker() { 59 CallbackTracker::~CallbackTracker() {
61 // All callbacks must be aborted before destruction. 60 // All callbacks must be aborted before destruction.
62 CHECK_EQ(0u, pending_callbacks_.size()); 61 CHECK_EQ(0u, pending_callbacks_.size());
63 } 62 }
64 63
65 void CallbackTracker::Add( 64 void CallbackTracker::Add(
66 const scoped_refptr<TrackedCallback>& tracked_callback) { 65 const scoped_refptr<TrackedCallback>& tracked_callback) {
67 base::AutoLock acquire(lock_); 66 base::AutoLock acquire(lock_);
(...skipping 12 matching lines...) Expand all
80 CallbackSet::iterator it = map_it->second.find(tracked_callback); 79 CallbackSet::iterator it = map_it->second.find(tracked_callback);
81 DCHECK(it != map_it->second.end()); 80 DCHECK(it != map_it->second.end());
82 map_it->second.erase(it); 81 map_it->second.erase(it);
83 82
84 // If there are no pending callbacks left for this ID, get rid of the entry. 83 // If there are no pending callbacks left for this ID, get rid of the entry.
85 if (map_it->second.empty()) 84 if (map_it->second.empty())
86 pending_callbacks_.erase(map_it); 85 pending_callbacks_.erase(map_it);
87 } 86 }
88 87
89 } // namespace ppapi 88 } // namespace ppapi
OLDNEW
« ppapi/proxy/udp_socket_resource_base.cc ('K') | « ppapi/proxy/udp_socket_resource_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698