Ensure that redirected subresource requests in the AppCache URLLoader can be served out of the cache.
Subresource requests handled by the AppCacheSubresourceURLFactory can be redirected. The redirected
URL could potentially be served out of the AppCache. This patch provides support for the same.
Changes as below:
1. AppCacheURLLoaderJob now maintains a weak pointer to the AppCacheSubresourceURLFactory instance. This
is passed to the AppCacheRequestHandler::MaybeCreateSubresourceLoader function and from there to the
job.
2. When the AppCacheURLLoaderJob receives a redirect notification via a call to URLLoaderClient::OnReceiveRedirect(),
we remember the redirect information. When the caller invokes FollowRedirect(), we try to load the request out
of the AppCache via a call to the AppCacheRequestHandler::MaybeCreateSubresourceLoader() function.
3. The AppCacheSubresourceURLFactory class supports weak pointers and provides a method Restart() which is called by
the AppCacheURLLoaderJob when its FollowRedirect() method is called.
4. A new virtual method SetSubresourceFactory has been added to the WebApplicationCacheHostImpl class.
This is overridden by the RendererWebApplicationCacheHostImpl class and we set the AppCache
URLLoaderFactory instance on the RenderFrameImpl instance.
5. RenderFrameImpl now passes its routing_id to the RendererWebApplicationCacheHostImpl class when it creates it
This is used to lookup the RenderFrameImpl on which the factory is to be set.
6. A virtual function OnSetSubresourceFactory has been added to the AppCacheFrontend interface.
The proxy in the browser sends the IPC message AppCacheMsg_SetSubresourceFactory to the renderer.
The implementation in the renderer invokes the SetSubresourceFactory() method on the host where
the factory is passed off to the RenderFrameImpl.
7. The AppCacheUpdate job passes the subresource factory to the proxy when it receives the APPCACHE_CACHED_EVENT
event.
The rest of the changes are boilerplate changes.
BUG=715632, 759901
TEST=Covered by content browser test AppCacheNetworkServiceBrowserTest.VerifyRedirectedSubresourceAppCacheLoad
TBR=wfh
Change-Id: Id73749254d7c81d0c0fded65fb6185b7e913f76f
Reviewed-on: https://chromium-review.googlesource.com/633922
Commit-Queue: Ananta Iyengar <[email protected]>
Reviewed-by: Ananta Iyengar <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: Michael Nordman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#499235}
diff --git a/content/browser/appcache/appcache_frontend_proxy.h b/content/browser/appcache/appcache_frontend_proxy.h
index 65d03ee..91b211e 100644
--- a/content/browser/appcache/appcache_frontend_proxy.h
+++ b/content/browser/appcache/appcache_frontend_proxy.h
@@ -34,6 +34,9 @@
AppCacheLogLevel log_level,
const std::string& message) override;
void OnContentBlocked(int host_id, const GURL& manifest_url) override;
+ void OnSetSubresourceFactory(
+ int host_id,
+ mojo::MessagePipeHandle loader_factory_pipe_handle) override;
private:
IPC::Sender* sender_;