chromium/components/blocklist/opt_out_blocklist/sql/opt_out_store_sql.cc

// Copyright 2016 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/blocklist/opt_out_blocklist/sql/opt_out_store_sql.h"

#include <map>
#include <string>
#include <tuple>
#include <utility>

#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_data.h"
#include "sql/database.h"
#include "sql/recovery.h"
#include "sql/statement.h"
#include "sql/transaction.h"

namespace blocklist {

namespace {

// Command line switch to change the entry per host DB size.
const char kMaxRowsPerHost[] =;

// Command line switch to change the DB size.
const char kMaxRows[] =;

// Returns the maximum number of table rows allowed per host for the sql
// opt out store. This is enforced during insertion of new navigation entries.
int MaxRowsPerHostInOptOutDB() {}

// Returns the maximum number of table rows allowed for the blocklist opt out
// store. This is enforced during load time; thus the database can grow
// larger than this temporarily.
int MaxRowsInOptOutDB() {}

// Table names use a macro instead of a const, so they can be used inline in
// other SQL statements below.

// The Opt Out table holds entries for hosts that should not use a specified
// type. Historically, this was named previews_v1.
#define OPT_OUT_TABLE_NAME

// The Enabled types table hold the list of enabled types
// treatments with a version for that enabled treatment. If the version
// changes or the type becomes disabled, then any entries in the Opt Out
// table for that treatment type should be cleared. Historically, this was named
// enabled_previews_v1.
#define ENABLED_TYPES_TABLE_NAME

void CreateSchema(sql::Database* db) {}

void DatabaseErrorCallback(sql::Database* db,
                           int extended_error,
                           sql::Statement* stmt) {}

void InitDatabase(sql::Database* db, base::FilePath path) {}

// Adds a new OptOut entry to the data base.
void AddEntryToDataBase(sql::Database* db,
                        bool opt_out,
                        const std::string& host_name,
                        int type,
                        base::Time now) {}

// Removes OptOut entries for |host_name| if the per-host row limit is exceeded.
// Removes OptOut entries if per data base row limit is exceeded.
void MaybeEvictHostEntryFromDataBase(sql::Database* db,
                                     const std::string& host_name) {}

// Deletes every entry for |type|.
void ClearBlocklistForTypeInDataBase(sql::Database* db, int type) {}

// Retrieves the list of previously enabled types with their version from the
// Enabled table.
BlocklistData::AllowedTypesAndVersions GetStoredEntries(sql::Database* db) {}

// Adds a newly enabled |type| with its |version| to the Enabled types table.
void InsertEnabledTypesInDataBase(sql::Database* db, int type, int version) {}

// Updates the |version| of an enabled |type| in the Enabled table.
void UpdateEnabledTypesInDataBase(sql::Database* db, int type, int version) {}

// Checks the current set of enabled types (with their current version)
// and where a type is now disabled or has a different version, cleans up
// any associated blocklist entries.
void CheckAndReconcileEnabledTypesWithDataBase(
    sql::Database* db,
    const BlocklistData::AllowedTypesAndVersions& allowed_types) {}

void LoadBlockListFromDataBase(
    sql::Database* db,
    std::unique_ptr<BlocklistData> blocklist_data,
    scoped_refptr<base::SingleThreadTaskRunner> runner,
    LoadBlockListCallback callback) {}

// Synchronous implementations, these are run on the background thread
// and actually do the work to access the SQL data base.
void LoadBlockListSync(sql::Database* db,
                       const base::FilePath& path,
                       std::unique_ptr<BlocklistData> blocklist_data,
                       scoped_refptr<base::SingleThreadTaskRunner> runner,
                       LoadBlockListCallback callback) {}

// Deletes every row in the table that has entry time between |begin_time| and
// |end_time|.
void ClearBlockListSync(sql::Database* db,
                        base::Time begin_time,
                        base::Time end_time) {}

void AddEntrySync(bool opt_out,
                  const std::string& host_name,
                  int type,
                  base::Time now,
                  sql::Database* db) {}

}  // namespace

OptOutStoreSQL::OptOutStoreSQL(
    scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
    scoped_refptr<base::SequencedTaskRunner> background_task_runner,
    const base::FilePath& path)
    :{}

OptOutStoreSQL::~OptOutStoreSQL() {}

void OptOutStoreSQL::AddEntry(bool opt_out,
                              const std::string& host_name,
                              int type,
                              base::Time now) {}

void OptOutStoreSQL::ClearBlockList(base::Time begin_time,
                                    base::Time end_time) {}

void OptOutStoreSQL::LoadBlockList(
    std::unique_ptr<BlocklistData> blocklist_data,
    LoadBlockListCallback callback) {}

}  // namespace blocklist