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

Unified Diff: content/child/web_url_loader_impl.cc

Issue 737763002: Properly handle defers loading in WebURLLoaderImpl for data uris (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More sturdy API Created 6 years 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
« no previous file with comments | « no previous file | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/web_url_loader_impl.cc
diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc
index 0ed7d5bc2b2ffa1679ea7c94ac51db2d6b8d58ac..3814c901998d92d502ff27211f9caf84036e7c65 100644
--- a/content/child/web_url_loader_impl.cc
+++ b/content/child/web_url_loader_impl.cc
@@ -8,6 +8,7 @@
#include <algorithm>
#include <deque>
+#include <string>
#include "base/bind.h"
#include "base/command_line.h"
@@ -354,6 +355,8 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
// mechanism.
std::deque<char> body_stream_buffer_;
bool got_all_stream_body_data_;
+ enum DeferState {NOT_DEFERRING, SHOULD_DEFER, DEFERRED_DATA};
+ DeferState defers_loading_;
};
WebURLLoaderImpl::Context::Context(
@@ -365,7 +368,8 @@ WebURLLoaderImpl::Context::Context(
resource_dispatcher_(resource_dispatcher),
task_runner_(task_runner),
referrer_policy_(blink::WebReferrerPolicyDefault),
- got_all_stream_body_data_(false) {
+ got_all_stream_body_data_(false),
+ defers_loading_(NOT_DEFERRING) {
}
void WebURLLoaderImpl::Context::Cancel() {
@@ -390,6 +394,15 @@ void WebURLLoaderImpl::Context::Cancel() {
void WebURLLoaderImpl::Context::SetDefersLoading(bool value) {
if (bridge_)
bridge_->SetDefersLoading(value);
+ if (value && defers_loading_ == NOT_DEFERRING) {
+ defers_loading_ = SHOULD_DEFER;
+ } else if (!value && defers_loading_ != NOT_DEFERRING) {
+ if (defers_loading_ == DEFERRED_DATA) {
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&Context::HandleDataURL, this));
+ }
+ defers_loading_ = NOT_DEFERRING;
+ }
}
void WebURLLoaderImpl::Context::DidChangePriority(
@@ -838,6 +851,12 @@ bool WebURLLoaderImpl::Context::CanHandleDataURLRequestLocally() const {
}
void WebURLLoaderImpl::Context::HandleDataURL() {
+ DCHECK_NE(defers_loading_, DEFERRED_DATA);
+ if (defers_loading_ == SHOULD_DEFER) {
+ defers_loading_ = DEFERRED_DATA;
+ return;
+ }
+
ResourceResponseInfo info;
std::string data;
« no previous file with comments | « no previous file | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698