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

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

Issue 2496193002: Implement transfer navigation with mojo (Closed)
Patch Set: fix 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/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 4117eae4cdc25ff63a0a9027ed0d186bd863423c..13a8b0273f7bccfd88f154520572eb024b84e7cd 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -1200,7 +1200,9 @@ void ResourceDispatcherHostImpl::UpdateRequestForTransfer(
void ResourceDispatcherHostImpl::CompleteTransfer(
int request_id,
const ResourceRequest& request_data,
- int route_id) {
+ int route_id,
+ mojom::URLLoaderAssociatedRequest mojo_request,
+ mojom::URLLoaderClientAssociatedPtr url_loader_client) {
// Caller should ensure that |request_data| is associated with a transfer.
DCHECK(request_data.transferred_request_child_id != -1 ||
request_data.transferred_request_request_id != -1);
@@ -1245,7 +1247,8 @@ void ResourceDispatcherHostImpl::CompleteTransfer(
// state and let it resume with its existing ResourceHandlers.
UpdateRequestForTransfer(filter_->child_id(), route_id, request_id,
request_data, it);
- pending_loader->CompleteTransfer();
+ pending_loader->CompleteTransfer(std::move(mojo_request),
+ std::move(url_loader_client));
}
void ResourceDispatcherHostImpl::BeginRequest(
@@ -1294,10 +1297,8 @@ void ResourceDispatcherHostImpl::BeginRequest(
// we want to reuse and resume the old loader rather than start a new one.
if (request_data.transferred_request_child_id != -1 ||
request_data.transferred_request_request_id != -1) {
- // TODO(yhirano): Make mojo work for this case.
- DCHECK(!url_loader_client);
-
- CompleteTransfer(request_id, request_data, route_id);
+ CompleteTransfer(request_id, request_data, route_id,
+ std::move(mojo_request), std::move(url_loader_client));
return;
}
@@ -1598,6 +1599,7 @@ ResourceDispatcherHostImpl::CreateResourceHandler(
ResourceContext* resource_context,
mojom::URLLoaderAssociatedRequest mojo_request,
mojom::URLLoaderClientAssociatedPtr url_loader_client) {
+ TransferCallback transfer_callback;
// TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
tracked_objects::ScopedTracker tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
@@ -1616,9 +1618,10 @@ ResourceDispatcherHostImpl::CreateResourceHandler(
handler.reset(new SyncResourceHandler(request, sync_result_handler, this));
} else {
if (mojo_request.is_pending()) {
- handler.reset(new MojoAsyncResourceHandler(request, this,
- std::move(mojo_request),
- std::move(url_loader_client)));
+ auto mojo_handler = base::MakeUnique<MojoAsyncResourceHandler>(
+ request, this, std::move(mojo_request), std::move(url_loader_client));
+ transfer_callback = mojo_handler->GetTransferCallback();
+ handler = std::move(mojo_handler);
} else {
handler.reset(new AsyncResourceHandler(request, this));
}
@@ -1649,7 +1652,7 @@ ResourceDispatcherHostImpl::CreateResourceHandler(
return AddStandardHandlers(
request, request_data.resource_type, resource_context,
request_data.fetch_request_context_type, filter_->appcache_service(),
- child_id, route_id, std::move(handler));
+ child_id, route_id, std::move(handler), transfer_callback);
}
std::unique_ptr<ResourceHandler>
@@ -1661,7 +1664,8 @@ ResourceDispatcherHostImpl::AddStandardHandlers(
AppCacheService* appcache_service,
int child_id,
int route_id,
- std::unique_ptr<ResourceHandler> handler) {
+ std::unique_ptr<ResourceHandler> handler,
+ TransferCallback transfer_callback) {
// PlzNavigate: do not add ResourceThrottles for main resource requests from
// the renderer. Decisions about the navigation should have been done in the
// initial request.
@@ -1687,7 +1691,7 @@ ResourceDispatcherHostImpl::AddStandardHandlers(
// thread is handled by the NavigationURLloader.
if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) {
throttles.push_back(new NavigationResourceThrottle(
- request, delegate_, fetch_request_context_type));
+ request, delegate_, fetch_request_context_type, transfer_callback));
}
if (delegate_) {
@@ -1863,7 +1867,7 @@ void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id,
void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
const GlobalRequestID& id,
- const base::Closure& on_transfer_complete_callback) {
+ const TransferCallback& on_transfer_complete_callback) {
GetLoader(id)->MarkAsTransferring(on_transfer_complete_callback);
}
@@ -1879,7 +1883,7 @@ void ResourceDispatcherHostImpl::ResumeDeferredNavigation(
ResourceLoader* loader = GetLoader(id);
// The response we were meant to resume could have already been canceled.
if (loader)
- loader->CompleteTransfer();
+ loader->CompleteTransfer(nullptr, nullptr);
}
// The object died, so cancel and detach all requests associated with it except
@@ -2263,7 +2267,7 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
nullptr, // appcache_service
-1, // child_id
-1, // route_id
- std::move(handler));
+ std::move(handler), {});
BeginRequestInternal(std::move(new_request), std::move(handler));
}

Powered by Google App Engine
This is Rietveld 408576698