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

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

Issue 10693124: Merge 145792 - Fix incomplete WebDatabase migration from downgraded version. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1132/src/
Patch Set: Created 8 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
« no previous file with comments | « no previous file | no next file » | 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/web_database.h" 5 #include "chrome/browser/webdata/web_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 9 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
10 #include "chrome/browser/webdata/autofill_table.h" 10 #include "chrome/browser/webdata/autofill_table.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 return transaction.Commit() ? sql::INIT_OK : sql::INIT_FAILURE; 157 return transaction.Commit() ? sql::INIT_OK : sql::INIT_FAILURE;
158 } 158 }
159 159
160 sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() { 160 sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() {
161 // Some malware tries to force protector to re-sign things by lowering the 161 // Some malware tries to force protector to re-sign things by lowering the
162 // version number, causing migration to fail. Ensure the version number is at 162 // version number, causing migration to fail. Ensure the version number is at
163 // least as high as the compatible version number. 163 // least as high as the compatible version number.
164 int current_version = std::max(meta_table_.GetVersionNumber(), 164 int current_version = std::max(meta_table_.GetVersionNumber(),
165 meta_table_.GetCompatibleVersionNumber()); 165 meta_table_.GetCompatibleVersionNumber());
166 if (current_version < meta_table_.GetCompatibleVersionNumber()) 166 if (current_version > meta_table_.GetVersionNumber())
167 ChangeVersion(&meta_table_, current_version, false); 167 ChangeVersion(&meta_table_, current_version, false);
168 168
169 // Migrate if necessary. 169 // Migrate if necessary.
170 switch (current_version) { 170 switch (current_version) {
171 // Versions 1 - 19 are unhandled. Version numbers greater than 171 // Versions 1 - 19 are unhandled. Version numbers greater than
172 // kCurrentVersionNumber should have already been weeded out by the caller. 172 // kCurrentVersionNumber should have already been weeded out by the caller.
173 default: 173 default:
174 // When the version is too old, we return failure error code. The schema 174 // When the version is too old, we return failure error code. The schema
175 // is too out of date to migrate. 175 // is too out of date to migrate.
176 // There should not be a released product that makes a database too old to 176 // There should not be a released product that makes a database too old to
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 338
339 // Add successive versions here. Each should set the version number and 339 // Add successive versions here. Each should set the version number and
340 // compatible version number as appropriate, then fall through to the next 340 // compatible version number as appropriate, then fall through to the next
341 // case. 341 // case.
342 342
343 case kCurrentVersionNumber: 343 case kCurrentVersionNumber:
344 // No migration needed. 344 // No migration needed.
345 return sql::INIT_OK; 345 return sql::INIT_OK;
346 } 346 }
347 } 347 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698