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

Unified Diff: chrome/browser/history/download_database.cc

Issue 3127008: Preliminary work on resuming downloads whose connections have expired.
Patch Set: Waiting to send download automation error message until after other downloads are canceled. Created 10 years, 3 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/history/download_database.cc
diff --git a/chrome/browser/history/download_database.cc b/chrome/browser/history/download_database.cc
index f101e395f2169176bf891cdc9eefe6d0509d8848..16faac84e84f6cdeaac2f9b946a50c9d370b4d3f 100644
--- a/chrome/browser/history/download_database.cc
+++ b/chrome/browser/history/download_database.cc
@@ -146,10 +146,21 @@ bool DownloadDatabase::CleanUpInProgressEntries() {
}
int64 DownloadDatabase::CreateDownload(const DownloadCreateInfo& info) {
- sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
- "INSERT INTO downloads "
- "(full_path, url, start_time, received_bytes, total_bytes, state) "
- "VALUES (?, ?, ?, ?, ?, ?)"));
+ // If the database contains the 'last_modified' field, then set it to blank.
+ bool has_last_mod = GetDB().DoesColumnExist("downloads", "last_modified");
+ sql::Statement statement;
+ if (has_last_mod) {
+ statement.Assign(GetDB().GetCachedStatement(SQL_FROM_HERE,
+ "INSERT INTO downloads "
+ "(full_path, url, start_time, received_bytes, total_bytes, state, "
+ "last_modified) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?)"));
+ } else {
+ statement.Assign(GetDB().GetCachedStatement(SQL_FROM_HERE,
+ "INSERT INTO downloads "
+ "(full_path, url, start_time, received_bytes, total_bytes, state) "
+ "VALUES (?, ?, ?, ?, ?, ?)"));
+ }
if (!statement)
return 0;
@@ -159,6 +170,8 @@ int64 DownloadDatabase::CreateDownload(const DownloadCreateInfo& info) {
statement.BindInt64(3, info.received_bytes);
statement.BindInt64(4, info.total_bytes);
statement.BindInt(5, info.state);
+ if (has_last_mod)
+ statement.BindString(6, "");
if (statement.Run())
return GetDB().GetLastInsertRowId();

Powered by Google App Engine
This is Rietveld 408576698