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

Unified Diff: content/browser/loader/mojo_async_resource_handler.cc

Issue 2919313004: Get rid of URLLoaderFactory in browser-side case (Closed)
Patch Set: . Created 3 years, 6 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/browser/loader/mojo_async_resource_handler.cc
diff --git a/content/browser/loader/mojo_async_resource_handler.cc b/content/browser/loader/mojo_async_resource_handler.cc
index 7ec6e4a697360e5a19ec2908c1840adf8f15cfef..08f65045f2e2a986148e8a421515493acdb40715 100644
--- a/content/browser/loader/mojo_async_resource_handler.cc
+++ b/content/browser/loader/mojo_async_resource_handler.cc
@@ -120,16 +120,12 @@ MojoAsyncResourceHandler::MojoAsyncResourceHandler(
ResourceType resource_type)
: ResourceHandler(request),
rdh_(rdh),
- binding_(this, std::move(mojo_request)),
+ binding_(this),
handle_watcher_(FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::MANUAL),
- url_loader_client_(std::move(url_loader_client)),
weak_factory_(this) {
- DCHECK(url_loader_client_);
+ Start(std::move(mojo_request), std::move(url_loader_client));
+
InitializeResourceBufferConstants();
- // This unretained pointer is safe, because |binding_| is owned by |this| and
- // the callback will never be called after |this| is destroyed.
- binding_.set_connection_error_handler(
- base::Bind(&MojoAsyncResourceHandler::Cancel, base::Unretained(this)));
if (IsResourceTypeFrame(resource_type)) {
GetRequestInfo()->set_on_transfer(base::Bind(
@@ -466,6 +462,21 @@ void MojoAsyncResourceHandler::OnResponseCompleted(
controller->Resume();
}
+void MojoAsyncResourceHandler::Start(
+ mojom::URLLoaderAssociatedRequest mojo_request,
+ mojom::URLLoaderClientPtr url_loader_client) {
+ DCHECK(!binding_.is_bound());
+
+ binding_.Bind(std::move(mojo_request));
+ // This unretained pointer is safe, because |binding_| is owned by |this| and
+ // the callback will never be called after |this| is destroyed.
+ binding_.set_connection_error_handler(
+ base::Bind(&MojoAsyncResourceHandler::Cancel, base::Unretained(this)));
+
+ url_loader_client_ = std::move(url_loader_client);
+ DCHECK(url_loader_client_);
+}
+
bool MojoAsyncResourceHandler::CopyReadDataToDataPipe(bool* defer) {
while (buffer_bytes_read_ > 0) {
scoped_refptr<net::IOBufferWithSize> dest;

Powered by Google App Engine
This is Rietveld 408576698