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

Unified Diff: chrome/browser/download/download_resource_throttle.cc

Issue 1467563002: Use ResourceRequestInfo::GetWebContents in DownloadRequestLimiter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-contents-callback
Patch Set: Created 5 years, 1 month 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: chrome/browser/download/download_resource_throttle.cc
diff --git a/chrome/browser/download/download_resource_throttle.cc b/chrome/browser/download/download_resource_throttle.cc
index 9578d33917c9b49fb6436628a5c220f5694faab0..7a72cf1b496c84aa543c978d1c60df868701443e 100644
--- a/chrome/browser/download/download_resource_throttle.cc
+++ b/chrome/browser/download/download_resource_throttle.cc
@@ -30,9 +30,8 @@ void OnCanDownloadDecided(base::WeakPtr<DownloadResourceThrottle> throttle,
void CanDownload(
scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- info->limiter->CanDownload(info->render_process_id, info->render_view_id,
- info->url, info->request_method,
- info->continue_callback);
+ info->limiter->CanDownload(info->web_contents_getter, info->url,
davidben 2015/11/24 15:51:16 Since we're already on the UI thread, I'd probably
clamy 2015/11/25 14:02:02 If I do that though I have to get back a RPH + RFH
+ info->request_method, info->continue_callback);
}
#if defined(OS_ANDROID)
@@ -51,11 +50,10 @@ void CanDownloadOnUIThread(
scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
#if defined(OS_ANDROID)
- int process_id = info->render_process_id;
- int render_view_id = info->render_view_id;
content::DownloadControllerAndroid::Get()->AcquireFileAccessPermission(
- process_id, render_view_id, base::Bind(&OnAcquireFileAccessPermissionDone,
- base::Passed(info.Pass())));
+ info->web_contents_getter.Run(),
+ base::Bind(&OnAcquireFileAccessPermissionDone,
+ base::Passed(info.Pass())));
#else
CanDownload(info.Pass());
#endif
@@ -65,14 +63,12 @@ void CanDownloadOnUIThread(
DownloadResourceThrottle::DownloadRequestInfo::DownloadRequestInfo(
scoped_refptr<DownloadRequestLimiter> limiter,
- int render_process_id,
- int render_view_id,
+ const base::Callback<content::WebContents*(void)>& web_contents_getter,
const GURL& url,
const std::string& request_method,
const DownloadRequestLimiter::Callback& continue_callback)
: limiter(limiter),
- render_process_id(render_process_id),
- render_view_id(render_view_id),
+ web_contents_getter(web_contents_getter),
url(url),
request_method(request_method),
continue_callback(continue_callback) {}
@@ -81,8 +77,7 @@ DownloadResourceThrottle::DownloadRequestInfo::~DownloadRequestInfo() {}
DownloadResourceThrottle::DownloadResourceThrottle(
scoped_refptr<DownloadRequestLimiter> limiter,
- int render_process_id,
- int render_view_id,
+ const base::Callback<content::WebContents*(void)>& web_contents_getter,
const GURL& url,
const std::string& request_method)
: querying_limiter_(true),
@@ -94,7 +89,7 @@ DownloadResourceThrottle::DownloadResourceThrottle(
base::Bind(
&CanDownloadOnUIThread,
base::Passed(scoped_ptr<DownloadRequestInfo>(new DownloadRequestInfo(
- limiter, render_process_id, render_view_id, url, request_method,
+ limiter, web_contents_getter, url, request_method,
base::Bind(&OnCanDownloadDecided, AsWeakPtr()))))));
}

Powered by Google App Engine
This is Rietveld 408576698