OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tracked_callback.h" | 5 #include "ppapi/shared_impl/tracked_callback.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 DCHECK(!completed_); | 221 DCHECK(!completed_); |
222 | 222 |
223 // We will be removed; maintain a reference to ensure we won't be deleted | 223 // We will be removed; maintain a reference to ensure we won't be deleted |
224 // until we're done. | 224 // until we're done. |
225 scoped_refptr<TrackedCallback> thiz = this; | 225 scoped_refptr<TrackedCallback> thiz = this; |
226 completed_ = true; | 226 completed_ = true; |
227 // We may not have a valid resource, in which case we're not in the tracker. | 227 // We may not have a valid resource, in which case we're not in the tracker. |
228 if (resource_id_) | 228 if (resource_id_) |
229 tracker_->Remove(thiz); | 229 tracker_->Remove(thiz); |
230 tracker_ = NULL; | 230 tracker_ = NULL; |
231 | |
232 // Relax the cross-thread access restriction to non-thread-safe RefCount. | |
233 // |lock_| protects the access to Resource instances. | |
234 base::ScopedAllowCrossThreadRefCountAccess | |
235 allow_cross_thread_ref_count_access; | |
236 target_loop_ = NULL; | 231 target_loop_ = NULL; |
237 } | 232 } |
238 | 233 |
239 void TrackedCallback::PostRunWithLock(int32_t result) { | 234 void TrackedCallback::PostRunWithLock(int32_t result) { |
240 lock_.AssertAcquired(); | 235 lock_.AssertAcquired(); |
241 if (completed_) { | 236 if (completed_) { |
242 NOTREACHED(); | 237 NOTREACHED(); |
243 return; | 238 return; |
244 } | 239 } |
245 if (result == PP_ERROR_ABORTED) | 240 if (result == PP_ERROR_ABORTED) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // tracker. Then MarkAsCompleted before waking up the blocked thread, | 281 // tracker. Then MarkAsCompleted before waking up the blocked thread, |
287 // which could potentially re-enter. | 282 // which could potentially re-enter. |
288 scoped_refptr<TrackedCallback> thiz(this); | 283 scoped_refptr<TrackedCallback> thiz(this); |
289 MarkAsCompletedWithLock(); | 284 MarkAsCompletedWithLock(); |
290 // Wake up the blocked thread. See BlockUntilComplete for where the thread | 285 // Wake up the blocked thread. See BlockUntilComplete for where the thread |
291 // Wait()s. | 286 // Wait()s. |
292 operation_completed_condvar_->Signal(); | 287 operation_completed_condvar_->Signal(); |
293 } | 288 } |
294 | 289 |
295 } // namespace ppapi | 290 } // namespace ppapi |
OLD | NEW |