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/message_loop.h" |
| 8 #include "ppapi/c/pp_errors.h" |
| 9 |
| 10 namespace ppapi { |
| 11 namespace thunk { |
| 12 |
| 13 int32_t MayForceCallback(PP_CompletionCallback callback, int32_t result) { |
| 14 if (result == PP_OK_COMPLETIONPENDING) |
| 15 return result; |
| 16 |
| 17 if (callback.func == NULL || |
| 18 (callback.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL) != 0) |
| 19 return result; |
| 20 |
| 21 // TODO(polina): make this work off the main thread as well |
| 22 // (At this point this should not be an issue because PPAPI is only supported |
| 23 // on the main thread). |
| 24 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( |
| 25 callback.func, callback.user_data, result)); |
| 26 return PP_OK_COMPLETIONPENDING; |
| 27 } |
| 28 |
| 29 } // namespace thunk |
| 30 } // namespace ppapi |
OLD | NEW |