Chromium Code Reviews| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 NOTREACHED(); | 159 NOTREACHED(); |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 if (result == PP_ERROR_ABORTED) | 162 if (result == PP_ERROR_ABORTED) |
| 163 aborted_ = true; | 163 aborted_ = true; |
| 164 // We might abort when there's already a scheduled callback, but callers | 164 // We might abort when there's already a scheduled callback, but callers |
| 165 // should never try to PostRun more than once otherwise. | 165 // should never try to PostRun more than once otherwise. |
| 166 DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); | 166 DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); |
| 167 | 167 |
| 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))); |
|
bbudge
2013/09/04 22:31:45
We should probably move this into the 'else' claus
| |
| 170 if (!target_loop_.get()) { | 170 if (is_blocking()) { |
| 171 // We might not have a MessageLoop to post to, so we must call Run() | |
| 172 // directly. Since we don't want to attempt to re-acquire the lock, we | |
| 173 // don't use the locking closure. | |
| 174 Run(result); | |
| 175 } else if (!target_loop_.get()) { | |
| 171 // We must be running in-process and on the main thread (the Enter | 176 // We must be running in-process and on the main thread (the Enter |
| 172 // classes protect against having a null target_loop_ otherwise). | 177 // classes protect against having a null target_loop_ otherwise). |
| 173 DCHECK(IsMainThread()); | 178 DCHECK(IsMainThread()); |
| 174 DCHECK(PpapiGlobals::Get()->IsHostGlobals()); | 179 DCHECK(PpapiGlobals::Get()->IsHostGlobals()); |
| 175 base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); | 180 base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); |
| 176 } else { | 181 } else { |
| 177 target_loop_->PostClosure(FROM_HERE, callback_closure, 0); | 182 target_loop_->PostClosure(FROM_HERE, callback_closure, 0); |
| 178 } | 183 } |
| 179 is_scheduled_ = true; | 184 is_scheduled_ = true; |
| 180 } | 185 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 // until we're done. | 237 // until we're done. |
| 233 scoped_refptr<TrackedCallback> thiz = this; | 238 scoped_refptr<TrackedCallback> thiz = this; |
| 234 completed_ = true; | 239 completed_ = true; |
| 235 // We may not have a valid resource, in which case we're not in the tracker. | 240 // We may not have a valid resource, in which case we're not in the tracker. |
| 236 if (resource_id_) | 241 if (resource_id_) |
| 237 tracker_->Remove(thiz); | 242 tracker_->Remove(thiz); |
| 238 tracker_ = NULL; | 243 tracker_ = NULL; |
| 239 } | 244 } |
| 240 | 245 |
| 241 } // namespace ppapi | 246 } // namespace ppapi |
| OLD | NEW |