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

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

Issue 1467563002: Use ResourceRequestInfo::GetWebContents in DownloadRequestLimiter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-contents-callback
Patch Set: Addressed davidben's comments Created 5 years 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_request_limiter.cc
diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc
index 238bcbd42b6e825bec53b20f9d3131e98accbda6..c2d400491032961ffb1ca4ff485059cd1ff40407 100644
--- a/chrome/browser/download/download_request_limiter.cc
+++ b/chrome/browser/download/download_request_limiter.cc
@@ -306,15 +306,14 @@ DownloadRequestLimiter::GetDownloadState(
return state;
}
-void DownloadRequestLimiter::CanDownload(int render_process_host_id,
- int render_view_id,
- const GURL& url,
- const std::string& request_method,
- const Callback& callback) {
+void DownloadRequestLimiter::CanDownload(
+ const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
+ const GURL& url,
+ const std::string& request_method,
+ const Callback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- content::WebContents* originating_contents =
- tab_util::GetWebContentsByID(render_process_host_id, render_view_id);
+ content::WebContents* originating_contents = web_contents_getter.Run();
if (!originating_contents) {
// The WebContents was closed, don't allow the download.
callback.Run(false);
@@ -330,12 +329,8 @@ void DownloadRequestLimiter::CanDownload(int render_process_host_id,
// OnCanDownloadDecided is invoked, we look it up by |render_process_host_id|
// and |render_view_id|.
base::Callback<void(bool)> can_download_callback = base::Bind(
- &DownloadRequestLimiter::OnCanDownloadDecided,
- factory_.GetWeakPtr(),
- render_process_host_id,
- render_view_id,
- request_method,
- callback);
+ &DownloadRequestLimiter::OnCanDownloadDecided, factory_.GetWeakPtr(),
+ web_contents_getter, request_method, callback);
originating_contents->GetDelegate()->CanDownload(
url,
@@ -344,13 +339,12 @@ void DownloadRequestLimiter::CanDownload(int render_process_host_id,
}
void DownloadRequestLimiter::OnCanDownloadDecided(
- int render_process_host_id,
- int render_view_id,
+ const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
const std::string& request_method,
- const Callback& orig_callback, bool allow) {
+ const Callback& orig_callback,
+ bool allow) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- content::WebContents* originating_contents =
- tab_util::GetWebContentsByID(render_process_host_id, render_view_id);
+ content::WebContents* originating_contents = web_contents_getter.Run();
if (!originating_contents || !allow) {
orig_callback.Run(false);
return;
« no previous file with comments | « chrome/browser/download/download_request_limiter.h ('k') | chrome/browser/download/download_resource_throttle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698