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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // The Enter class should handle checking this for us. | 55 // The Enter class should handle checking this for us. |
56 | 56 |
57 // TODO(dmichael): Add tracking at the instance level, for callbacks that only | 57 // TODO(dmichael): Add tracking at the instance level, for callbacks that only |
58 // have an instance (e.g. for MouseLock). | 58 // have an instance (e.g. for MouseLock). |
59 if (resource) { | 59 if (resource) { |
60 tracker_ = PpapiGlobals::Get()->GetCallbackTrackerForInstance( | 60 tracker_ = PpapiGlobals::Get()->GetCallbackTrackerForInstance( |
61 resource->pp_instance()); | 61 resource->pp_instance()); |
62 tracker_->Add(make_scoped_refptr(this)); | 62 tracker_->Add(make_scoped_refptr(this)); |
63 } | 63 } |
64 | 64 |
65 base::Lock* proxy_lock = PpapiGlobals::Get()->GetProxyLock(); | 65 base::Lock* proxy_lock = ProxyLock::Get(); |
66 if (proxy_lock) { | 66 if (proxy_lock) { |
67 // If the proxy_lock is valid, we're running out-of-process, and locking | 67 // If the proxy_lock is valid, we're running out-of-process, and locking |
68 // is enabled. | 68 // is enabled. |
69 if (is_blocking()) { | 69 if (is_blocking()) { |
70 // This is a blocking completion callback, so we will need a condition | 70 // This is a blocking completion callback, so we will need a condition |
71 // variable for blocking & signalling the calling thread. | 71 // variable for blocking & signalling the calling thread. |
72 operation_completed_condvar_.reset( | 72 operation_completed_condvar_.reset( |
73 new base::ConditionVariable(proxy_lock)); | 73 new base::ConditionVariable(proxy_lock)); |
74 } else { | 74 } else { |
75 // It's a non-blocking callback, so we should have a MessageLoopResource | 75 // It's a non-blocking callback, so we should have a MessageLoopResource |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // until we're done. | 238 // until we're done. |
239 scoped_refptr<TrackedCallback> thiz = this; | 239 scoped_refptr<TrackedCallback> thiz = this; |
240 completed_ = true; | 240 completed_ = true; |
241 // We may not have a valid resource, in which case we're not in the tracker. | 241 // We may not have a valid resource, in which case we're not in the tracker. |
242 if (resource_id_) | 242 if (resource_id_) |
243 tracker_->Remove(thiz); | 243 tracker_->Remove(thiz); |
244 tracker_ = NULL; | 244 tracker_ = NULL; |
245 } | 245 } |
246 | 246 |
247 } // namespace ppapi | 247 } // namespace ppapi |
OLD | NEW |