Chromium Code Reviews| Index: components/search_engines/keyword_table.cc |
| diff --git a/components/search_engines/keyword_table.cc b/components/search_engines/keyword_table.cc |
| index 1bbd601da8fef0f9d8de798ac98a657def036458..e5ae836e5f5531977fd394d05efc30014bb54f83 100644 |
| --- a/components/search_engines/keyword_table.cc |
| +++ b/components/search_engines/keyword_table.cc |
| @@ -84,6 +84,10 @@ const std::string ColumnsForVersion(int version, bool concatenated) { |
| // Column added in version 53. |
| columns.push_back("new_tab_url"); |
| } |
| + if (version >= 69) { |
| + // Column add in version 69. |
|
Peter Kasting
2016/11/21 03:35:08
Nit: added
ltian
2016/11/28 22:08:02
Done.
|
| + columns.push_back("last_visited"); |
| + } |
| return base::JoinString(columns, std::string(concatenated ? " || " : ", ")); |
| } |
| @@ -136,6 +140,7 @@ void BindURLToStatement(const TemplateURLData& data, |
| s->BindString(starting_column + 20, data.instant_url_post_params); |
| s->BindString(starting_column + 21, data.image_url_post_params); |
| s->BindString(starting_column + 22, data.new_tab_url); |
| + s->BindInt64(starting_column + 23, data.last_visited.ToTimeT()); |
| } |
| WebDatabaseTable::TypeKey GetKey() { |
| @@ -186,7 +191,8 @@ bool KeywordTable::CreateTablesIfNecessary() { |
| "suggest_url_post_params VARCHAR," |
| "instant_url_post_params VARCHAR," |
| "image_url_post_params VARCHAR," |
| - "new_tab_url VARCHAR)"); |
| + "new_tab_url VARCHAR," |
| + " last_visited INTEGER DEFAULT 0)"); |
|
Peter Kasting
2016/11/21 03:35:08
Nit: No leading space
ltian
2016/11/28 22:08:02
Done.
Peter Kasting
2016/12/01 07:38:24
No... I meant "no leading space inside the quotati
|
| } |
| bool KeywordTable::IsSyncable() { |
| @@ -206,6 +212,9 @@ bool KeywordTable::MigrateToVersion(int version, |
| case 68: |
| *update_compatible_version = true; |
| return MigrateToVersion68RemoveShowInDefaultListColumn(); |
| + case 69: |
| + *update_compatible_version = true; |
|
Peter Kasting
2016/11/21 03:35:08
Doesn't seem like you should set this, as we don't
ltian
2016/11/28 22:08:02
Done.
|
| + return MigrateToVersion69AddLastVisitedColumn(); |
| } |
| return true; |
| @@ -335,6 +344,11 @@ bool KeywordTable::MigrateToVersion68RemoveShowInDefaultListColumn() { |
| transaction.Commit(); |
| } |
| +bool KeywordTable::MigrateToVersion69AddLastVisitedColumn() { |
| + return db_->Execute("ALTER TABLE keywords ADD COLUMN last_visited " |
| + "INTEGER DEFAULT 0"); |
| +} |
| + |
| // static |
| bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s, |
| TemplateURLData* data) { |
| @@ -384,6 +398,7 @@ bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s, |
| } |
| data->search_terms_replacement_key = s.ColumnString(17); |
| + data->last_visited = Time::FromTimeT(s.ColumnInt64(24)); |
| return true; |
| } |
| @@ -392,7 +407,7 @@ bool KeywordTable::AddKeyword(const TemplateURLData& data) { |
| DCHECK(data.id); |
| std::string query("INSERT INTO keywords (" + GetKeywordColumns() + ") " |
| "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?," |
| - " ?)"); |
| + " ?,?)"); |
| sql::Statement s(db_->GetCachedStatement(SQL_FROM_HERE, query.c_str())); |
| BindURLToStatement(data, &s, 0, 1); |
| @@ -419,8 +434,8 @@ bool KeywordTable::UpdateKeyword(const TemplateURLData& data) { |
| "last_modified=?, sync_guid=?, alternate_urls=?, " |
| "search_terms_replacement_key=?, image_url=?, search_url_post_params=?, " |
| "suggest_url_post_params=?, instant_url_post_params=?, " |
| - "image_url_post_params=?, new_tab_url=? WHERE id=?")); |
| - BindURLToStatement(data, &s, 23, 0); // "23" binds id() as the last item. |
| + "image_url_post_params=?, new_tab_url=?, last_visited=? WHERE id=?")); |
| + BindURLToStatement(data, &s, 24, 0); // "24" binds id() as the last item. |
| return s.Run(); |
| } |