| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/thunk/common.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/message_loop.h" | |
| 9 #include "ppapi/c/pp_errors.h" | |
| 10 | |
| 11 namespace ppapi { | |
| 12 namespace thunk { | |
| 13 | |
| 14 int32_t MayForceCallback(PP_CompletionCallback callback, int32_t result) { | |
| 15 if (result == PP_OK_COMPLETIONPENDING) | |
| 16 return result; | |
| 17 | |
| 18 if (callback.func == NULL || | |
| 19 (callback.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL) != 0) | |
| 20 return result; | |
| 21 | |
| 22 // TODO(polina): make this work off the main thread as well | |
| 23 // (At this point this should not be an issue because PPAPI is only supported | |
| 24 // on the main thread). | |
| 25 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | |
| 26 callback.func, callback.user_data, result)); | |
| 27 return PP_OK_COMPLETIONPENDING; | |
| 28 } | |
| 29 | |
| 30 } // namespace thunk | |
| 31 } // namespace ppapi | |
| OLD | NEW |