summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history
diff options
context:
space:
mode:
authorahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 17:28:26 +0000
committerahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 17:28:26 +0000
commitbf68a00b0b843605b1b8ecae30cfa12dc3c0a962 (patch)
tree8b9b74a22d633286a5dbf6c75000731c2bf6bed2 /chrome/browser/history
parentc975f51346a9c93ac54d7d9e51a7a8d7025a9b54 (diff)
downloadchromium_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/history')
-rw-r--r--chrome/browser/history/download_database.cc3
-rw-r--r--chrome/browser/history/history_unittest.cc13
2 files changed, 9 insertions, 7 deletions
diff --git a/chrome/browser/history/download_database.cc b/chrome/browser/history/download_database.cc
index f101e39..6c5fea7 100644
--- a/chrome/browser/history/download_database.cc
+++ b/chrome/browser/history/download_database.cc
@@ -181,7 +181,7 @@ void DownloadDatabase::RemoveDownloadsBetween(base::Time delete_begin,
// downloads where an index by time will give us a lot of benefit.
sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
"DELETE FROM downloads WHERE start_time >= ? AND start_time < ? "
- "AND (State = ? OR State = ?)"));
+ "AND (State = ? OR State = ? OR State = ?)"));
if (!statement)
return;
@@ -193,6 +193,7 @@ void DownloadDatabase::RemoveDownloadsBetween(base::Time delete_begin,
end_time ? end_time : std::numeric_limits<int64>::max());
statement.BindInt(2, DownloadItem::COMPLETE);
statement.BindInt(3, DownloadItem::CANCELLED);
+ statement.BindInt(4, DownloadItem::INTERRUPTED);
statement.Run();
}
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index b5ee476..068347a 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -320,21 +320,22 @@ TEST_F(HistoryTest, ClearBrowsingData_Downloads) {
EXPECT_NE(0, AddDownload(DownloadItem::COMPLETE, now - one_day));
EXPECT_NE(0, AddDownload(DownloadItem::COMPLETE, now));
EXPECT_NE(0, AddDownload(DownloadItem::COMPLETE, now + one_day));
- // Try the other three states.
- EXPECT_NE(0, AddDownload(DownloadItem::COMPLETE, month_ago));
+ // Try the other four states.
+ EXPECT_NE(0, AddDownload(DownloadItem::COMPLETE, month_ago));
EXPECT_NE(0, in_progress = AddDownload(DownloadItem::IN_PROGRESS, month_ago));
- EXPECT_NE(0, AddDownload(DownloadItem::CANCELLED, month_ago));
- EXPECT_NE(0, removing = AddDownload(DownloadItem::REMOVING, month_ago));
+ EXPECT_NE(0, AddDownload(DownloadItem::CANCELLED, month_ago));
+ EXPECT_NE(0, AddDownload(DownloadItem::INTERRUPTED, month_ago));
+ EXPECT_NE(0, removing = AddDownload(DownloadItem::REMOVING, month_ago));
// Test to see if inserts worked.
db_->QueryDownloads(&downloads);
- EXPECT_EQ(8U, downloads.size());
+ EXPECT_EQ(9U, downloads.size());
// Try removing from current timestamp. This should delete the one in the
// future and one very recent one.
db_->RemoveDownloadsBetween(now, Time());
db_->QueryDownloads(&downloads);
- EXPECT_EQ(6U, downloads.size());
+ EXPECT_EQ(7U, downloads.size());
// Try removing from two months ago. This should not delete items that are
// 'in progress' or in 'removing' state.