| Index: content/browser/loader/navigation_url_loader_impl_core.cc
|
| diff --git a/content/browser/loader/navigation_url_loader_impl_core.cc b/content/browser/loader/navigation_url_loader_impl_core.cc
|
| index 7cbf6999946551028e17f588a2d5277e81119cff..517dc5ed78890c5783d6396b2e9f455bb5e670d9 100644
|
| --- a/content/browser/loader/navigation_url_loader_impl_core.cc
|
| +++ b/content/browser/loader/navigation_url_loader_impl_core.cc
|
| @@ -10,7 +10,9 @@
|
| #include "content/browser/frame_host/navigation_request_info.h"
|
| #include "content/browser/loader/navigation_resource_handler.h"
|
| #include "content/browser/loader/resource_dispatcher_host_impl.h"
|
| +#include "content/browser/service_worker/service_worker_context_wrapper.h"
|
| #include "content/common/navigation_params.h"
|
| +#include "content/common/service_worker/service_worker_types.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/stream_handle.h"
|
| #include "content/public/common/resource_response.h"
|
| @@ -20,8 +22,11 @@
|
| namespace content {
|
|
|
| NavigationURLLoaderImplCore::NavigationURLLoaderImplCore(
|
| - const base::WeakPtr<NavigationURLLoaderImpl>& loader)
|
| + const base::WeakPtr<NavigationURLLoaderImpl>& loader,
|
| + ServiceWorkerContext* service_worker_context)
|
| : loader_(loader),
|
| + service_worker_context_(
|
| + static_cast<ServiceWorkerContextWrapper*>(service_worker_context)),
|
| resource_handler_(nullptr) {
|
| // This object is created on the UI thread but otherwise is accessed and
|
| // deleted on the IO thread.
|
| @@ -47,8 +52,8 @@ void NavigationURLLoaderImplCore::Start(
|
| base::TimeTicks::Now()));
|
|
|
| ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
|
| - resource_context, frame_tree_node_id,
|
| - *request_info, this);
|
| + resource_context, frame_tree_node_id, *request_info, this,
|
| + service_worker_context_.get());
|
| }
|
|
|
| void NavigationURLLoaderImplCore::FollowRedirect() {
|
| @@ -58,6 +63,11 @@ void NavigationURLLoaderImplCore::FollowRedirect() {
|
| resource_handler_->FollowRedirect();
|
| }
|
|
|
| +void NavigationURLLoaderImplCore::SetServiceWorkerProviderHost(
|
| + scoped_ptr<ServiceWorkerProviderHost> service_worker_provider_host) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + service_worker_provider_host_ = service_worker_provider_host.Pass();
|
| +}
|
|
|
| void NavigationURLLoaderImplCore::NotifyRequestRedirected(
|
| const net::RedirectInfo& redirect_info,
|
| @@ -79,7 +89,12 @@ void NavigationURLLoaderImplCore::NotifyResponseStarted(
|
| ResourceResponse* response,
|
| scoped_ptr<StreamHandle> body) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| -
|
| + int navigation_provider_id = kInvalidServiceWorkerProviderId;
|
| + if (service_worker_provider_host_) {
|
| + navigation_provider_id = service_worker_provider_host_->provider_id();
|
| + service_worker_context_->RegisterNavigationProviderHost(
|
| + service_worker_provider_host_.Pass());
|
| + }
|
| // If, by the time the task reaches the UI thread, |loader_| has already been
|
| // destroyed, NotifyResponseStarted will not run. |body| will be destructed
|
| // and the request released at that point.
|
| @@ -92,7 +107,8 @@ void NavigationURLLoaderImplCore::NotifyResponseStarted(
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_,
|
| - response->DeepCopy(), base::Passed(&body)));
|
| + response->DeepCopy(), base::Passed(&body),
|
| + navigation_provider_id));
|
| }
|
|
|
| void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache,
|
|
|