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

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

Issue 7396024: Adding a sync_guid field to TemplateURL. Adding appropriate database migration changes and tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Lint fix. Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/web_database.h" 5 #include "chrome/browser/webdata/web_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/sql/statement.h" 9 #include "app/sql/statement.h"
10 #include "app/sql/transaction.h" 10 #include "app/sql/transaction.h"
11 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 11 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
12 #include "content/common/notification_service.h" 12 #include "content/common/notification_service.h"
13 13
14 namespace { 14 namespace {
15 15
16 // Current version number. Note: when changing the current version number, 16 // Current version number. Note: when changing the current version number,
17 // corresponding changes must happen in the unit tests, and new migration test 17 // corresponding changes must happen in the unit tests, and new migration test
18 // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|. 18 // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|.
19 const int kCurrentVersionNumber = 38; 19 const int kCurrentVersionNumber = 39;
20 const int kCompatibleVersionNumber = 38; 20 const int kCompatibleVersionNumber = 39;
21 21
22 // Change the version number and possibly the compatibility version of 22 // Change the version number and possibly the compatibility version of
23 // |meta_table_|. 23 // |meta_table_|.
24 void ChangeVersion(sql::MetaTable* meta_table, 24 void ChangeVersion(sql::MetaTable* meta_table,
25 int version_num, 25 int version_num,
26 bool update_compatible_version_num) { 26 bool update_compatible_version_num) {
27 meta_table->SetVersionNumber(version_num); 27 meta_table->SetVersionNumber(version_num);
28 if (update_compatible_version_num) { 28 if (update_compatible_version_num) {
29 meta_table->SetCompatibleVersionNumber( 29 meta_table->SetCompatibleVersionNumber(
30 std::min(version_num, kCompatibleVersionNumber)); 30 std::min(version_num, kCompatibleVersionNumber));
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 ChangeVersion(&meta_table_, 37, true); 279 ChangeVersion(&meta_table_, 37, true);
280 // FALL THROUGH 280 // FALL THROUGH
281 281
282 case 37: 282 case 37:
283 if (!keyword_table_->MigrateToVersion38AddLastModifiedColumn()) 283 if (!keyword_table_->MigrateToVersion38AddLastModifiedColumn())
284 return FailedMigrationTo(38); 284 return FailedMigrationTo(38);
285 285
286 ChangeVersion(&meta_table_, 38, true); 286 ChangeVersion(&meta_table_, 38, true);
287 // FALL THROUGH 287 // FALL THROUGH
288 288
289 case 38:
290 if (!keyword_table_->MigrateToVersion39AddSyncGUIDColumn())
291 return FailedMigrationTo(39);
292
293 ChangeVersion(&meta_table_, 39, true);
294 // FALL THROUGH
295
289 // Add successive versions here. Each should set the version number and 296 // Add successive versions here. Each should set the version number and
290 // compatible version number as appropriate, then fall through to the next 297 // compatible version number as appropriate, then fall through to the next
291 // case. 298 // case.
292 299
293 case kCurrentVersionNumber: 300 case kCurrentVersionNumber:
294 // No migration needed. 301 // No migration needed.
295 return sql::INIT_OK; 302 return sql::INIT_OK;
296 } 303 }
297 } 304 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/keyword_table.cc ('k') | chrome/browser/webdata/web_database_migration_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698