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

Unified Diff: content/browser/download/download_resource_handler.cc

Issue 1924473003: [Downloads] Use the initiating StoragePartition for resumption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in comment Created 4 years, 7 months 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/download/download_resource_handler.cc
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc
index 310da2ebe3c0afe201ebbe4dca003da25fb4cb0a..fabe1d629191f8c1ccae0bd3ea4a8360f9b5603d 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_interrupt_reasons.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/resource_response.h"
@@ -39,12 +40,16 @@ static void StartOnUIThread(
std::unique_ptr<DownloadCreateInfo> info,
std::unique_ptr<DownloadResourceHandler::DownloadTabInfo> tab_info,
std::unique_ptr<ByteStreamReader> stream,
+ int render_process_id,
+ int render_frame_id,
const DownloadUrlParameters::OnStartedCallback& started_cb) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ RenderFrameHost* frame_host =
+ RenderFrameHost::FromID(render_process_id, render_frame_id);
DownloadManager* download_manager =
info->request_handle->GetDownloadManager();
- if (!download_manager) {
+ if (!download_manager || !frame_host) {
// NULL in unittests or if the page closed right after starting the
// download.
if (!started_cb.is_null())
@@ -58,6 +63,7 @@ static void StartOnUIThread(
info->tab_url = tab_info->tab_url;
info->tab_referrer_url = tab_info->tab_referrer_url;
+ info->site_url = frame_host->GetSiteInstance()->GetSiteURL();
download_manager->StartDownload(std::move(info), std::move(stream),
started_cb);
@@ -189,11 +195,15 @@ void DownloadResourceHandler::OnStart(
create_info->request_handle.reset(new DownloadRequestHandle(
AsWeakPtr(), request_info->GetWebContentsGetterForRequest()));
+ int render_process_id = -1;
+ int render_frame_id = -1;
+ request_info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id);
+
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&StartOnUIThread, base::Passed(&create_info),
base::Passed(&tab_info_), base::Passed(&stream_reader),
- callback));
+ render_process_id, render_frame_id, callback));
}
void DownloadResourceHandler::OnReadyToRead() {
« no previous file with comments | « content/browser/download/download_request_core.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698