Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: webkit/plugins/ppapi/ppb_file_chooser_impl.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated TestURLLoader to test blocking callbacks. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppb_file_chooser_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
index 95a97a2a22ebcade418ffbd62215ad7dc961d8da..4605b893d0342e98ed93d1cbc537a43190614b05 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
@@ -28,6 +28,7 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_helper.h"
+using ppapi::ApiCallbackType;
using ppapi::StringVar;
using ppapi::thunk::PPB_FileChooser_API;
using ppapi::TrackedCallback;
@@ -148,28 +149,21 @@ void PPB_FileChooser_Impl::StoreChosenFiles(
RunCallback(result_code);
}
-int32_t PPB_FileChooser_Impl::ValidateCallback(
- const PP_CompletionCallback& callback) {
- // We only support non-blocking calls.
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
+int32_t PPB_FileChooser_Impl::ValidateCallback(ApiCallbackType callback) {
if (TrackedCallback::IsPending(callback_))
return PP_ERROR_INPROGRESS;
return PP_OK;
}
-void PPB_FileChooser_Impl::RegisterCallback(
- const PP_CompletionCallback& callback) {
- DCHECK(callback.func);
+void PPB_FileChooser_Impl::RegisterCallback(ApiCallbackType callback) {
DCHECK(!TrackedCallback::IsPending(callback_));
PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
if (!plugin_module)
return;
- callback_ = new TrackedCallback(this, callback);
+ callback_ = callback;
}
void PPB_FileChooser_Impl::RunCallback(int32_t result) {
@@ -177,7 +171,7 @@ void PPB_FileChooser_Impl::RunCallback(int32_t result) {
}
int32_t PPB_FileChooser_Impl::Show(const PP_ArrayOutput& output,
- const PP_CompletionCallback& callback) {
+ ApiCallbackType callback) {
int32_t result = Show0_5(callback);
if (result == PP_OK_COMPLETIONPENDING)
output_.set_pp_array_output(output);
@@ -188,7 +182,7 @@ int32_t PPB_FileChooser_Impl::ShowWithoutUserGesture(
PP_Bool save_as,
PP_Var suggested_file_name,
const PP_ArrayOutput& output,
- const PP_CompletionCallback& callback) {
+ ApiCallbackType callback) {
int32_t result = ShowWithoutUserGesture0_5(save_as, suggested_file_name,
callback);
if (result == PP_OK_COMPLETIONPENDING)
@@ -196,7 +190,7 @@ int32_t PPB_FileChooser_Impl::ShowWithoutUserGesture(
return result;
}
-int32_t PPB_FileChooser_Impl::Show0_5(const PP_CompletionCallback& callback) {
+int32_t PPB_FileChooser_Impl::Show0_5(ApiCallbackType callback) {
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
return PP_ERROR_FAILED;
@@ -208,7 +202,7 @@ int32_t PPB_FileChooser_Impl::Show0_5(const PP_CompletionCallback& callback) {
int32_t PPB_FileChooser_Impl::ShowWithoutUserGesture0_5(
PP_Bool save_as,
PP_Var suggested_file_name,
- const PP_CompletionCallback& callback) {
+ ApiCallbackType callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;

Powered by Google App Engine
This is Rietveld 408576698