summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 18:11:55 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 18:11:55 +0000
commitb8d9e92060972f9f9a98b825710116747e371b89 (patch)
tree6b5ac3d0de1e8dc40677353ed4d8f404a230ded7
parent5ed3120eb4197051352260a03b28f304f75d6cc9 (diff)
downloadchromium_src-b8d9e92060972f9f9a98b825710116747e371b89.zip
chromium_src-b8d9e92060972f9f9a98b825710116747e371b89.tar.gz
chromium_src-b8d9e92060972f9f9a98b825710116747e371b89.tar.bz2
Don't try to call setDefersLoading when the loader is null. This does a bit of cleanup so the checks for the null-ness of this variable is centralized, and I filed a bug for not having this implemented for main document loads.
TEST=manual BUG=96727 Review URL: http://codereview.chromium.org/7920001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101524 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.cc32
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.h12
2 files changed, 34 insertions, 10 deletions
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index 8edba62..5d0acb9 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -96,6 +96,11 @@ void PPB_URLLoader_Impl::InstanceWasDeleted() {
int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id,
PP_CompletionCallback callback) {
+ // Main document loads are already open, so don't allow people to open them
+ // again.
+ if (main_document_loader_)
+ return PP_ERROR_INPROGRESS;
+
EnterResourceNoLock<PPB_URLRequestInfo_API> enter_request(request_id, true);
if (enter_request.failed())
return PP_ERROR_BADARGUMENT;
@@ -156,7 +161,7 @@ int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) {
WebURL redirect_url = GURL(response_info_->redirect_url());
- loader_->setDefersLoading(false); // Allow the redirect to continue.
+ SetDefersLoading(false); // Allow the redirect to continue.
RegisterCallback(callback);
return PP_OK_COMPLETIONPENDING;
}
@@ -233,10 +238,8 @@ int32_t PPB_URLLoader_Impl::FinishStreamingToFile(
return done_status_;
is_streaming_to_file_ = true;
- if (is_asynchronous_load_suspended_) {
- loader_->setDefersLoading(false);
- is_asynchronous_load_suspended_ = false;
- }
+ if (is_asynchronous_load_suspended_)
+ SetDefersLoading(false);
// Wait for didFinishLoading / didFail.
RegisterCallback(callback);
@@ -267,7 +270,7 @@ void PPB_URLLoader_Impl::willSendRequest(
const WebURLResponse& redirect_response) {
if (!request_data_.follow_redirects) {
SaveResponse(redirect_response);
- loader_->setDefersLoading(true);
+ SetDefersLoading(true);
RunCallback(PP_OK);
}
}
@@ -303,6 +306,7 @@ void PPB_URLLoader_Impl::didReceiveData(WebURLLoader* loader,
const char* data,
int data_length,
int encoded_data_length) {
+ // Note that |loader| will be NULL for document loads.
bytes_received_ += data_length;
UpdateStatus();
@@ -323,8 +327,7 @@ void PPB_URLLoader_Impl::didReceiveData(WebURLLoader* loader,
(buffer_.size() >= static_cast<size_t>(
request_data_.prefetch_buffer_upper_threshold))) {
DVLOG(1) << "Suspending async load - buffer size: " << buffer_.size();
- loader->setDefersLoading(true);
- is_asynchronous_load_suspended_ = true;
+ SetDefersLoading(true);
}
}
@@ -353,6 +356,16 @@ void PPB_URLLoader_Impl::didFail(WebURLLoader* loader,
FinishLoading(pp_error);
}
+void PPB_URLLoader_Impl::SetDefersLoading(bool defers_loading) {
+ if (loader_.get()) {
+ loader_->setDefersLoading(defers_loading);
+ is_asynchronous_load_suspended_ = defers_loading;
+ }
+
+ // TODO(brettw) bug 96770: We need a way to set the defers loading flag on
+ // main document loads (when the loader_ is null).
+}
+
void PPB_URLLoader_Impl::FinishLoading(int32_t done_status) {
done_status_ = done_status;
// If the client hasn't called any function that takes a callback since
@@ -410,8 +423,7 @@ size_t PPB_URLLoader_Impl::FillUserBuffer() {
buffer_.size() <= static_cast<size_t>(
request_data_.prefetch_buffer_lower_threshold)) {
DVLOG(1) << "Resuming async load - buffer size: " << buffer_.size();
- loader_->setDefersLoading(false);
- is_asynchronous_load_suspended_ = false;
+ SetDefersLoading(false);
}
// Reset for next time.
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.h b/webkit/plugins/ppapi/ppb_url_loader_impl.h
index f45181b..642a591 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.h
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.h
@@ -117,6 +117,10 @@ class PPB_URLLoader_Impl : public ::ppapi::Resource,
bool RecordDownloadProgress() const;
bool RecordUploadProgress() const;
+ // Calls SetDefersLoading on the current load. This encapsulates the logic
+ // differences between document loads and regular ones.
+ void SetDefersLoading(bool defers_loading);
+
void FinishLoading(int32_t done_status);
// If true, then the plugin instance is a full-frame plugin and we're just
@@ -128,7 +132,15 @@ class PPB_URLLoader_Impl : public ::ppapi::Resource,
// change the request info resource out from under us.
::ppapi::PPB_URLRequestInfo_Data request_data_;
+ // The loader associated with this request. MAY BE NULL.
+ //
+ // This will be NULL if the load hasn't been opened yet, or if this is a main
+ // document loader (when registered as a mime type). Therefore, you should
+ // always NULL check this value before using it. In the case of a main
+ // document load, you would call the functions on the document to cancel the
+ // load, etc. since there is no loader.
scoped_ptr<WebKit::WebURLLoader> loader_;
+
scoped_refptr<PPB_URLResponseInfo_Impl> response_info_;
scoped_refptr<TrackedCompletionCallback> pending_callback_;
std::deque<char> buffer_;