chromium/chrome/browser/dips/dips_database.cc

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

#include "chrome/browser/dips/dips_database.h"

#include <cstddef>
#include <limits>
#include <optional>
#include <string>
#include <string_view>
#include <vector>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "chrome/browser/dips/dips_database_migrator.h"
#include "chrome/browser/dips/dips_utils.h"
#include "content/public/common/content_features.h"
#include "sql/database.h"
#include "sql/error_delegate_util.h"
#include "sql/init_status.h"
#include "sql/meta_table.h"
#include "sql/statement.h"
#include "sql/transaction.h"

namespace {

BASE_FEATURE();

// NOTE: This is flag is intended for local testing and debugging only.
BASE_FEATURE();

constexpr char kTimerLastFiredKey[] =;

std::optional<base::Time> ColumnOptionalTime(sql::Statement* statement,
                                             int column_index) {}

TimestampRange RangeFromColumns(sql::Statement* statement,
                                int start_column_idx,
                                int end_column_idx,
                                std::vector<DIPSErrorCode>& errors) {}

// Binds either the start/ends of `range` or NULL at
// `start_param_idx`/`end_param_idx` in `statement` if time is provided.
void BindTimesOrNull(sql::Statement& statement,
                     TimestampRange time,
                     int start_param_idx,
                     int end_param_idx) {}

}  // namespace

// See comments at declaration of these variables in dips_database.h
// for details.
const base::TimeDelta DIPSDatabase::kMetricsInterval =;
const base::TimeDelta DIPSDatabase::kPopupTtl =;

DIPSDatabase::DIPSDatabase(const std::optional<base::FilePath>& db_path)
    :{}

DIPSDatabase::~DIPSDatabase() {}

// Invoked on a db error.
void DIPSDatabase::DatabaseErrorCallback(int extended_error,
                                         sql::Statement* stmt) {}

sql::InitStatus DIPSDatabase::OpenDatabase() {}

bool DIPSDatabase::InitTables() {}

sql::InitStatus DIPSDatabase::InitImpl() {}

sql::InitStatus DIPSDatabase::Init() {}

void DIPSDatabase::LogDatabaseMetrics() {}

bool DIPSDatabase::CheckDBInit() {}

bool DIPSDatabase::ExecuteSqlForTesting(const base::cstring_view sql) {}

bool DIPSDatabase::Write(const std::string& site,
                         const TimestampRange& storage_times,
                         const TimestampRange& interaction_times,
                         const TimestampRange& stateful_bounce_times,
                         const TimestampRange& bounce_times,
                         const TimestampRange& web_authn_assertion_times) {}

bool DIPSDatabase::WritePopup(const std::string& opener_site,
                              const std::string& popup_site,
                              const uint64_t access_id,
                              const base::Time& popup_time,
                              bool is_current_interaction) {}

std::optional<StateValue> DIPSDatabase::Read(const std::string& site) {}

std::optional<PopupsStateValue> DIPSDatabase::ReadPopup(
    const std::string& opener_site,
    const std::string& popup_site) {}

std::vector<PopupWithTime> DIPSDatabase::ReadRecentPopupsWithInteraction(
    const base::TimeDelta& lookback) {}

std::vector<std::string> DIPSDatabase::GetAllSitesForTesting(
    DIPSDatabaseTable table) {}

std::vector<std::string> DIPSDatabase::GetSitesThatBounced(
    base::TimeDelta grace_period) {}

std::vector<std::string> DIPSDatabase::GetSitesThatBouncedWithState(
    base::TimeDelta grace_period) {}

std::vector<std::string> DIPSDatabase::GetSitesThatUsedStorage(
    base::TimeDelta grace_period) {}

std::set<std::string> DIPSDatabase::FilterSitesWithProtectiveEvent(
    const std::set<std::string>& sites) {}

size_t DIPSDatabase::ClearExpiredRows() {}

bool DIPSDatabase::RemoveRow(const DIPSDatabaseTable table,
                             const std::string& site) {}

bool DIPSDatabase::RemoveRows(const DIPSDatabaseTable table,
                              const std::vector<std::string>& sites) {}

bool DIPSDatabase::RemoveEventsByTime(const base::Time& delete_begin,
                                      const base::Time& delete_end,
                                      const DIPSEventRemovalType type) {}

bool DIPSDatabase::RemoveEventsBySite(bool preserve,
                                      const std::vector<std::string>& sites,
                                      const DIPSEventRemovalType type) {}

bool DIPSDatabase::ClearTimestamps(const base::Time& delete_begin,
                                   const base::Time& delete_end,
                                   const DIPSEventRemovalType type) {}

bool DIPSDatabase::AdjustFirstTimestamps(const base::Time& delete_begin,
                                         const base::Time& delete_end,
                                         const DIPSEventRemovalType type) {}

bool DIPSDatabase::AdjustLastTimestamps(const base::Time& delete_begin,
                                        const base::Time& delete_end,
                                        const DIPSEventRemovalType type) {}

bool DIPSDatabase::ClearTimestampsBySite(bool preserve,
                                         const std::vector<std::string>& sites,
                                         const DIPSEventRemovalType type) {}

bool DIPSDatabase::RemoveEmptyRows() {}

size_t DIPSDatabase::GetEntryCount(const DIPSDatabaseTable table) {}

size_t DIPSDatabase::GarbageCollect() {}

size_t DIPSDatabase::GarbageCollectOldest(const DIPSDatabaseTable table,
                                          int purge_goal) {}

std::vector<std::string> DIPSDatabase::GetGarbageCollectOldestSitesForTesting(
    DIPSDatabaseTable table) {}

bool DIPSDatabase::SetConfigValue(std::string_view key, int64_t value) {}

std::optional<int64_t> DIPSDatabase::GetConfigValue(std::string_view key) {}

std::optional<base::Time> DIPSDatabase::GetTimerLastFired() {}

bool DIPSDatabase::SetTimerLastFired(base::Time time) {}