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

Side by Side Diff: chrome/browser/webdata/keyword_table.cc

Issue 12518017: Generalize migration code in WebDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge of LKGR Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/webdata/keyword_table.h ('k') | chrome/browser/webdata/logins_table.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/webdata/keyword_table.h" 5 #include "chrome/browser/webdata/keyword_table.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 "last_modified INTEGER DEFAULT 0," 145 "last_modified INTEGER DEFAULT 0,"
146 "sync_guid VARCHAR," 146 "sync_guid VARCHAR,"
147 "alternate_urls VARCHAR," 147 "alternate_urls VARCHAR,"
148 "search_terms_replacement_key VARCHAR)"); 148 "search_terms_replacement_key VARCHAR)");
149 } 149 }
150 150
151 bool KeywordTable::IsSyncable() { 151 bool KeywordTable::IsSyncable() {
152 return true; 152 return true;
153 } 153 }
154 154
155 bool KeywordTable::MigrateToVersion(int version,
156 const std::string& app_locale,
157 bool* update_compatible_version) {
158 // Migrate if necessary.
159 switch (version) {
160 case 21:
161 *update_compatible_version = true;
162 return MigrateToVersion21AutoGenerateKeywordColumn();
163 case 25:
164 *update_compatible_version = true;
165 return MigrateToVersion25AddLogoIDColumn();
166 case 26:
167 *update_compatible_version = true;
168 return MigrateToVersion26AddCreatedByPolicyColumn();
169 case 28:
170 *update_compatible_version = true;
171 return MigrateToVersion28SupportsInstantColumn();
172 case 29:
173 *update_compatible_version = true;
174 return MigrateToVersion29InstantURLToSupportsInstant();
175 case 38:
176 *update_compatible_version = true;
177 return MigrateToVersion38AddLastModifiedColumn();
178 case 39:
179 *update_compatible_version = true;
180 return MigrateToVersion39AddSyncGUIDColumn();
181 case 44:
182 *update_compatible_version = true;
183 return MigrateToVersion44AddDefaultSearchProviderBackup();
184 case 45:
185 *update_compatible_version = true;
186 return MigrateToVersion45RemoveLogoIDAndAutogenerateColumns();
187 case 47:
188 *update_compatible_version = true;
189 return MigrateToVersion47AddAlternateURLsColumn();
190 case 48:
191 *update_compatible_version = true;
192 return MigrateToVersion48RemoveKeywordsBackup();
193 case 49:
194 *update_compatible_version = true;
195 return MigrateToVersion49AddSearchTermsReplacementKeyColumn();
196 }
197
198 return true;
199 }
200
155 bool KeywordTable::AddKeyword(const TemplateURLData& data) { 201 bool KeywordTable::AddKeyword(const TemplateURLData& data) {
156 DCHECK(data.id); 202 DCHECK(data.id);
157 std::string query("INSERT INTO keywords (" + GetKeywordColumns() + 203 std::string query("INSERT INTO keywords (" + GetKeywordColumns() +
158 ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); 204 ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
159 sql::Statement s(db_->GetUniqueStatement(query.c_str())); 205 sql::Statement s(db_->GetUniqueStatement(query.c_str()));
160 BindURLToStatement(data, &s, 0, 1); 206 BindURLToStatement(data, &s, 0, 1);
161 207
162 return s.Run(); 208 return s.Run();
163 } 209 }
164 210
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 } 594 }
549 } 595 }
550 596
551 // Replace the old table with the new one. 597 // Replace the old table with the new one.
552 sql = "DROP TABLE " + name; 598 sql = "DROP TABLE " + name;
553 if (!db_->Execute(sql.c_str())) 599 if (!db_->Execute(sql.c_str()))
554 return false; 600 return false;
555 sql = "ALTER TABLE keywords_temp RENAME TO " + name; 601 sql = "ALTER TABLE keywords_temp RENAME TO " + name;
556 return db_->Execute(sql.c_str()); 602 return db_->Execute(sql.c_str());
557 } 603 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/keyword_table.h ('k') | chrome/browser/webdata/logins_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698