chromium/components/history/core/browser/top_sites_database.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/history/core/browser/top_sites_database.h"

#include <stddef.h>
#include <stdint.h>

#include <tuple>
#include <utility>

#include "base/check.h"
#include "base/check_op.h"
#include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/sequence_checker.h"
#include "components/history/core/browser/features.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/browser/top_sites.h"
#include "sql/database.h"
#include "sql/meta_table.h"
#include "sql/recovery.h"
#include "sql/statement.h"
#include "sql/transaction.h"

namespace history {

// Description of database table:
//
// top_sites
//   url              URL of the top site.
//   url_rank         Index of the site, 0-based. The site with the highest rank
//                    will be the next one evicted.
//   title            The title to display under that site.

namespace {

// For this database, schema migrations are deprecated after two
// years.  This means that the oldest non-deprecated version should be
// two years old or greater (thus the migrations to get there are
// older).  Databases containing deprecated versions will be cleared
// at startup.  Since this database is a cache, losing old data is not
// fatal (in fact, very old data may be expired immediately at startup
// anyhow).

// Version 5: TODO [email protected] on 2022-09-21
// Version 4: 95af34ec/r618360 [email protected] on 2018-12-20
// Version 3: b6d6a783/r231648 by [email protected] on 2013-10-29
// Version 2: eb0b24e6/r87284 by [email protected] on 2011-05-31 (deprecated)
// Version 1: 809cc4d8/r64072 by [email protected] on 2010-10-27 (deprecated)

// NOTE(shess): When changing the version, add a new golden file for
// the new version and a test to verify that Init() works with it.
static const int kVersionNumber =;
static const int kDeprecatedVersionNumber =;  // and earlier.

// Rank used to indicate that this is a newly added URL.
static const int kRankOfNewURL =;

bool InitTables(sql::Database* db) {}

// Most corruption comes down to atomic updates between pages being broken
// somehow.  This can result in either missing data, or overlapping data,
// depending on the operation broken.  This table has large rows, which will use
// overflow pages, so it is possible (though unlikely) that a chain could fit
// together and yield a row with errors.
void FixTopSitesTable(sql::Database& db) {}

}  // namespace

void TopSitesDatabase::DatabaseErrorCallback(const base::FilePath& db_path,
                                             int extended_error,
                                             sql::Statement* stmt) {}

// static
const int TopSitesDatabase::kRankOfNonExistingURL =;

TopSitesDatabase::TopSitesDatabase() {}

TopSitesDatabase::~TopSitesDatabase() {}

bool TopSitesDatabase::Init(const base::FilePath& db_name) {}

bool TopSitesDatabase::UpgradeToVersion5(sql::MetaTable& meta_table) {}

bool TopSitesDatabase::InitImpl(const base::FilePath& db_name) {}

void TopSitesDatabase::ApplyDelta(const TopSitesDelta& delta) {}

MostVisitedURLList TopSitesDatabase::GetSites() {}

void TopSitesDatabase::SetSiteNoTransaction(const MostVisitedURL& url,
                                            int new_rank) {}

void TopSitesDatabase::AddSite(const MostVisitedURL& url, int new_rank) {}

bool TopSitesDatabase::UpdateSite(const MostVisitedURL& url) {}

int TopSitesDatabase::GetURLRank(const MostVisitedURL& url) {}

void TopSitesDatabase::UpdateSiteRankNoTransaction(const MostVisitedURL& url,
                                                   int new_rank) {}

bool TopSitesDatabase::RemoveURLNoTransaction(const MostVisitedURL& url) {}

sql::Database* TopSitesDatabase::db_for_testing() {}

int TopSitesDatabase::GetURLRankForTesting(const MostVisitedURL& url) {}

bool TopSitesDatabase::RemoveURLNoTransactionForTesting(
    const MostVisitedURL& url) {}

}  // namespace history