diff options
author | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 17:28:26 +0000 |
---|---|---|
committer | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 17:28:26 +0000 |
commit | bf68a00b0b843605b1b8ecae30cfa12dc3c0a962 (patch) | |
tree | 8b9b74a22d633286a5dbf6c75000731c2bf6bed2 /chrome/browser/download/download_shelf.cc | |
parent | c975f51346a9c93ac54d7d9e51a7a8d7025a9b54 (diff) | |
download | chromium_src-bf68a00b0b843605b1b8ecae30cfa12dc3c0a962.zip chromium_src-bf68a00b0b843605b1b8ecae30cfa12dc3c0a962.tar.gz chromium_src-bf68a00b0b843605b1b8ecae30cfa12dc3c0a962.tar.bz2 |
Detect download errors.
When a download error occurs, we now mark it as "Interrupted", and display the new status on the Download Shelf.
This is handled through the OnResponseCompleted() method, from:
DownloadResourceHandler ->
DownloadFileManager ->
DownloadManager
The latter checks the error value, and if not zero calls DownloadError().
DownloadError() marks the download as interrupted (stopping the progress timer), updates the download history, and updates its Observers.
DownloadItem::DownloadState now has a new state, INTERRUPTED.
There are also new display strings that show up on interrupted downloads in the download shelf and download page.
BUG=35278
TEST=Pass unit and browser tests. Also, run a python server that behaves as described below, connect to it, and observe that "Interrupted" shows up in the item on the download shelf. Check that the item behaves as if it were cancelled.
The Python server should respond to a GET request with a content length that is large, then provide several chunks of data (but less than the specified length) and then send a 'No file' response (code 204) and close the connection.
Review URL: http://codereview.chromium.org/6613024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_shelf.cc')
-rw-r--r-- | chrome/browser/download/download_shelf.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/chrome/browser/download/download_shelf.cc b/chrome/browser/download/download_shelf.cc index 279368a..f490882 100644 --- a/chrome/browser/download/download_shelf.cc +++ b/chrome/browser/download/download_shelf.cc @@ -47,7 +47,7 @@ string16 DownloadShelfContextMenu::GetLabelForCommandId(int command_id) const { case SHOW_IN_FOLDER: return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_SHOW); case OPEN_WHEN_COMPLETE: - if (download_->state() == DownloadItem::IN_PROGRESS) + if (download_->IsInProgress()) return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE); return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN); case ALWAYS_OPEN_TYPE: @@ -70,13 +70,13 @@ bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const { switch (command_id) { case SHOW_IN_FOLDER: case OPEN_WHEN_COMPLETE: - return download_->state() != DownloadItem::CANCELLED; + return !download_->IsCancelled(); case ALWAYS_OPEN_TYPE: return download_->CanOpenDownload(); case CANCEL: - return download_->state() == DownloadItem::IN_PROGRESS; + return download_->IsPartialDownload(); case TOGGLE_PAUSE: - return download_->state() == DownloadItem::IN_PROGRESS; + return download_->IsInProgress(); default: return command_id > 0 && command_id < MENU_LAST; } @@ -102,7 +102,7 @@ void DownloadShelfContextMenu::ExecuteCommand(int command_id) { // It is possible for the download to complete before the user clicks the // menu item, recheck if the download is in progress state before toggling // pause. - if (download_->state() == DownloadItem::IN_PROGRESS) + if (download_->IsPartialDownload()) download_->TogglePause(); break; default: |