Index: content/browser/appcache/appcache_request_handler.cc |
diff --git a/content/browser/appcache/appcache_request_handler.cc b/content/browser/appcache/appcache_request_handler.cc |
index 870fa7d35200c73a52989a24241190d1cd360aa3..22a1f45306baae754442a2ae02f59286fd2d1c00 100644 |
--- a/content/browser/appcache/appcache_request_handler.cc |
+++ b/content/browser/appcache/appcache_request_handler.cc |
@@ -9,10 +9,16 @@ |
#include "base/bind.h" |
#include "content/browser/appcache/appcache.h" |
#include "content/browser/appcache/appcache_backend_impl.h" |
+#include "content/browser/appcache/appcache_host.h" |
+#include "content/browser/appcache/appcache_navigation_handle_core.h" |
#include "content/browser/appcache/appcache_policy.h" |
#include "content/browser/appcache/appcache_request.h" |
+#include "content/browser/appcache/appcache_url_loader_factory.h" |
+#include "content/browser/appcache/appcache_url_loader_job.h" |
+#include "content/browser/appcache/appcache_url_loader_request.h" |
#include "content/browser/appcache/appcache_url_request_job.h" |
#include "content/browser/service_worker/service_worker_request_handler.h" |
+#include "content/browser/url_loader_factory_getter.h" |
#include "net/url_request/url_request.h" |
#include "net/url_request/url_request_job.h" |
@@ -223,6 +229,20 @@ void AppCacheRequestHandler::MaybeCompleteCrossSiteTransferInOldProcess( |
CompleteCrossSiteTransfer(old_process_id_, old_host_id_); |
} |
+// static |
+std::unique_ptr<AppCacheRequestHandler> |
+AppCacheRequestHandler::InitializeForNavigationNetworkService( |
+ const ResourceRequest& request, |
+ AppCacheNavigationHandleCore* appcache_handle_core, |
+ URLLoaderFactoryGetter* url_loader_factory_getter) { |
+ std::unique_ptr<AppCacheRequestHandler> handler = |
+ appcache_handle_core->host()->CreateRequestHandler( |
+ AppCacheURLLoaderRequest::Create(request), request.resource_type, |
+ request.should_reset_appcache); |
+ handler->url_loader_factory_getter_ = url_loader_factory_getter; |
+ return handler; |
+} |
+ |
void AppCacheRequestHandler::OnDestructionImminent(AppCacheHost* host) { |
storage()->CancelDelegateCallbacks(this); |
host_ = NULL; // no need to RemoveObserver, the host is being deleted |
@@ -264,6 +284,13 @@ void AppCacheRequestHandler::DeliverAppCachedResponse( |
if (IsResourceTypeFrame(resource_type_) && !namespace_entry_url.is_empty()) |
host_->NotifyMainResourceIsNamespaceEntry(namespace_entry_url); |
+ if (navigation_request_job_.get()) { |
+ AppCacheURLLoaderFactory::CreateURLLoaderFactory( |
+ mojo::MakeRequest(&appcache_factory_), |
+ url_loader_factory_getter_.get(), |
+ navigation_request_job_.release()); |
+ std::move(loader_factory_callback_).Run(appcache_factory_.get()); |
+ } |
job_->DeliverAppCachedResponse(manifest_url, cache_id, entry, is_fallback); |
} |
@@ -278,6 +305,16 @@ void AppCacheRequestHandler::DeliverNetworkResponse() { |
DCHECK(job_.get() && job_->IsWaiting()); |
DCHECK_EQ(kAppCacheNoCacheId, cache_id_); |
DCHECK(manifest_url_.is_empty()); |
+ |
+ // In network service land, if we are processing a navigation request, we |
+ // need to inform the loader callback that we are not going to handle this |
+ // request. |
+ if (navigation_request_job_.get()) { |
+ std::move(loader_factory_callback_).Run(nullptr); |
+ navigation_request_job_.reset(nullptr); |
+ return; |
+ } |
+ |
job_->DeliverNetworkResponse(); |
} |
@@ -316,12 +353,22 @@ std::unique_ptr<AppCacheJob> AppCacheRequestHandler::MaybeLoadMainResource( |
// If a page falls into the scope of a ServiceWorker, any matching AppCaches |
// should be ignored. This depends on the ServiceWorker handler being invoked |
// prior to the AppCache handler. |
- if (ServiceWorkerRequestHandler::IsControlledByServiceWorker( |
+ // TODO(ananta) |
+ // We need to handle this for AppCache requests initiated for the network |
+ // service |
+ if (request_->GetURLRequest() && |
+ ServiceWorkerRequestHandler::IsControlledByServiceWorker( |
request_->GetURLRequest())) { |
host_->enable_cache_selection(false); |
return nullptr; |
} |
+ if (storage()->IsInitialized() && |
+ service_->storage()->usage_map()->find(request_->GetURL().GetOrigin()) == |
+ service_->storage()->usage_map()->end()) { |
+ return nullptr; |
+ } |
+ |
host_->enable_cache_selection(true); |
const AppCacheHost* spawning_host = |
@@ -503,4 +550,18 @@ void AppCacheRequestHandler::OnCacheSelectionComplete(AppCacheHost* host) { |
ContinueMaybeLoadSubResource(); |
} |
+void AppCacheRequestHandler::MaybeCreateLoaderFactory( |
+ const ResourceRequest& resource_request, |
+ ResourceContext* resource_context, |
+ LoaderFactoryCallback callback) { |
kinuko
2017/06/06 08:07:30
(As michael wrote we're likely changing this part,
ananta
2017/06/06 20:49:15
Will keep an eye out :)
|
+ navigation_request_job_ = MaybeLoadMainResource(nullptr); |
+ if (!navigation_request_job_.get()) { |
+ std::move(callback).Run(nullptr); |
+ return; |
+ } |
+ navigation_request_job_->AsURLLoaderJob()->SetURLLoaderFactoryGetter( |
+ url_loader_factory_getter_.get()); |
+ loader_factory_callback_ = std::move(callback); |
+} |
+ |
} // namespace content |