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

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

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
« ppapi/c/pp_completion_callback.h ('K') | « ppapi/tests/test_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_url_loader_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_url_loader_impl.cc (revision 82761)
+++ webkit/plugins/ppapi/ppb_url_loader_impl.cc (working copy)
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_core.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
@@ -47,6 +48,15 @@
namespace {
+int32_t CompletionResult(PP_CompletionCallback callback, int32_t result) {
+ if (callback.func == NULL ||
+ (callback.flags & PP_COMPLETIONCALLBACK_FLAG_NOFORCEASYNC) != 0)
+ return result;
+
+ PluginModule::GetCore()->CallOnMainThread(0, callback, result);
+ return PP_OK_COMPLETIONPENDING;
+}
+
PP_Resource Create(PP_Instance instance_id) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance)
@@ -66,12 +76,12 @@
scoped_refptr<PPB_URLLoader_Impl> loader(
Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
- return PP_ERROR_BADRESOURCE;
+ return CompletionResult(callback, PP_ERROR_BADRESOURCE);
scoped_refptr<PPB_URLRequestInfo_Impl> request(
Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id));
if (!request)
- return PP_ERROR_BADRESOURCE;
+ return CompletionResult(callback, PP_ERROR_BADRESOURCE);
return loader->Open(request, callback);
}
@@ -242,18 +252,18 @@
PP_CompletionCallback callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
- return rv;
+ return CompletionResult(callback, rv);
darin (slow to review) 2011/04/25 18:31:06 I think it would be better to put the callback fix
polina 2011/04/25 19:44:44 Do you mean put this in outer Open where it has:
if (request->RequiresUniversalAccess() && !has_universal_access_)
- return PP_ERROR_BADARGUMENT;
+ // Why is this not PP_ERROR_NOACCESS?
+ return CompletionResult(callback, PP_ERROR_BADARGUMENT);
if (loader_.get())
- return PP_ERROR_INPROGRESS;
+ return CompletionResult(callback, PP_ERROR_INPROGRESS);
WebFrame* frame = GetFrame(instance());
if (!frame)
- return PP_ERROR_FAILED;
- WebURLRequest web_request(request->ToWebURLRequest(frame));
+ return CompletionResult(callback, PP_ERROR_FAILED);
WebURLLoaderOptions options;
if (has_universal_access_) {
@@ -270,8 +280,9 @@
loader_.reset(frame->createAssociatedURLLoader(options));
if (!loader_.get())
- return PP_ERROR_FAILED;
+ return CompletionResult(callback, PP_ERROR_FAILED);
+ WebURLRequest web_request(request->ToWebURLRequest(frame));
loader_->loadAsynchronously(web_request, this);
// Check for immediate failure; The AssociatedURLLoader will call our
// didFail method synchronously for certain kinds of access violations
@@ -279,7 +290,7 @@
// TODO(bbudge) Modify the underlying AssociatedURLLoader to only call
// back asynchronously.
if (done_status_ == PP_ERROR_FAILED)
- return PP_ERROR_NOACCESS;
+ return CompletionResult(callback, PP_ERROR_NOACCESS);
request_info_ = scoped_refptr<PPB_URLRequestInfo_Impl>(request);
@@ -291,7 +302,7 @@
int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
- return rv;
+ return CompletionResult(callback, rv);
WebURL redirect_url = GURL(response_info_->redirect_url());
@@ -330,23 +341,23 @@
PP_CompletionCallback callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
- return rv;
+ return CompletionResult(callback, rv);
if (!response_info_ || response_info_->body())
- return PP_ERROR_FAILED;
+ return CompletionResult(callback, PP_ERROR_FAILED);
if (bytes_to_read <= 0 || !buffer)
- return PP_ERROR_BADARGUMENT;
+ return CompletionResult(callback, PP_ERROR_BADARGUMENT);
user_buffer_ = static_cast<char*>(buffer);
user_buffer_size_ = bytes_to_read;
if (!buffer_.empty())
- return FillUserBuffer();
+ return CompletionResult(callback, FillUserBuffer());
// We may have already reached EOF.
if (done_status_ != PP_OK_COMPLETIONPENDING) {
user_buffer_ = NULL;
user_buffer_size_ = 0;
- return done_status_;
+ return CompletionResult(callback, done_status_);
}
RegisterCallback(callback);
@@ -357,13 +368,13 @@
PP_CompletionCallback callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
- return rv;
+ return CompletionResult(callback, rv);
if (!response_info_ || !response_info_->body())
- return PP_ERROR_FAILED;
+ return CompletionResult(callback, PP_ERROR_FAILED);
// We may have already reached EOF.
if (done_status_ != PP_OK_COMPLETIONPENDING)
- return done_status_;
+ return CompletionResult(callback, done_status_);
// Wait for didFinishLoading / didFail.
RegisterCallback(callback);
« ppapi/c/pp_completion_callback.h ('K') | « ppapi/tests/test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698