| Index: chrome/browser/history/download_database.cc
|
| diff --git a/chrome/browser/history/download_database.cc b/chrome/browser/history/download_database.cc
|
| index 0ae510438660df74e7b22e2454f7f3d5622f8bda..1fda02e81a8a20b7dceb9081466eb711efed31ae 100644
|
| --- a/chrome/browser/history/download_database.cc
|
| +++ b/chrome/browser/history/download_database.cc
|
| @@ -125,8 +125,6 @@ void DownloadDatabase::QueryDownloads(
|
| "total_bytes, state, end_time, opened "
|
| "FROM downloads "
|
| "ORDER BY start_time"));
|
| - if (!statement)
|
| - return;
|
|
|
| while (statement.Step()) {
|
| DownloadPersistentStoreInfo info;
|
| @@ -158,14 +156,12 @@ bool DownloadDatabase::UpdateDownload(const DownloadPersistentStoreInfo& data) {
|
| sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
|
| "UPDATE downloads "
|
| "SET received_bytes=?, state=?, end_time=?, opened=? WHERE id=?"));
|
| - if (!statement)
|
| - return false;
|
| -
|
| statement.BindInt64(0, data.received_bytes);
|
| statement.BindInt(1, data.state);
|
| statement.BindInt64(2, data.end_time.ToTimeT());
|
| statement.BindInt(3, (data.opened ? 1 : 0));
|
| statement.BindInt64(4, data.db_handle);
|
| +
|
| return statement.Run();
|
| }
|
|
|
| @@ -175,11 +171,9 @@ bool DownloadDatabase::UpdateDownloadPath(const FilePath& path,
|
| DCHECK(db_handle > 0);
|
| sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
|
| "UPDATE downloads SET full_path=? WHERE id=?"));
|
| - if (!statement)
|
| - return false;
|
| -
|
| BindFilePath(statement, path, 0);
|
| statement.BindInt64(1, db_handle);
|
| +
|
| return statement.Run();
|
| }
|
|
|
| @@ -187,10 +181,9 @@ bool DownloadDatabase::CleanUpInProgressEntries() {
|
| CheckThread();
|
| sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
|
| "UPDATE downloads SET state=? WHERE state=?"));
|
| - if (!statement)
|
| - return false;
|
| statement.BindInt(0, DownloadItem::CANCELLED);
|
| statement.BindInt(1, DownloadItem::IN_PROGRESS);
|
| +
|
| return statement.Run();
|
| }
|
|
|
| @@ -203,9 +196,6 @@ int64 DownloadDatabase::CreateDownload(
|
| "(full_path, url, start_time, received_bytes, total_bytes, state, "
|
| "end_time, opened) "
|
| "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"));
|
| - if (!statement)
|
| - return 0;
|
| -
|
| BindFilePath(statement, info.path, 0);
|
| statement.BindString(1, info.url.spec());
|
| statement.BindInt64(2, info.start_time.ToTimeT());
|
| @@ -225,7 +215,7 @@ int64 DownloadDatabase::CreateDownload(
|
| sql::Statement dbg_statement(GetDB().GetCachedStatement(
|
| SQL_FROM_HERE,
|
| "SELECT id FROM downloads;"));
|
| - CHECK_96627(dbg_statement);
|
| + CHECK_96627(dbg_statement.is_valid());
|
|
|
| std::set<int64> database_ids;
|
| while (dbg_statement.Step()) {
|
| @@ -249,16 +239,16 @@ void DownloadDatabase::RemoveDownload(DownloadID db_handle) {
|
| CheckThread();
|
| sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
|
| "DELETE FROM downloads WHERE id=?"));
|
| - if (!statement)
|
| + statement.BindInt64(0, db_handle);
|
| +
|
| + if (!statement.Run())
|
| return;
|
|
|
| - statement.BindInt64(0, db_handle);
|
| - if (statement.Run())
|
| - // TODO(rdsmith): Remove when http://crbug.com/96627 is resolved.
|
| - returned_ids_.erase(db_handle);
|
| + // TODO(rdsmith): Remove when http://crbug.com/96627 is resolved.
|
| + returned_ids_.erase(db_handle);
|
| }
|
|
|
| -void DownloadDatabase::RemoveDownloadsBetween(base::Time delete_begin,
|
| +bool DownloadDatabase::RemoveDownloadsBetween(base::Time delete_begin,
|
| base::Time delete_end) {
|
| CheckThread();
|
| time_t start_time = delete_begin.ToTimeT();
|
| @@ -270,8 +260,6 @@ void DownloadDatabase::RemoveDownloadsBetween(base::Time delete_begin,
|
| SQL_FROM_HERE,
|
| "SELECT id FROM downloads WHERE start_time >= ? AND start_time < ? "
|
| "AND (State = ? OR State = ? OR State = ?)"));
|
| - if (!dbg_statement)
|
| - return;
|
| dbg_statement.BindInt64(0, start_time);
|
| dbg_statement.BindInt64(
|
| 1,
|
| @@ -279,6 +267,10 @@ void DownloadDatabase::RemoveDownloadsBetween(base::Time delete_begin,
|
| dbg_statement.BindInt(2, DownloadItem::COMPLETE);
|
| dbg_statement.BindInt(3, DownloadItem::CANCELLED);
|
| dbg_statement.BindInt(4, DownloadItem::INTERRUPTED);
|
| +
|
| + if (!dbg_statement.is_valid())
|
| + return false;
|
| +
|
| while (dbg_statement.Step()) {
|
| int64 id_to_delete = dbg_statement.ColumnInt64(0);
|
| returned_ids_.erase(id_to_delete);
|
| @@ -291,9 +283,6 @@ void DownloadDatabase::RemoveDownloadsBetween(base::Time delete_begin,
|
| sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
|
| "DELETE FROM downloads WHERE start_time >= ? AND start_time < ? "
|
| "AND (State = ? OR State = ? OR State = ?)"));
|
| - if (!statement)
|
| - return;
|
| -
|
| statement.BindInt64(0, start_time);
|
| statement.BindInt64(
|
| 1,
|
| @@ -301,7 +290,8 @@ void DownloadDatabase::RemoveDownloadsBetween(base::Time delete_begin,
|
| statement.BindInt(2, DownloadItem::COMPLETE);
|
| statement.BindInt(3, DownloadItem::CANCELLED);
|
| statement.BindInt(4, DownloadItem::INTERRUPTED);
|
| - statement.Run();
|
| +
|
| + return statement.Run();
|
| }
|
|
|
| } // namespace history
|
|
|