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

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

Issue 10823203: Fix downloads db state=3 corruption using version=23 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 4 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/history/download_database.cc ('k') | chrome/browser/history/history_unittest.cc » ('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/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 = 22; 31 static const int kCurrentVersionNumber = 23;
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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 if (cur_version == 21) { 325 if (cur_version == 21) {
326 // The android_urls table's data schemal was changed in version 21. 326 // The android_urls table's data schemal was changed in version 21.
327 #if defined(OS_ANDROID) 327 #if defined(OS_ANDROID)
328 if (!MigrateToVersion22()) { 328 if (!MigrateToVersion22()) {
329 LOG(WARNING) << "Unable to migrate the android_urls table to version 22"; 329 LOG(WARNING) << "Unable to migrate the android_urls table to version 22";
330 } 330 }
331 #endif 331 #endif
332 ++cur_version; 332 ++cur_version;
333 meta_table_.SetVersionNumber(cur_version); 333 meta_table_.SetVersionNumber(cur_version);
334 } 334 }
335
336 if (cur_version == 22) {
337 if (!MigrateDownloadsState()) {
338 LOG(WARNING) << "Unable to fix invalid downloads state values";
339 // Invalid state values may cause crashes.
340 return sql::INIT_FAILURE;
341 }
342 cur_version++;
343 meta_table_.SetVersionNumber(cur_version);
344 }
345
335 // When the version is too old, we just try to continue anyway, there should 346 // When the version is too old, we just try to continue anyway, there should
336 // not be a released product that makes a database too old for us to handle. 347 // not be a released product that makes a database too old for us to handle.
337 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << 348 LOG_IF(WARNING, cur_version < GetCurrentVersion()) <<
338 "History database version " << cur_version << " is too old to handle."; 349 "History database version " << cur_version << " is too old to handle.";
339 350
340 return sql::INIT_OK; 351 return sql::INIT_OK;
341 } 352 }
342 353
343 #if !defined(OS_WIN) 354 #if !defined(OS_WIN)
344 void HistoryDatabase::MigrateTimeEpoch() { 355 void HistoryDatabase::MigrateTimeEpoch() {
(...skipping 14 matching lines...) Expand all
359 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 370 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
360 371
361 // Erase all the full text index files. These will take a while to update and 372 // Erase all the full text index files. These will take a while to update and
362 // are less important, so we just blow them away. Same with the archived 373 // are less important, so we just blow them away. Same with the archived
363 // database. 374 // database.
364 needs_version_17_migration_ = true; 375 needs_version_17_migration_ = true;
365 } 376 }
366 #endif 377 #endif
367 378
368 } // namespace history 379 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/download_database.cc ('k') | chrome/browser/history/history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698