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; |
231 target_loop_ = NULL; | 236 target_loop_ = NULL; |
232 } | 237 } |
233 | 238 |
234 void TrackedCallback::PostRunWithLock(int32_t result) { | 239 void TrackedCallback::PostRunWithLock(int32_t result) { |
235 lock_.AssertAcquired(); | 240 lock_.AssertAcquired(); |
236 if (completed_) { | 241 if (completed_) { |
237 NOTREACHED(); | 242 NOTREACHED(); |
238 return; | 243 return; |
239 } | 244 } |
240 if (result == PP_ERROR_ABORTED) | 245 if (result == PP_ERROR_ABORTED) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // tracker. Then MarkAsCompleted before waking up the blocked thread, | 286 // tracker. Then MarkAsCompleted before waking up the blocked thread, |
282 // which could potentially re-enter. | 287 // which could potentially re-enter. |
283 scoped_refptr<TrackedCallback> thiz(this); | 288 scoped_refptr<TrackedCallback> thiz(this); |
284 MarkAsCompletedWithLock(); | 289 MarkAsCompletedWithLock(); |
285 // Wake up the blocked thread. See BlockUntilComplete for where the thread | 290 // Wake up the blocked thread. See BlockUntilComplete for where the thread |
286 // Wait()s. | 291 // Wait()s. |
287 operation_completed_condvar_->Signal(); | 292 operation_completed_condvar_->Signal(); |
288 } | 293 } |
289 | 294 |
290 } // namespace ppapi | 295 } // namespace ppapi |
OLD | NEW |