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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // should never try to PostRun more than once otherwise. | 160 // should never try to PostRun more than once otherwise. |
161 DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); | 161 DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); |
162 | 162 |
163 if (is_blocking()) { | 163 if (is_blocking()) { |
164 // We might not have a MessageLoop to post to, so we must call Run() | 164 // We might not have a MessageLoop to post to, so we must call Run() |
165 // directly. | 165 // directly. |
166 Run(result); | 166 Run(result); |
167 } else { | 167 } else { |
168 base::Closure callback_closure( | 168 base::Closure callback_closure( |
169 RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result))); | 169 RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result))); |
170 if (target_loop_) { | 170 if (target_loop_.get()) { |
171 target_loop_->PostClosure(FROM_HERE, callback_closure, 0); | 171 target_loop_->PostClosure(FROM_HERE, callback_closure, 0); |
172 } else { | 172 } else { |
173 // We must be running in-process and on the main thread (the Enter | 173 // We must be running in-process and on the main thread (the Enter |
174 // classes protect against having a null target_loop_ otherwise). | 174 // classes protect against having a null target_loop_ otherwise). |
175 DCHECK(IsMainThread()); | 175 DCHECK(IsMainThread()); |
176 DCHECK(PpapiGlobals::Get()->IsHostGlobals()); | 176 DCHECK(PpapiGlobals::Get()->IsHostGlobals()); |
177 base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); | 177 base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); |
178 } | 178 } |
179 } | 179 } |
180 is_scheduled_ = true; | 180 is_scheduled_ = true; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // until we're done. | 233 // until we're done. |
234 scoped_refptr<TrackedCallback> thiz = this; | 234 scoped_refptr<TrackedCallback> thiz = this; |
235 completed_ = true; | 235 completed_ = true; |
236 // We may not have a valid resource, in which case we're not in the tracker. | 236 // We may not have a valid resource, in which case we're not in the tracker. |
237 if (resource_id_) | 237 if (resource_id_) |
238 tracker_->Remove(thiz); | 238 tracker_->Remove(thiz); |
239 tracker_ = NULL; | 239 tracker_ = NULL; |
240 } | 240 } |
241 | 241 |
242 } // namespace ppapi | 242 } // namespace ppapi |
OLD | NEW |