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

Side by Side Diff: chrome/browser/history/history_database.cc

Issue 10067030: Upgrade the history database to version 23 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Sync and update test data Created 8 years, 8 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
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/history/history_database.h" 5 #include "chrome/browser/history/history_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "base/mac/mac_util.h" 21 #include "base/mac/mac_util.h"
22 #endif 22 #endif
23 23
24 namespace history { 24 namespace history {
25 25
26 namespace { 26 namespace {
27 27
28 // Current version number. We write databases at the "current" version number, 28 // Current version number. We write databases at the "current" version number,
29 // but any previous version that can read the "compatible" one can make do with 29 // but any previous version that can read the "compatible" one can make do with
30 // or database without *too* many bad effects. 30 // or database without *too* many bad effects.
31 static const int kCurrentVersionNumber = 21; 31 static const int kCurrentVersionNumber = 22;
32 static const int kCompatibleVersionNumber = 16; 32 static const int kCompatibleVersionNumber = 16;
33 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; 33 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold";
34 34
35 // Key in the meta table used to determine if we need to migrate thumbnails out 35 // Key in the meta table used to determine if we need to migrate thumbnails out
36 // of history. 36 // of history.
37 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration"; 37 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration";
38 38
39 void ComputeDatabaseMetrics(const FilePath& history_name, 39 void ComputeDatabaseMetrics(const FilePath& history_name,
40 sql::Connection& db) { 40 sql::Connection& db) {
41 if (base::RandInt(1, 100) != 50) 41 if (base::RandInt(1, 100) != 50)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // This is the version prior to adding the visit_duration field in visits 315 // This is the version prior to adding the visit_duration field in visits
316 // database. We need to migrate the database. 316 // database. We need to migrate the database.
317 if (!MigrateVisitsWithoutDuration()) { 317 if (!MigrateVisitsWithoutDuration()) {
318 LOG(WARNING) << "Unable to update history database to version 21."; 318 LOG(WARNING) << "Unable to update history database to version 21.";
319 return sql::INIT_FAILURE; 319 return sql::INIT_FAILURE;
320 } 320 }
321 ++cur_version; 321 ++cur_version;
322 meta_table_.SetVersionNumber(cur_version); 322 meta_table_.SetVersionNumber(cur_version);
323 } 323 }
324 324
325 if (cur_version == 21) {
326 // The android_urls table's data schemal was changed in version 21.
327 #if defined(OS_ANDROID)
328 if (!MigrateToVersion22()) {
329 LOG(WARNING) << "Unable to migrate the android_urls table to version 22";
330 }
331 #endif
332 ++cur_version;
333 meta_table_.SetVersionNumber(cur_version);
334 }
325 // When the version is too old, we just try to continue anyway, there should 335 // When the version is too old, we just try to continue anyway, there should
326 // not be a released product that makes a database too old for us to handle. 336 // not be a released product that makes a database too old for us to handle.
327 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << 337 LOG_IF(WARNING, cur_version < GetCurrentVersion()) <<
328 "History database version " << cur_version << " is too old to handle."; 338 "History database version " << cur_version << " is too old to handle.";
329 339
330 return sql::INIT_OK; 340 return sql::INIT_OK;
331 } 341 }
332 342
333 #if !defined(OS_WIN) 343 #if !defined(OS_WIN)
334 void HistoryDatabase::MigrateTimeEpoch() { 344 void HistoryDatabase::MigrateTimeEpoch() {
(...skipping 14 matching lines...) Expand all
349 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 359 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
350 360
351 // Erase all the full text index files. These will take a while to update and 361 // Erase all the full text index files. These will take a while to update and
352 // are less important, so we just blow them away. Same with the archived 362 // are less important, so we just blow them away. Same with the archived
353 // database. 363 // database.
354 needs_version_17_migration_ = true; 364 needs_version_17_migration_ = true;
355 } 365 }
356 #endif 366 #endif
357 367
358 } // namespace history 368 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/android/android_urls_database_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698