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

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

Issue 11363222: Persist download interrupt reason, both target and current paths, and url_chain. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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) 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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "sql/transaction.h" 16 #include "sql/transaction.h"
17 17
18 #if defined(OS_MACOSX) 18 #if defined(OS_MACOSX)
19 #include "base/mac/mac_util.h" 19 #include "base/mac/mac_util.h"
20 #endif 20 #endif
21 21
22 namespace history { 22 namespace history {
23 23
24 namespace { 24 namespace {
25 25
26 // Current version number. We write databases at the "current" version number, 26 // Current version number. We write databases at the "current" version number,
27 // but any previous version that can read the "compatible" one can make do with 27 // but any previous version that can read the "compatible" one can make do with
28 // or database without *too* many bad effects. 28 // or database without *too* many bad effects.
29 static const int kCurrentVersionNumber = 23; 29 static const int kCurrentVersionNumber = 24;
30 static const int kCompatibleVersionNumber = 16; 30 static const int kCompatibleVersionNumber = 16;
31 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; 31 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold";
32 32
33 // Key in the meta table used to determine if we need to migrate thumbnails out 33 // Key in the meta table used to determine if we need to migrate thumbnails out
34 // of history. 34 // of history.
35 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration"; 35 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration";
36 36
37 void ComputeDatabaseMetrics(const FilePath& history_name, 37 void ComputeDatabaseMetrics(const FilePath& history_name,
38 sql::Connection& db) { 38 sql::Connection& db) {
39 if (base::RandInt(1, 100) != 50) 39 if (base::RandInt(1, 100) != 50)
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if (cur_version == 22) { 335 if (cur_version == 22) {
336 if (!MigrateDownloadsState()) { 336 if (!MigrateDownloadsState()) {
337 LOG(WARNING) << "Unable to fix invalid downloads state values"; 337 LOG(WARNING) << "Unable to fix invalid downloads state values";
338 // Invalid state values may cause crashes. 338 // Invalid state values may cause crashes.
339 return sql::INIT_FAILURE; 339 return sql::INIT_FAILURE;
340 } 340 }
341 cur_version++; 341 cur_version++;
342 meta_table_.SetVersionNumber(cur_version); 342 meta_table_.SetVersionNumber(cur_version);
343 } 343 }
344 344
345 if (cur_version == 23) {
346 if (!MigrateReasonAndPaths()) {
benjhayden 2012/11/14 19:43:22 Put 'Downloads' in this method name?
Randy Smith (Not in Mondays) 2012/11/14 22:47:34 Done.
347 LOG(WARNING) << "Unable to upgrade download interrupt reason and paths";
348 // Invalid state values may cause crashes.
349 return sql::INIT_FAILURE;
350 }
351 cur_version++;
352 meta_table_.SetVersionNumber(cur_version);
353 }
354
345 // When the version is too old, we just try to continue anyway, there should 355 // When the version is too old, we just try to continue anyway, there should
346 // not be a released product that makes a database too old for us to handle. 356 // not be a released product that makes a database too old for us to handle.
347 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << 357 LOG_IF(WARNING, cur_version < GetCurrentVersion()) <<
348 "History database version " << cur_version << " is too old to handle."; 358 "History database version " << cur_version << " is too old to handle.";
349 359
350 return sql::INIT_OK; 360 return sql::INIT_OK;
351 } 361 }
352 362
353 #if !defined(OS_WIN) 363 #if !defined(OS_WIN)
354 void HistoryDatabase::MigrateTimeEpoch() { 364 void HistoryDatabase::MigrateTimeEpoch() {
(...skipping 14 matching lines...) Expand all
369 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 379 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
370 380
371 // Erase all the full text index files. These will take a while to update and 381 // Erase all the full text index files. These will take a while to update and
372 // are less important, so we just blow them away. Same with the archived 382 // are less important, so we just blow them away. Same with the archived
373 // database. 383 // database.
374 needs_version_17_migration_ = true; 384 needs_version_17_migration_ = true;
375 } 385 }
376 #endif 386 #endif
377 387
378 } // namespace history 388 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698