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

Side by Side Diff: content/browser/loader/mojo_async_resource_handler.cc

Issue 2496193002: Implement transfer navigation with mojo (Closed)
Patch Set: rebase Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/loader/mojo_async_resource_handler.h" 5 #include "content/browser/loader/mojo_async_resource_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 }; 103 };
104 104
105 MojoAsyncResourceHandler::MojoAsyncResourceHandler( 105 MojoAsyncResourceHandler::MojoAsyncResourceHandler(
106 net::URLRequest* request, 106 net::URLRequest* request,
107 ResourceDispatcherHostImpl* rdh, 107 ResourceDispatcherHostImpl* rdh,
108 mojom::URLLoaderAssociatedRequest mojo_request, 108 mojom::URLLoaderAssociatedRequest mojo_request,
109 mojom::URLLoaderClientAssociatedPtr url_loader_client) 109 mojom::URLLoaderClientAssociatedPtr url_loader_client)
110 : ResourceHandler(request), 110 : ResourceHandler(request),
111 rdh_(rdh), 111 rdh_(rdh),
112 binding_(this, std::move(mojo_request)), 112 binding_(this, std::move(mojo_request)),
113 url_loader_client_(std::move(url_loader_client)) { 113 url_loader_client_(std::move(url_loader_client)),
114 weak_factory_(this) {
114 DCHECK(url_loader_client_); 115 DCHECK(url_loader_client_);
115 InitializeResourceBufferConstants(); 116 InitializeResourceBufferConstants();
116 // This unretained pointer is safe, because |binding_| is owned by |this| and 117 // This unretained pointer is safe, because |binding_| is owned by |this| and
117 // the callback will never be called after |this| is destroyed. 118 // the callback will never be called after |this| is destroyed.
118 binding_.set_connection_error_handler( 119 binding_.set_connection_error_handler(
119 base::Bind(&MojoAsyncResourceHandler::Cancel, base::Unretained(this))); 120 base::Bind(&MojoAsyncResourceHandler::Cancel, base::Unretained(this)));
121
122 GetRequestInfo()->set_on_transfer(base::Bind(
123 &MojoAsyncResourceHandler::OnTransfer, weak_factory_.GetWeakPtr()));
120 } 124 }
121 125
122 MojoAsyncResourceHandler::~MojoAsyncResourceHandler() { 126 MojoAsyncResourceHandler::~MojoAsyncResourceHandler() {
123 if (has_checked_for_sufficient_resources_) 127 if (has_checked_for_sufficient_resources_)
124 rdh_->FinishedWithResourcesForRequest(request()); 128 rdh_->FinishedWithResourcesForRequest(request());
125 } 129 }
126 130
127 bool MojoAsyncResourceHandler::OnRequestRedirected( 131 bool MojoAsyncResourceHandler::OnRequestRedirected(
128 const net::RedirectInfo& redirect_info, 132 const net::RedirectInfo& redirect_info,
129 ResourceResponse* response, 133 ResourceResponse* response,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 void MojoAsyncResourceHandler::Cancel() { 434 void MojoAsyncResourceHandler::Cancel() {
431 const ResourceRequestInfoImpl* info = GetRequestInfo(); 435 const ResourceRequestInfoImpl* info = GetRequestInfo();
432 ResourceDispatcherHostImpl::Get()->CancelRequestFromRenderer( 436 ResourceDispatcherHostImpl::Get()->CancelRequestFromRenderer(
433 GlobalRequestID(info->GetChildID(), info->GetRequestID())); 437 GlobalRequestID(info->GetChildID(), info->GetRequestID()));
434 } 438 }
435 439
436 void MojoAsyncResourceHandler::ReportBadMessage(const std::string& error) { 440 void MojoAsyncResourceHandler::ReportBadMessage(const std::string& error) {
437 mojo::ReportBadMessage(error); 441 mojo::ReportBadMessage(error);
438 } 442 }
439 443
444 void MojoAsyncResourceHandler::OnTransfer(
445 mojom::URLLoaderAssociatedRequest mojo_request,
446 mojom::URLLoaderClientAssociatedPtr url_loader_client) {
447 binding_.Unbind();
448 binding_.Bind(std::move(mojo_request));
449 binding_.set_connection_error_handler(
450 base::Bind(&MojoAsyncResourceHandler::Cancel, base::Unretained(this)));
451 url_loader_client_ = std::move(url_loader_client);
452 }
453
440 } // namespace content 454 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698