Chromium Code Reviews| Index: components/offline_pages/offline_page_metadata_store_sql.cc |
| diff --git a/components/offline_pages/offline_page_metadata_store_sql.cc b/components/offline_pages/offline_page_metadata_store_sql.cc |
| index dea0649e81cff8c461562d55b73db83c766960fb..963868c3379852c297bff90985d728005822e1ed 100644 |
| --- a/components/offline_pages/offline_page_metadata_store_sql.cc |
| +++ b/components/offline_pages/offline_page_metadata_store_sql.cc |
| @@ -33,7 +33,6 @@ bool CreateOfflinePagesTable(sql::Connection* db) { |
| " file_size INTEGER NOT NULL," |
| " last_access_time INTEGER NOT NULL," |
| " access_count INTEGER NOT NULL," |
| - " expiration_time INTEGER NOT NULL DEFAULT 0," |
| " client_namespace VARCHAR NOT NULL," |
| " client_id VARCHAR NOT NULL," |
| " online_url VARCHAR NOT NULL," |
| @@ -76,11 +75,11 @@ bool UpgradeFrom53(sql::Connection* db) { |
| const char kSql[] = |
| "INSERT INTO " OFFLINE_PAGES_TABLE_NAME |
| " (offline_id, creation_time, file_size, last_access_time, " |
| - "access_count, expiration_time, client_namespace, client_id, " |
|
fgorski
2016/11/18 00:13:04
this will revive expired pages.
Shouldn't we dele
romax
2016/11/18 20:50:49
I lean towards letting consistency check do the wo
|
| + "access_count, client_namespace, client_id, " |
| "online_url, file_path) " |
| "SELECT " |
| "offline_id, creation_time, file_size, last_access_time, " |
| - "access_count, expiration_time, client_namespace, client_id, " |
| + "access_count, client_namespace, client_id, " |
| "online_url, file_path " |
| "FROM temp_" OFFLINE_PAGES_TABLE_NAME; |
| return UpgradeWithQuery(db, kSql); |
| @@ -90,11 +89,11 @@ bool UpgradeFrom54(sql::Connection* db) { |
| const char kSql[] = |
| "INSERT INTO " OFFLINE_PAGES_TABLE_NAME |
| " (offline_id, creation_time, file_size, last_access_time, " |
| - "access_count, expiration_time, client_namespace, client_id, " |
|
fgorski
2016/11/18 00:13:04
ditto
romax
2016/11/18 20:50:49
Done.
|
| + "access_count, client_namespace, client_id, " |
| "online_url, file_path, title) " |
| "SELECT " |
| "offline_id, creation_time, file_size, last_access_time, " |
| - "access_count, expiration_time, client_namespace, client_id, " |
| + "access_count, client_namespace, client_id, " |
| "online_url, file_path, title " |
| "FROM temp_" OFFLINE_PAGES_TABLE_NAME; |
| return UpgradeWithQuery(db, kSql); |
| @@ -104,12 +103,12 @@ bool UpgradeFrom55(sql::Connection* db) { |
| const char kSql[] = |
| "INSERT INTO " OFFLINE_PAGES_TABLE_NAME |
| " (offline_id, creation_time, file_size, last_access_time, " |
| - "access_count, expiration_time, client_namespace, client_id, " |
| - "online_url, file_path, title) " |
| + "access_count, client_namespace, client_id, online_url, " |
| + "file_path, title) " |
| "SELECT " |
| "offline_id, creation_time, file_size, last_access_time, " |
| - "access_count, expiration_time, client_namespace, client_id, " |
| - "online_url, file_path, title " |
| + "access_count, client_namespace, client_id, online_url, " |
| + "file_path, title " |
| "FROM temp_" OFFLINE_PAGES_TABLE_NAME; |
| return UpgradeWithQuery(db, kSql); |
| } |
| @@ -127,7 +126,8 @@ bool CreateSchema(sql::Connection* db) { |
| } |
| // Upgrade section. Details are described in the header file. |
| - if (!db->DoesColumnExist(OFFLINE_PAGES_TABLE_NAME, "expiration_time")) { |
| + if (!db->DoesColumnExist(OFFLINE_PAGES_TABLE_NAME, "expiration_time") && |
|
jianli
2016/11/18 00:15:48
M56 table doesn't have expiration_time and title.
romax
2016/11/18 20:50:49
M56 should have title. It was added in M54
|
| + !db->DoesColumnExist(OFFLINE_PAGES_TABLE_NAME, "title")) { |
| if (!UpgradeFrom52(db)) |
| return false; |
| } else if (!db->DoesColumnExist(OFFLINE_PAGES_TABLE_NAME, "title")) { |
| @@ -183,18 +183,15 @@ OfflinePageItem MakeOfflinePageItem(sql::Statement* statement) { |
| base::Time last_access_time = |
| base::Time::FromInternalValue(statement->ColumnInt64(3)); |
| int access_count = statement->ColumnInt(4); |
| - base::Time expiration_time = |
| - base::Time::FromInternalValue(statement->ColumnInt64(5)); |
| - ClientId client_id(statement->ColumnString(6), statement->ColumnString(7)); |
| - GURL url(statement->ColumnString(8)); |
| - base::FilePath path(GetPathFromUTF8String(statement->ColumnString(9))); |
| - base::string16 title = statement->ColumnString16(10); |
| - GURL original_url(statement->ColumnString(11)); |
| + ClientId client_id(statement->ColumnString(5), statement->ColumnString(6)); |
| + GURL url(statement->ColumnString(7)); |
| + base::FilePath path(GetPathFromUTF8String(statement->ColumnString(8))); |
| + base::string16 title = statement->ColumnString16(9); |
| + GURL original_url(statement->ColumnString(10)); |
| OfflinePageItem item(url, id, client_id, path, file_size, creation_time); |
| item.last_access_time = last_access_time; |
| item.access_count = access_count; |
| - item.expiration_time = expiration_time; |
| item.title = title; |
| item.original_url = original_url; |
| return item; |
| @@ -207,9 +204,9 @@ ItemActionStatus Insert(sql::Connection* db, const OfflinePageItem& item) { |
| "INSERT OR IGNORE INTO " OFFLINE_PAGES_TABLE_NAME |
| " (offline_id, online_url, client_namespace, client_id, file_path, " |
| "file_size, creation_time, last_access_time, access_count, " |
| - "expiration_time, title, original_url)" |
| + "title, original_url)" |
| " VALUES " |
| - " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
| + " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
| sql::Statement statement(db->GetCachedStatement(SQL_FROM_HERE, kSql)); |
| statement.BindInt64(0, item.offline_id); |
| @@ -221,9 +218,8 @@ ItemActionStatus Insert(sql::Connection* db, const OfflinePageItem& item) { |
| statement.BindInt64(6, item.creation_time.ToInternalValue()); |
| statement.BindInt64(7, item.last_access_time.ToInternalValue()); |
| statement.BindInt(8, item.access_count); |
| - statement.BindInt64(9, item.expiration_time.ToInternalValue()); |
| - statement.BindString16(10, item.title); |
| - statement.BindString(11, item.original_url.spec()); |
| + statement.BindString16(9, item.title); |
| + statement.BindString(10, item.original_url.spec()); |
| if (!statement.Run()) |
| return ItemActionStatus::STORE_ERROR; |
| if (db->GetLastChangeCount() == 0) |
| @@ -236,7 +232,7 @@ bool Update(sql::Connection* db, const OfflinePageItem& item) { |
| "UPDATE OR IGNORE " OFFLINE_PAGES_TABLE_NAME |
| " SET online_url = ?, client_namespace = ?, client_id = ?, file_path = ?," |
| " file_size = ?, creation_time = ?, last_access_time = ?," |
| - " access_count = ?, expiration_time = ?, title = ?, original_url = ?" |
| + " access_count = ?, title = ?, original_url = ?" |
| " WHERE offline_id = ?"; |
| sql::Statement statement(db->GetCachedStatement(SQL_FROM_HERE, kSql)); |
| @@ -248,10 +244,9 @@ bool Update(sql::Connection* db, const OfflinePageItem& item) { |
| statement.BindInt64(5, item.creation_time.ToInternalValue()); |
| statement.BindInt64(6, item.last_access_time.ToInternalValue()); |
| statement.BindInt(7, item.access_count); |
| - statement.BindInt64(8, item.expiration_time.ToInternalValue()); |
| - statement.BindString16(9, item.title); |
| - statement.BindString(10, item.original_url.spec()); |
| - statement.BindInt64(11, item.offline_id); |
| + statement.BindString16(8, item.title); |
| + statement.BindString(9, item.original_url.spec()); |
| + statement.BindInt64(10, item.offline_id); |
| return statement.Run() && db->GetLastChangeCount() > 0; |
| } |