OLD | NEW |
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 Loading... |
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 // Add successive versions here. Each should set the version number and | 346 // Add successive versions here. Each should set the version number and |
347 // compatible version number as appropriate, then fall through to the next | 347 // compatible version number as appropriate, then fall through to the next |
348 // case. | 348 // case. |
349 | 349 |
350 case kCurrentVersionNumber: | 350 case kCurrentVersionNumber: |
351 // No migration needed. | 351 // No migration needed. |
352 return sql::INIT_OK; | 352 return sql::INIT_OK; |
353 } | 353 } |
354 } | 354 } |
OLD | NEW |