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

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

Issue 1229933010: move file access permission logic to DownloadResourceThrottle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments Created 5 years, 5 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: 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 fb83530036b1a2689245190a69dcf66fa2ebc21c..983d2725943135511671ca6a985e15158d29b9be 100644
--- a/chrome/browser/download/download_request_limiter.cc
+++ b/chrome/browser/download/download_request_limiter.cc
@@ -247,8 +247,10 @@ void DownloadRequestLimiter::TabDownloadState::NotifyCallbacks(bool allow) {
change_status = true;
}
- for (size_t i = 0; i < callbacks.size(); ++i)
- host_->ScheduleNotification(callbacks[i], allow);
+ for (size_t i = 0; i < callbacks.size(); ++i) {
+ BrowserThread::PostTask(
asanka 2015/07/20 20:15:24 Why invoke this on the IO thread? The callback is
qinmin 2015/07/20 22:11:02 typo, fixed.
+ BrowserThread::IO, FROM_HERE, base::Bind(callbacks[i], allow));
+ }
if (change_status)
set_download_status(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD);
@@ -279,22 +281,6 @@ DownloadRequestLimiter::GetDownloadStatus(content::WebContents* web_contents) {
return state ? state->download_status() : ALLOW_ONE_DOWNLOAD;
}
-void DownloadRequestLimiter::CanDownloadOnIOThread(
- int render_process_host_id,
- int render_view_id,
- const GURL& url,
- const std::string& request_method,
- const Callback& callback) {
- // This is invoked on the IO thread. Schedule the task to run on the UI
- // thread so that we can query UI state.
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&DownloadRequestLimiter::CanDownload, this,
- render_process_host_id, render_view_id, url,
- request_method, callback));
-}
-
DownloadRequestLimiter::TabDownloadState*
DownloadRequestLimiter::GetDownloadState(
content::WebContents* web_contents,
@@ -325,12 +311,12 @@ void DownloadRequestLimiter::CanDownload(int render_process_host_id,
tab_util::GetWebContentsByID(render_process_host_id, render_view_id);
if (!originating_contents) {
// The WebContents was closed, don't allow the download.
- ScheduleNotification(callback, false);
+ callback.Run(false);
return;
}
if (!originating_contents->GetDelegate()) {
- ScheduleNotification(callback, false);
+ callback.Run(false);
return;
}
@@ -360,7 +346,7 @@ void DownloadRequestLimiter::OnCanDownloadDecided(
content::WebContents* originating_contents =
tab_util::GetWebContentsByID(render_process_host_id, render_view_id);
if (!originating_contents || !allow) {
- ScheduleNotification(orig_callback, false);
+ orig_callback.Run(false);
return;
}
@@ -388,18 +374,18 @@ void DownloadRequestLimiter::CanDownloadImpl(
if (state->download_count() && !(state->download_count() %
DownloadRequestLimiter::kMaxDownloadsAtOnce))
state->set_download_status(PROMPT_BEFORE_DOWNLOAD);
- ScheduleNotification(callback, true);
+ callback.Run(true);
state->increment_download_count();
break;
case ALLOW_ONE_DOWNLOAD:
state->set_download_status(PROMPT_BEFORE_DOWNLOAD);
- ScheduleNotification(callback, true);
+ callback.Run(true);
state->increment_download_count();
break;
case DOWNLOADS_NOT_ALLOWED:
- ScheduleNotification(callback, false);
+ callback.Run(false);
break;
case PROMPT_BEFORE_DOWNLOAD: {
@@ -419,7 +405,7 @@ void DownloadRequestLimiter::CanDownloadImpl(
originating_contents);
if (settings)
settings->SetDownloadsBlocked(false);
- ScheduleNotification(callback, true);
+ callback.Run(true);
state->increment_download_count();
return;
}
@@ -429,7 +415,7 @@ void DownloadRequestLimiter::CanDownloadImpl(
originating_contents);
if (settings)
settings->SetDownloadsBlocked(true);
- ScheduleNotification(callback, false);
+ callback.Run(false);
return;
}
case CONTENT_SETTING_DEFAULT:
@@ -451,12 +437,6 @@ void DownloadRequestLimiter::CanDownloadImpl(
}
}
-void DownloadRequestLimiter::ScheduleNotification(const Callback& callback,
- bool allow) {
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE, base::Bind(callback, allow));
-}
-
void DownloadRequestLimiter::Remove(TabDownloadState* state,
content::WebContents* contents) {
DCHECK(ContainsKey(state_map_, contents));

Powered by Google App Engine
This is Rietveld 408576698