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.h" | 10 #include "base/message_loop.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // should never try to PostRun more than once otherwise. | 150 // should never try to PostRun more than once otherwise. |
151 DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); | 151 DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); |
152 | 152 |
153 base::Closure callback_closure( | 153 base::Closure callback_closure( |
154 RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result))); | 154 RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result))); |
155 if (!target_loop_) { | 155 if (!target_loop_) { |
156 // We must be running in-process and on the main thread (the Enter | 156 // We must be running in-process and on the main thread (the Enter |
157 // classes protect against having a null target_loop_ otherwise). | 157 // classes protect against having a null target_loop_ otherwise). |
158 DCHECK(IsMainThread()); | 158 DCHECK(IsMainThread()); |
159 DCHECK(PpapiGlobals::Get()->IsHostGlobals()); | 159 DCHECK(PpapiGlobals::Get()->IsHostGlobals()); |
160 MessageLoop::current()->PostTask(FROM_HERE, callback_closure); | 160 base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); |
161 } else { | 161 } else { |
162 target_loop_->PostClosure(FROM_HERE, callback_closure, 0); | 162 target_loop_->PostClosure(FROM_HERE, callback_closure, 0); |
163 } | 163 } |
164 is_scheduled_ = true; | 164 is_scheduled_ = true; |
165 } | 165 } |
166 | 166 |
167 // static | 167 // static |
168 bool TrackedCallback::IsPending( | 168 bool TrackedCallback::IsPending( |
169 const scoped_refptr<TrackedCallback>& callback) { | 169 const scoped_refptr<TrackedCallback>& callback) { |
170 if (!callback.get()) | 170 if (!callback.get()) |
(...skipping 26 matching lines...) Expand all Loading... |
197 // until we're done. | 197 // until we're done. |
198 scoped_refptr<TrackedCallback> thiz = this; | 198 scoped_refptr<TrackedCallback> thiz = this; |
199 completed_ = true; | 199 completed_ = true; |
200 // We may not have a valid resource, in which case we're not in the tracker. | 200 // We may not have a valid resource, in which case we're not in the tracker. |
201 if (resource_id_) | 201 if (resource_id_) |
202 tracker_->Remove(thiz); | 202 tracker_->Remove(thiz); |
203 tracker_ = NULL; | 203 tracker_ = NULL; |
204 } | 204 } |
205 | 205 |
206 } // namespace ppapi | 206 } // namespace ppapi |
OLD | NEW |