diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 15:22:54 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 15:22:54 +0000 |
commit | 809cc4d808f30112929ef9c33183e6cc052d3f88 (patch) | |
tree | 54398a78a324c611c7413d386d62aad68c01b17b /chrome/browser/history/history_database.cc | |
parent | 68d5a677812099c0d85b1c22f9234e8db9ddfc03 (diff) | |
download | chromium_src-809cc4d808f30112929ef9c33183e6cc052d3f88.zip chromium_src-809cc4d808f30112929ef9c33183e6cc052d3f88.tar.gz chromium_src-809cc4d808f30112929ef9c33183e6cc052d3f88.tar.bz2 |
Attempt 2 at landing top sites refactor:
Refactors TopSites so that it's hopefully easier to maintain and
doesn't suffer the plethora of threading issues that exist with the
current version. Here's the breakdown of what was refactored:
. TopSitesCache: Contains the most visited urls and thumbnails.
. TopSitesBackend: All mutations to topsites data end up calling into
the backend on the UI thread. TopSitesBackend processes the method on
the DB thread calling through to the TopSitesDatabase.
. TopSites: uses two TopSitesCache. One that contains the raw history
data, the other contains the processed data (pinned/blacklisted). The
processed cache can be accessed on any thread.
TopSites waits until history loads to know if it should migrate or use
it's own db. I could probably make these execute in parallel, but for
now this is how it works.
This patch also makes it so the dom ui accesses the thumbnails on the
IO thread.
BUG=56382
TEST=Make sure all your thumbnails are correctly updated and you don't
see problems.
Review URL: http://codereview.chromium.org/4051004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/history_database.cc')
-rw-r--r-- | chrome/browser/history/history_database.cc | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/chrome/browser/history/history_database.cc b/chrome/browser/history/history_database.cc index 56ee054..3e03504 100644 --- a/chrome/browser/history/history_database.cc +++ b/chrome/browser/history/history_database.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,15 +10,16 @@ #include "app/sql/transaction.h" #include "base/command_line.h" #include "base/file_util.h" -#if defined(OS_MACOSX) -#include "base/mac_util.h" -#endif #include "base/metrics/histogram.h" #include "base/rand_util.h" #include "base/string_util.h" #include "chrome/browser/diagnostics/sqlite_diagnostics.h" #include "chrome/common/chrome_switches.h" +#if defined(OS_MACOSX) +#include "base/mac_util.h" +#endif + namespace history { namespace { @@ -26,10 +27,14 @@ namespace { // Current version number. We write databases at the "current" version number, // but any previous version that can read the "compatible" one can make do with // or database without *too* many bad effects. -static const int kCurrentVersionNumber = 19; +static const int kCurrentVersionNumber = 20; static const int kCompatibleVersionNumber = 16; static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; +// Key in the meta table used to determine if we need to migrate thumbnails out +// of history. +static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration"; + void ComputeDatabaseMetrics(const FilePath& history_name, sql::Connection& db) { if (base::RandInt(1, 100) != 50) @@ -173,6 +178,16 @@ void HistoryDatabase::Vacuum() { db_.Execute("VACUUM"); } +void HistoryDatabase::ThumbnailMigrationDone() { + meta_table_.SetValue(kNeedsThumbnailMigrationKey, 0); +} + +bool HistoryDatabase::GetNeedsThumbnailMigration() { + int value = 0; + return (meta_table_.GetValue(kNeedsThumbnailMigrationKey, &value) && + value != 0); +} + bool HistoryDatabase::SetSegmentID(VisitID visit_id, SegmentID segment_id) { sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, "UPDATE visits SET segment_id = ? WHERE id = ?")); @@ -289,6 +304,14 @@ sql::InitStatus HistoryDatabase::EnsureCurrentVersion( meta_table_.SetVersionNumber(cur_version); } + if (cur_version == 19) { + cur_version++; + meta_table_.SetVersionNumber(cur_version); + // Set a key indicating we need to migrate thumbnails. When successfull the + // key is removed (ThumbnailMigrationDone). + meta_table_.SetValue(kNeedsThumbnailMigrationKey, 1); + } + // When the version is too old, we just try to continue anyway, there should // not be a released product that makes a database too old for us to handle. LOG_IF(WARNING, cur_version < GetCurrentVersion()) << @@ -322,8 +345,4 @@ void HistoryDatabase::MigrateTimeEpoch() { } #endif -void HistoryDatabase::MigrationToTopSitesDone() { - // TODO(sky): implement me. -} - } // namespace history |