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

Unified Diff: components/history/core/browser/download_database.cc

Issue 2720613002: Downloads: Added transient flag to download item and download database (Closed)
Patch Set: fix tests Created 3 years, 9 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: components/history/core/browser/download_database.cc
diff --git a/components/history/core/browser/download_database.cc b/components/history/core/browser/download_database.cc
index 9b7d4f76d54e285ba5fc0939642a00913c3d64e4..818c8ce9825ae112ae60d44d34dccfd33f2edbb4 100644
--- a/components/history/core/browser/download_database.cc
+++ b/components/history/core/browser/download_database.cc
@@ -277,6 +277,10 @@ bool DownloadDatabase::MigrateDownloadLastAccessTime() {
return EnsureColumnExists("last_access_time", "INTEGER NOT NULL DEFAULT 0");
}
+bool DownloadDatabase::MigrateDownloadVisible() {
+ return EnsureColumnExists("visible", "INTEGER NOT NULL DEFAULT 1");
+}
+
bool DownloadDatabase::InitDownloadTable() {
const char kSchema[] =
"CREATE TABLE downloads ("
@@ -295,6 +299,7 @@ bool DownloadDatabase::InitDownloadTable() {
"opened INTEGER NOT NULL," // 1 if it has ever been opened
// else 0
"last_access_time INTEGER NOT NULL," // The last time it was accessed.
+ "visible INTEGER NOT NULL," // 1 if it is visible, else 0.
"referrer VARCHAR NOT NULL," // HTTP Referrer
"site_url VARCHAR NOT NULL," // Site URL for initiating site
// instance.
@@ -386,9 +391,9 @@ void DownloadDatabase::QueryDownloads(std::vector<DownloadRow>* results) {
"SELECT id, guid, current_path, target_path, mime_type, "
"original_mime_type, start_time, received_bytes, total_bytes, state, "
"danger_type, interrupt_reason, hash, end_time, opened, "
- "last_access_time, referrer, site_url, tab_url, tab_referrer_url, "
- "http_method, by_ext_id, by_ext_name, etag, last_modified "
- "FROM downloads ORDER BY start_time"));
+ "last_access_time, visible, referrer, site_url, tab_url, "
+ "tab_referrer_url, http_method, by_ext_id, by_ext_name, etag, "
+ "last_modified FROM downloads ORDER BY start_time"));
while (statement_main.Step()) {
std::unique_ptr<DownloadRow> info(new DownloadRow());
@@ -422,6 +427,7 @@ void DownloadDatabase::QueryDownloads(std::vector<DownloadRow>* results) {
info->opened = statement_main.ColumnInt(column++) != 0;
info->last_access_time =
base::Time::FromInternalValue(statement_main.ColumnInt64(column++));
+ info->visible = statement_main.ColumnInt(column++) != 0;
info->referrer_url = GURL(statement_main.ColumnString(column++));
info->site_url = GURL(statement_main.ColumnString(column++));
info->tab_url = GURL(statement_main.ColumnString(column++));
@@ -539,8 +545,8 @@ bool DownloadDatabase::UpdateDownload(const DownloadRow& data) {
"mime_type=?, original_mime_type=?, "
"received_bytes=?, state=?, "
"danger_type=?, interrupt_reason=?, hash=?, end_time=?, total_bytes=?, "
- "opened=?, last_access_time=?, by_ext_id=?, by_ext_name=?, etag=?, "
- "last_modified=? WHERE id=?"));
+ "opened=?, last_access_time=?, visible=?, by_ext_id=?, by_ext_name=?, "
+ "etag=?, last_modified=? WHERE id=?"));
int column = 0;
BindFilePath(statement, data.current_path, column++);
BindFilePath(statement, data.target_path, column++);
@@ -556,6 +562,7 @@ bool DownloadDatabase::UpdateDownload(const DownloadRow& data) {
statement.BindInt64(column++, data.total_bytes);
statement.BindInt(column++, (data.opened ? 1 : 0));
statement.BindInt64(column++, data.last_access_time.ToInternalValue());
+ statement.BindInt(column++, (data.visible ? 1 : 0));
statement.BindString(column++, data.by_ext_id);
statement.BindString(column++, data.by_ext_name);
statement.BindString(column++, data.etag);
@@ -613,12 +620,12 @@ bool DownloadDatabase::CreateDownload(const DownloadRow& info) {
"INSERT INTO downloads "
"(id, guid, current_path, target_path, mime_type, original_mime_type, "
" start_time, received_bytes, total_bytes, state, danger_type, "
- " interrupt_reason, hash, end_time, opened, last_access_time, "
+ " interrupt_reason, hash, end_time, opened, last_access_time, visible, "
" referrer, site_url, tab_url, tab_referrer_url, http_method, "
" by_ext_id, by_ext_name, etag, last_modified) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
" ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
- " ?, ?, ?, ?, ?)"));
+ " ?, ?, ?, ?, ?, ?)"));
int column = 0;
statement_insert.BindInt(column++, DownloadIdToInt(info.id));
@@ -640,6 +647,7 @@ bool DownloadDatabase::CreateDownload(const DownloadRow& info) {
statement_insert.BindInt(column++, info.opened ? 1 : 0);
statement_insert.BindInt64(column++,
info.last_access_time.ToInternalValue());
+ statement_insert.BindInt(column++, info.visible ? 1 : 0);
statement_insert.BindString(column++, info.referrer_url.spec());
statement_insert.BindString(column++, info.site_url.spec());
statement_insert.BindString(column++, info.tab_url.spec());

Powered by Google App Engine
This is Rietveld 408576698