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

Unified Diff: webkit/plugins/ppapi/ppb_url_loader_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_url_loader_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index 7e4fdef0f443ab797c7ccdbeb2b64b46ac2c6284..68db6b8655e02013cd9f97a0f76c526b020e1462 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -32,6 +32,7 @@
#include "webkit/plugins/ppapi/resource_helper.h"
using appcache::WebApplicationCacheHostImpl;
+using ppapi::ApiCallbackType;
using ppapi::Resource;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_URLLoader_API;
@@ -96,7 +97,7 @@ void PPB_URLLoader_Impl::InstanceWasDeleted() {
}
int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id,
- PP_CompletionCallback callback) {
+ ApiCallbackType callback) {
// Main document loads are already open, so don't allow people to open them
// again.
if (main_document_loader_)
@@ -172,7 +173,7 @@ int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::FollowRedirect(ApiCallbackType callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
@@ -217,7 +218,7 @@ PP_Resource PPB_URLLoader_Impl::GetResponseInfo() {
int32_t PPB_URLLoader_Impl::ReadResponseBody(void* buffer,
int32_t bytes_to_read,
- PP_CompletionCallback callback) {
+ ApiCallbackType callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
@@ -244,7 +245,7 @@ int32_t PPB_URLLoader_Impl::ReadResponseBody(void* buffer,
}
int32_t PPB_URLLoader_Impl::FinishStreamingToFile(
- PP_CompletionCallback callback) {
+ ApiCallbackType callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
@@ -395,10 +396,9 @@ void PPB_URLLoader_Impl::FinishLoading(int32_t done_status) {
RunCallback(done_status_);
}
-int32_t PPB_URLLoader_Impl::ValidateCallback(PP_CompletionCallback callback) {
- // We only support non-blocking calls.
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
+int32_t PPB_URLLoader_Impl::ValidateCallback(
+ scoped_refptr<TrackedCallback> callback) {
+ DCHECK(callback);
if (TrackedCallback::IsPending(pending_callback_))
return PP_ERROR_INPROGRESS;
@@ -406,15 +406,15 @@ int32_t PPB_URLLoader_Impl::ValidateCallback(PP_CompletionCallback callback) {
return PP_OK;
}
-void PPB_URLLoader_Impl::RegisterCallback(PP_CompletionCallback callback) {
- DCHECK(callback.func);
+void PPB_URLLoader_Impl::RegisterCallback(
+ scoped_refptr<TrackedCallback> callback) {
DCHECK(!TrackedCallback::IsPending(pending_callback_));
PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
if (!plugin_module)
return;
- pending_callback_ = new TrackedCallback(this, callback);
+ pending_callback_ = callback;
}
void PPB_URLLoader_Impl::RunCallback(int32_t result) {

Powered by Google App Engine
This is Rietveld 408576698