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

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: Added binary files based on c#37 Created 7 years, 11 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
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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 if (cur_version == 22) { 337 if (cur_version == 22) {
338 if (!MigrateDownloadsState()) { 338 if (!MigrateDownloadsState()) {
339 LOG(WARNING) << "Unable to fix invalid downloads state values"; 339 LOG(WARNING) << "Unable to fix invalid downloads state values";
340 // Invalid state values may cause crashes. 340 // Invalid state values may cause crashes.
341 return sql::INIT_FAILURE; 341 return sql::INIT_FAILURE;
342 } 342 }
343 cur_version++; 343 cur_version++;
344 meta_table_.SetVersionNumber(cur_version); 344 meta_table_.SetVersionNumber(cur_version);
345 } 345 }
346 346
347 if (cur_version == 23) {
348 if (!MigrateDownloadsReasonPathsAndDangerType()) {
349 LOG(WARNING) << "Unable to upgrade download interrupt reason and paths";
350 // Invalid state values may cause crashes.
351 return sql::INIT_FAILURE;
352 }
353 cur_version++;
354 meta_table_.SetVersionNumber(cur_version);
355 }
356
347 // When the version is too old, we just try to continue anyway, there should 357 // When the version is too old, we just try to continue anyway, there should
348 // not be a released product that makes a database too old for us to handle. 358 // not be a released product that makes a database too old for us to handle.
349 LOG_IF(WARNING, cur_version < GetCurrentVersion()) << 359 LOG_IF(WARNING, cur_version < GetCurrentVersion()) <<
350 "History database version " << cur_version << " is too old to handle."; 360 "History database version " << cur_version << " is too old to handle.";
351 361
352 return sql::INIT_OK; 362 return sql::INIT_OK;
353 } 363 }
354 364
355 #if !defined(OS_WIN) 365 #if !defined(OS_WIN)
356 void HistoryDatabase::MigrateTimeEpoch() { 366 void HistoryDatabase::MigrateTimeEpoch() {
(...skipping 14 matching lines...) Expand all
371 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 381 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
372 382
373 // Erase all the full text index files. These will take a while to update and 383 // Erase all the full text index files. These will take a while to update and
374 // are less important, so we just blow them away. Same with the archived 384 // are less important, so we just blow them away. Same with the archived
375 // database. 385 // database.
376 needs_version_17_migration_ = true; 386 needs_version_17_migration_ = true;
377 } 387 }
378 #endif 388 #endif
379 389
380 } // namespace history 390 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698