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

Unified 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 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 8936346e86d7d70e424a5240098e562f2cb1b1fe..f1d9660eff054562456bf46af18c89ad0b1d0475 100644
--- a/content/browser/loader/mojo_async_resource_handler.cc
+++ b/content/browser/loader/mojo_async_resource_handler.cc
@@ -110,13 +110,17 @@ MojoAsyncResourceHandler::MojoAsyncResourceHandler(
: ResourceHandler(request),
rdh_(rdh),
binding_(this, std::move(mojo_request)),
- url_loader_client_(std::move(url_loader_client)) {
+ url_loader_client_(std::move(url_loader_client)),
+ weak_factory_(this) {
DCHECK(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)));
+
+ GetRequestInfo()->set_on_transfer(base::Bind(
+ &MojoAsyncResourceHandler::OnTransfer, weak_factory_.GetWeakPtr()));
}
MojoAsyncResourceHandler::~MojoAsyncResourceHandler() {
@@ -437,4 +441,14 @@ void MojoAsyncResourceHandler::ReportBadMessage(const std::string& error) {
mojo::ReportBadMessage(error);
}
+void MojoAsyncResourceHandler::OnTransfer(
+ mojom::URLLoaderAssociatedRequest mojo_request,
+ mojom::URLLoaderClientAssociatedPtr url_loader_client) {
+ binding_.Unbind();
+ binding_.Bind(std::move(mojo_request));
+ binding_.set_connection_error_handler(
+ base::Bind(&MojoAsyncResourceHandler::Cancel, base::Unretained(this)));
+ url_loader_client_ = std::move(url_loader_client);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698