Index: content/browser/download/download_manager_impl.cc |
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc |
index 8131d2740b1bbc811762e9fd9e361eda65287c10..aca05d2741b1a6d8864070ae221af50cebd2c45f 100644 |
--- a/content/browser/download/download_manager_impl.cc |
+++ b/content/browser/download/download_manager_impl.cc |
@@ -32,6 +32,7 @@ |
#include "content/browser/loader/resource_dispatcher_host_impl.h" |
#include "content/browser/loader/resource_request_info_impl.h" |
#include "content/browser/renderer_host/render_view_host_impl.h" |
+#include "content/browser/service_worker/service_worker_context_wrapper.h" |
#include "content/browser/web_contents/web_contents_impl.h" |
#include "content/public/browser/browser_context.h" |
#include "content/public/browser/content_browser_client.h" |
@@ -42,6 +43,7 @@ |
#include "content/public/browser/notification_types.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/resource_context.h" |
+#include "content/public/browser/storage_partition.h" |
#include "content/public/browser/web_contents_delegate.h" |
#include "content/public/common/referrer.h" |
#include "net/base/elements_upload_data_stream.h" |
@@ -60,6 +62,7 @@ namespace { |
std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> BeginDownload( |
std::unique_ptr<DownloadUrlParameters> params, |
content::ResourceContext* resource_context, |
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, |
uint32_t download_id, |
base::WeakPtr<DownloadManagerImpl> download_manager) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
@@ -80,9 +83,10 @@ std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> BeginDownload( |
if (params->render_process_host_id() >= 0) { |
DownloadInterruptReason reason = DownloadManagerImpl::BeginDownloadRequest( |
std::move(url_request), params->referrer(), resource_context, |
- params->content_initiated(), params->render_process_host_id(), |
- params->render_view_host_routing_id(), |
+ service_worker_context.get(), params->content_initiated(), |
+ params->render_process_host_id(), params->render_view_host_routing_id(), |
params->render_frame_host_routing_id(), |
+ params->service_worker_provider_id(), |
params->do_not_prompt_for_login()); |
// If the download was accepted, the DownloadResourceHandler is now |
@@ -483,7 +487,8 @@ void DownloadManagerImpl::ResumeInterruptedDownload( |
BrowserThread::PostTaskAndReplyWithResult( |
BrowserThread::IO, FROM_HERE, |
base::Bind(&BeginDownload, base::Passed(¶ms), |
- browser_context_->GetResourceContext(), id, |
+ browser_context_->GetResourceContext(), |
+ scoped_refptr<ServiceWorkerContextWrapper>(), id, |
weak_factory_.GetWeakPtr()), |
base::Bind(&DownloadManagerImpl::AddUrlDownloader, |
weak_factory_.GetWeakPtr())); |
@@ -533,10 +538,12 @@ DownloadInterruptReason DownloadManagerImpl::BeginDownloadRequest( |
std::unique_ptr<net::URLRequest> url_request, |
const Referrer& referrer, |
ResourceContext* resource_context, |
+ ServiceWorkerContextWrapper* service_worker_context, |
bool is_content_initiated, |
int render_process_id, |
int render_view_route_id, |
int render_frame_route_id, |
+ int service_worker_provider_id, |
bool do_not_prompt_for_login) { |
if (ResourceDispatcherHostImpl::Get()->is_shutdown()) |
return DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN; |
@@ -547,7 +554,7 @@ DownloadInterruptReason DownloadManagerImpl::BeginDownloadRequest( |
url_request.get(), referrer, |
true, // download. |
render_process_id, render_view_route_id, render_frame_route_id, |
- resource_context); |
+ service_worker_provider_id, resource_context, service_worker_context); |
// We treat a download as a main frame load, and thus update the policy URL on |
// redirects. |
@@ -645,6 +652,16 @@ int DownloadManagerImpl::RemoveAllDownloads() { |
void DownloadManagerImpl::DownloadUrl( |
std::unique_ptr<DownloadUrlParameters> params) { |
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context; |
+ RenderProcessHost* render_process_host = |
+ RenderProcessHost::FromID(params->render_process_host_id()); |
+ if (render_process_host) { |
+ StoragePartition* partition = render_process_host->GetStoragePartition(); |
+ if (partition) { |
+ service_worker_context = static_cast<ServiceWorkerContextWrapper*>( |
+ partition->GetServiceWorkerContext()); |
+ } |
+ } |
if (params->post_id() >= 0) { |
// Check this here so that the traceback is more useful. |
DCHECK(params->prefer_cache()); |
@@ -654,6 +671,7 @@ void DownloadManagerImpl::DownloadUrl( |
BrowserThread::IO, FROM_HERE, |
base::Bind(&BeginDownload, base::Passed(¶ms), |
browser_context_->GetResourceContext(), |
+ std::move(service_worker_context), |
content::DownloadItem::kInvalidId, weak_factory_.GetWeakPtr()), |
base::Bind(&DownloadManagerImpl::AddUrlDownloader, |
weak_factory_.GetWeakPtr())); |