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

Unified Diff: content/child/web_url_loader_impl.cc

Issue 1366883002: [Reland] Post loading tasks on the appropriate WebFrameScheduler's queue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android compile Created 5 years, 3 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: 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 83c9ad5b64db596b8d5e7941f2c8abb3ea6ea493..8581c745f85f3dc9713d21cb44bd423a19051748 100644
--- a/content/child/web_url_loader_impl.cc
+++ b/content/child/web_url_loader_impl.cc
@@ -16,6 +16,7 @@
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "components/mime_util/mime_util.h"
+#include "components/scheduler/child/web_task_runner_impl.h"
#include "content/child/child_thread_impl.h"
#include "content/child/ftp_directory_listing_response_delegate.h"
#include "content/child/multipart_response_delegate.h"
@@ -42,6 +43,7 @@
#include "net/ssl/ssl_connection_status_flags.h"
#include "net/url_request/url_request_data_job.h"
#include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
+#include "third_party/WebKit/public/platform/WebTraceLocation.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
#include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
@@ -254,7 +256,7 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
public:
Context(WebURLLoaderImpl* loader,
ResourceDispatcher* resource_dispatcher,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+ scoped_ptr<blink::WebTaskRunner> task_runner);
WebURLLoaderClient* client() const { return client_; }
void set_client(WebURLLoaderClient* client) { client_ = client; }
@@ -267,6 +269,7 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
blink::WebThreadedDataReceiver* threaded_data_receiver);
void Start(const WebURLRequest& request,
SyncLoadResponse* sync_load_response);
+ void SetWebTaskRunner(scoped_ptr<blink::WebTaskRunner> task_runner);
// RequestPeer methods:
void OnUploadProgress(uint64 position, uint64 size) override;
@@ -295,6 +298,18 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
friend class base::RefCounted<Context>;
~Context() override;
+ class HandleDataURLTask : public blink::WebTaskRunner::Task {
+ public:
+ explicit HandleDataURLTask(Context* context) : context_(context) {}
Sami 2015/09/30 13:03:16 nit: scoped_refptr
alex clarke (OOO till 29th) 2015/09/30 13:37:17 Done.
+
+ void run() override {
+ context_->HandleDataURL();
+ }
+
+ private:
+ scoped_refptr<Context> context_;
+ };
+
// Called when the body data stream is detached from the reader side.
void CancelBodyStreaming();
// We can optimize the handling of data URLs in most cases.
@@ -305,7 +320,7 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
WebURLRequest request_;
WebURLLoaderClient* client_;
ResourceDispatcher* resource_dispatcher_;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ scoped_ptr<blink::WebTaskRunner> web_task_runner_;
WebReferrerPolicy referrer_policy_;
scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_;
scoped_ptr<MultipartResponseDelegate> multipart_delegate_;
@@ -319,11 +334,11 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
WebURLLoaderImpl::Context::Context(
WebURLLoaderImpl* loader,
ResourceDispatcher* resource_dispatcher,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner)
+ scoped_ptr<blink::WebTaskRunner> web_task_runner)
: loader_(loader),
client_(NULL),
resource_dispatcher_(resource_dispatcher),
- task_runner_(task_runner),
+ web_task_runner_(web_task_runner.Pass()),
referrer_policy_(blink::WebReferrerPolicyDefault),
defers_loading_(NOT_DEFERRING),
request_id_(-1) {
@@ -359,8 +374,11 @@ void WebURLLoaderImpl::Context::SetDefersLoading(bool value) {
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));
+ // TODO(alexclarke): Find a way to let blink and chromium FROM_HERE
+ // coexist.
+ web_task_runner_->postTask(
+ ::blink::WebTraceLocation(__FUNCTION__, __FILE__),
+ new HandleDataURLTask(this));
}
defers_loading_ = NOT_DEFERRING;
}
@@ -418,8 +436,11 @@ void WebURLLoaderImpl::Context::Start(const WebURLRequest& request,
GetInfoFromDataURL(sync_load_response->url, sync_load_response,
&sync_load_response->data);
} else {
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&Context::HandleDataURL, this));
+ // TODO(alexclarke): Find a way to let blink and chromium FROM_HERE
+ // coexist.
+ web_task_runner_->postTask(
+ ::blink::WebTraceLocation(__FUNCTION__, __FILE__),
+ new HandleDataURLTask(this));
}
return;
}
@@ -482,6 +503,7 @@ void WebURLLoaderImpl::Context::Start(const WebURLRequest& request,
GetRequestContextFrameTypeForWebURLRequest(request);
request_info.extra_data = request.extraData();
request_info.report_raw_headers = request.reportRawHeaders();
+ request_info.loading_web_task_runner.reset(web_task_runner_->clone());
scoped_refptr<ResourceRequestBody> request_body =
GetRequestBodyForWebURLRequest(request).get();
@@ -496,6 +518,11 @@ void WebURLLoaderImpl::Context::Start(const WebURLRequest& request,
request_info, request_body.get(), this);
}
+void WebURLLoaderImpl::Context::SetWebTaskRunner(
+ scoped_ptr<blink::WebTaskRunner> web_task_runner) {
+ web_task_runner_ = web_task_runner.Pass();
+}
+
void WebURLLoaderImpl::Context::OnUploadProgress(uint64 position, uint64 size) {
if (client_)
client_->didSendData(loader_, position, size);
@@ -841,8 +868,8 @@ void WebURLLoaderImpl::Context::HandleDataURL() {
WebURLLoaderImpl::WebURLLoaderImpl(
ResourceDispatcher* resource_dispatcher,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner)
- : context_(new Context(this, resource_dispatcher, task_runner)) {
+ scoped_ptr<blink::WebTaskRunner> web_task_runner)
+ : context_(new Context(this, resource_dispatcher, web_task_runner.Pass())) {
}
WebURLLoaderImpl::~WebURLLoaderImpl() {
@@ -1059,4 +1086,11 @@ bool WebURLLoaderImpl::attachThreadedDataReceiver(
return context_->AttachThreadedDataReceiver(threaded_data_receiver);
}
+void WebURLLoaderImpl::setLoadingTaskRunner(
+ blink::WebTaskRunner* loading_task_runner) {
+ // There's no guarantee on the lifetime of |loading_task_runner| so we take a
+ // copy.
+ context_->SetWebTaskRunner(make_scoped_ptr(loading_task_runner->clone()));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698