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 fb6b9efb68fffe5af1679601fc435c9d6ad22429..7cff0f178e8e89aaa88f355deb38cee4247ae6c1 100644 |
--- a/components/history/core/browser/download_database.cc |
+++ b/components/history/core/browser/download_database.cc |
@@ -255,33 +255,39 @@ bool DownloadDatabase::MigrateDownloadTabUrl() { |
EnsureColumnExists("tab_referrer_url", "VARCHAR NOT NULL DEFAULT ''"); |
} |
+bool DownloadDatabase::MigrateDownloadSiteInstanceUrl() { |
+ return EnsureColumnExists("site_instance_url", "VARCHAR NOT NULL DEFAULT ''"); |
+} |
+ |
bool DownloadDatabase::InitDownloadTable() { |
const char kSchema[] = |
"CREATE TABLE downloads (" |
- "id INTEGER PRIMARY KEY," // Primary key. |
- "guid VARCHAR NOT NULL," // GUID. |
- "current_path LONGVARCHAR NOT NULL," // Current disk location |
- "target_path LONGVARCHAR NOT NULL," // Final disk location |
- "start_time INTEGER NOT NULL," // When the download was started. |
- "received_bytes INTEGER NOT NULL," // Total size downloaded. |
- "total_bytes INTEGER NOT NULL," // Total size of the download. |
- "state INTEGER NOT NULL," // 1=complete, 4=interrupted |
- "danger_type INTEGER NOT NULL," // Danger type, validated. |
- "interrupt_reason INTEGER NOT NULL," // DownloadInterruptReason |
- "hash BLOB NOT NULL," // Raw SHA-256 hash of contents. |
- "end_time INTEGER NOT NULL," // When the download completed. |
- "opened INTEGER NOT NULL," // 1 if it has ever been opened |
- // else 0 |
- "referrer VARCHAR NOT NULL," // HTTP Referrer |
- "tab_url VARCHAR NOT NULL," // Tab URL for initiator. |
- "tab_referrer_url VARCHAR NOT NULL," // Tag referrer URL for initiator. |
- "http_method VARCHAR NOT NULL," // HTTP method. |
- "by_ext_id VARCHAR NOT NULL," // ID of extension that started the |
- // download |
- "by_ext_name VARCHAR NOT NULL," // name of extension |
- "etag VARCHAR NOT NULL," // ETag |
- "last_modified VARCHAR NOT NULL," // Last-Modified header |
- "mime_type VARCHAR(255) NOT NULL," // MIME type. |
+ "id INTEGER PRIMARY KEY," // Primary key. |
+ "guid VARCHAR NOT NULL," // GUID. |
+ "current_path LONGVARCHAR NOT NULL," // Current disk location |
+ "target_path LONGVARCHAR NOT NULL," // Final disk location |
+ "start_time INTEGER NOT NULL," // When the download was started. |
+ "received_bytes INTEGER NOT NULL," // Total size downloaded. |
+ "total_bytes INTEGER NOT NULL," // Total size of the download. |
+ "state INTEGER NOT NULL," // 1=complete, 4=interrupted |
+ "danger_type INTEGER NOT NULL," // Danger type, validated. |
+ "interrupt_reason INTEGER NOT NULL," // DownloadInterruptReason |
+ "hash BLOB NOT NULL," // Raw SHA-256 hash of contents. |
+ "end_time INTEGER NOT NULL," // When the download completed. |
+ "opened INTEGER NOT NULL," // 1 if it has ever been opened |
+ // else 0 |
+ "referrer VARCHAR NOT NULL," // HTTP Referrer |
+ "site_instance_url VARCHAR NOT NULL," // Site URL for initiating site |
Charlie Reis
2016/05/05 21:43:22
site_url (see comment in download_item.h)
asanka
2016/05/07 00:24:45
Done. Here and elsewhere.
|
+ // instance. |
+ "tab_url VARCHAR NOT NULL," // Tab URL for initiator. |
+ "tab_referrer_url VARCHAR NOT NULL," // Tag referrer URL for initiator. |
+ "http_method VARCHAR NOT NULL," // HTTP method. |
+ "by_ext_id VARCHAR NOT NULL," // ID of extension that started the |
+ // download |
+ "by_ext_name VARCHAR NOT NULL," // name of extension |
+ "etag VARCHAR NOT NULL," // ETag |
+ "last_modified VARCHAR NOT NULL," // Last-Modified header |
+ "mime_type VARCHAR(255) NOT NULL," // MIME type. |
"original_mime_type VARCHAR(255) NOT NULL)"; // Original MIME type. |
const char kUrlChainSchema[] = |
@@ -344,8 +350,8 @@ 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, referrer, " |
- "tab_url, tab_referrer_url, http_method, by_ext_id, by_ext_name, etag, " |
- "last_modified FROM downloads ORDER BY start_time")); |
+ "site_instance_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()); |
@@ -378,6 +384,7 @@ void DownloadDatabase::QueryDownloads(std::vector<DownloadRow>* results) { |
base::Time::FromInternalValue(statement_main.ColumnInt64(column++)); |
info->opened = statement_main.ColumnInt(column++) != 0; |
info->referrer_url = GURL(statement_main.ColumnString(column++)); |
+ info->site_instance_url = GURL(statement_main.ColumnString(column++)); |
info->tab_url = GURL(statement_main.ColumnString(column++)); |
info->tab_referrer_url = GURL(statement_main.ColumnString(column++)); |
info->http_method = statement_main.ColumnString(column++); |
@@ -552,12 +559,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, referrer, tab_url, " |
- " tab_referrer_url, http_method, by_ext_id, by_ext_name, etag, " |
- " last_modified) " |
+ " interrupt_reason, hash, end_time, opened, referrer, " |
+ " site_instance_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)); |
@@ -578,6 +585,7 @@ bool DownloadDatabase::CreateDownload(const DownloadRow& info) { |
statement_insert.BindInt64(column++, info.end_time.ToInternalValue()); |
statement_insert.BindInt(column++, info.opened ? 1 : 0); |
statement_insert.BindString(column++, info.referrer_url.spec()); |
+ statement_insert.BindString(column++, info.site_instance_url.spec()); |
statement_insert.BindString(column++, info.tab_url.spec()); |
statement_insert.BindString(column++, info.tab_referrer_url.spec()); |
statement_insert.BindString(column++, info.http_method); |