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

Unified Diff: content/child/web_url_loader_impl.cc

Issue 1402103002: Revert of Revert "Post loading tasks on the appropriate WebFrameScheduler's queue." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « content/child/web_url_loader_impl.h ('k') | 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 bf669cc597b3bf8fbfa27cea9852543012e7d3f6..68851d43ee3c555d325fe6d257e5a6bfa804fbab 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 @@
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 @@
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,19 @@
friend class base::RefCounted<Context>;
~Context() override;
+ class HandleDataURLTask : public blink::WebTaskRunner::Task {
+ public:
+ explicit HandleDataURLTask(scoped_refptr<Context> context)
+ : context_(context) {}
+
+ 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 +321,7 @@
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 +335,11 @@
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 +375,11 @@
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 +437,11 @@
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 +504,7 @@
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();
@@ -494,6 +517,11 @@
request_id_ = resource_dispatcher_->StartAsync(
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) {
@@ -841,8 +869,8 @@
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 +1087,11 @@
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
« no previous file with comments | « content/child/web_url_loader_impl.h ('k') | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698