summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 19:09:43 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 19:09:43 +0000
commita3cc9413981beb27f56bd1709a3a807510497edc (patch)
tree7f3d55abb687f46ffbae20f7e094792be8c3a536 /chrome/browser/download
parenta4760beef9fef6c7610402b193e97a60583bc2f4 (diff)
downloadchromium_src-a3cc9413981beb27f56bd1709a3a807510497edc.zip
chromium_src-a3cc9413981beb27f56bd1709a3a807510497edc.tar.gz
chromium_src-a3cc9413981beb27f56bd1709a3a807510497edc.tar.bz2
Reverting to fix chromium linux 64 unit tests
Revert 42971 - Patch the Browser GDI crash with excessive downloads by restricting maximum number of downloads allowed at one time. When this limit is reached, we reprompt the user. BUG=39277 TEST=None Review URL: http://codereview.chromium.org/1417001 TBR=inferno@chromium.org Review URL: http://codereview.chromium.org/1572001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42972 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r--chrome/browser/download/download_request_infobar_delegate.cc4
-rw-r--r--chrome/browser/download/download_request_manager.cc38
-rw-r--r--chrome/browser/download/download_request_manager.h14
3 files changed, 9 insertions, 47 deletions
diff --git a/chrome/browser/download/download_request_infobar_delegate.cc b/chrome/browser/download/download_request_infobar_delegate.cc
index 88c83fc..3a6aa5d 100644
--- a/chrome/browser/download/download_request_infobar_delegate.cc
+++ b/chrome/browser/download/download_request_infobar_delegate.cc
@@ -51,9 +51,9 @@ std::wstring DownloadRequestInfoBarDelegate::GetButtonLabel(
bool DownloadRequestInfoBarDelegate::Accept() {
if (host_) {
host_->Accept();
+ host_ = NULL;
}
- // Accept() call will nullify host_ if no furthur prompts are required.
- return !host_;
+ return true;
}
bool DownloadRequestInfoBarDelegate::Cancel() {
diff --git a/chrome/browser/download/download_request_manager.cc b/chrome/browser/download/download_request_manager.cc
index 0ad74a0..4498233 100644
--- a/chrome/browser/download/download_request_manager.cc
+++ b/chrome/browser/download/download_request_manager.cc
@@ -135,37 +135,18 @@ void DownloadRequestManager::TabDownloadState::Observe(
}
void DownloadRequestManager::TabDownloadState::NotifyCallbacks(bool allow) {
+ if (infobar_) {
+ // Reset the delegate so we don't get notified again.
+ infobar_->set_host(NULL);
+ infobar_ = NULL;
+ }
status_ = allow ?
DownloadRequestManager::ALLOW_ALL_DOWNLOADS :
DownloadRequestManager::DOWNLOADS_NOT_ALLOWED;
std::vector<DownloadRequestManager::Callback*> callbacks;
- bool change_status = false;
-
- // Selectively send first few notifications only if number of downloads exceed
- // kMaxDownloadsAtOnce. In that case, we also retain the infobar instance and
- // don't close it. If allow is false, we send all the notifications to cancel
- // all remaining downloads and close the infobar.
- if (!allow || (callbacks_.size() < kMaxDownloadsAtOnce)) {
- if (infobar_) {
- // Reset the delegate so we don't get notified again.
- infobar_->set_host(NULL);
- infobar_ = NULL;
- }
- callbacks.swap(callbacks_);
- } else {
- std::vector<DownloadRequestManager::Callback*>::iterator start, end;
- start = callbacks_.begin();
- end = callbacks_.begin() + kMaxDownloadsAtOnce;
- callbacks.assign(start, end);
- callbacks_.erase(start, end);
- change_status = true;
- }
-
- for (size_t i = 0; i < callbacks.size(); ++i) {
+ callbacks.swap(callbacks_);
+ for (size_t i = 0; i < callbacks.size(); ++i)
host_->ScheduleNotification(callbacks[i], allow);
- }
- if (change_status)
- status_ = DownloadRequestManager::PROMPT_BEFORE_DOWNLOAD;
}
// DownloadRequestManager ------------------------------------------------------
@@ -266,11 +247,7 @@ void DownloadRequestManager::CanDownloadImpl(
&effective_tab->controller(), &originating_tab->controller(), true);
switch (state->download_status()) {
case ALLOW_ALL_DOWNLOADS:
- if (!(state->download_count() %
- DownloadRequestManager::kMaxDownloadsAtOnce))
- state->set_download_status(PROMPT_BEFORE_DOWNLOAD);
ScheduleNotification(callback, true);
- state->increment_download_count();
break;
case ALLOW_ONE_DOWNLOAD:
@@ -284,7 +261,6 @@ void DownloadRequestManager::CanDownloadImpl(
case PROMPT_BEFORE_DOWNLOAD:
state->PromptUserForDownload(effective_tab, callback);
- state->increment_download_count();
break;
default:
diff --git a/chrome/browser/download/download_request_manager.h b/chrome/browser/download/download_request_manager.h
index 97fa7f8..cea0536 100644
--- a/chrome/browser/download/download_request_manager.h
+++ b/chrome/browser/download/download_request_manager.h
@@ -51,9 +51,6 @@ class DownloadRequestManager
DOWNLOADS_NOT_ALLOWED
};
- // Max number of downloads before a "Prompt Before Download" Dialog is shown.
- static const size_t kMaxDownloadsAtOnce = 50;
-
// The callback from CanDownloadOnIOThread. This is invoked on the io thread.
class Callback {
public:
@@ -90,14 +87,6 @@ class DownloadRequestManager
return status_;
}
- // Number of "ALLOWED" downloads.
- void increment_download_count() {
- download_count_++;
- }
- size_t download_count() const {
- return download_count_;
- }
-
// Invoked when a user gesture occurs (mouse click, enter or space). This
// may result in invoking Remove on DownloadRequestManager.
void OnUserGesture();
@@ -125,7 +114,6 @@ class DownloadRequestManager
: host_(NULL),
controller_(NULL),
status_(DownloadRequestManager::ALLOW_ONE_DOWNLOAD),
- download_count_(0),
infobar_(NULL) {
}
@@ -148,8 +136,6 @@ class DownloadRequestManager
DownloadRequestManager::DownloadStatus status_;
- size_t download_count_;
-
// Callbacks we need to notify. This is only non-empty if we're showing a
// dialog.
// See description above CanDownloadOnIOThread for details on lifetime of