#include "components/offline_pages/core/offline_page_metadata_store.h"
#include <utility>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/cstring_view.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "components/offline_pages/core/client_namespace_constants.h"
#include "components/offline_pages/core/offline_page_item.h"
#include "components/offline_pages/core/offline_store_types.h"
#include "components/offline_pages/core/offline_store_utils.h"
#include "sql/database.h"
#include "sql/meta_table.h"
#include "sql/statement.h"
#include "sql/transaction.h"
namespace offline_pages {
const int OfflinePageMetadataStore::kFirstPostLegacyVersion;
const int OfflinePageMetadataStore::kCurrentVersion;
const int OfflinePageMetadataStore::kCompatibleVersion;
namespace {
#define OFFLINE_PAGES_TABLE_NAME …
bool CreateOfflinePagesTable(sql::Database* db) { … }
bool UpgradeWithQuery(sql::Database* db, const base::cstring_view upgrade_sql) { … }
bool UpgradeFrom52(sql::Database* db) { … }
bool UpgradeFrom53(sql::Database* db) { … }
bool UpgradeFrom54(sql::Database* db) { … }
bool UpgradeFrom55(sql::Database* db) { … }
bool UpgradeFrom56(sql::Database* db) { … }
bool UpgradeFrom57(sql::Database* db) { … }
bool UpgradeFrom61(sql::Database* db) { … }
bool CreatePageThumbnailsTable(sql::Database* db) { … }
bool CreateLatestSchema(sql::Database* db) { … }
bool UpgradeFromLegacyVersion(sql::Database* db) { … }
bool UpgradeFromVersion1ToVersion2(sql::Database* db,
sql::MetaTable* meta_table) { … }
bool UpgradeFromVersion2ToVersion3(sql::Database* db,
sql::MetaTable* meta_table) { … }
bool UpgradeFromVersion3ToVersion4(sql::Database* db,
sql::MetaTable* meta_table) { … }
bool CreateSchema(sql::Database* db) { … }
StoreState InitializationStatusToStoreState(
SqlStoreBase::InitializationStatus status) { … }
}
OfflinePageMetadataStore::OfflinePageMetadataStore(
scoped_refptr<base::SequencedTaskRunner> background_task_runner)
: … { … }
OfflinePageMetadataStore::OfflinePageMetadataStore(
scoped_refptr<base::SequencedTaskRunner> background_task_runner,
const base::FilePath& path)
: … { … }
OfflinePageMetadataStore::~OfflinePageMetadataStore() = default;
base::OnceCallback<bool(sql::Database* db)>
OfflinePageMetadataStore::GetSchemaInitializationFunction() { … }
StoreState OfflinePageMetadataStore::GetStateForTesting() const { … }
void OfflinePageMetadataStore::OnOpenStart(base::TimeTicks last_closing_time) { … }
void OfflinePageMetadataStore::OnOpenDone(bool success) { … }
void OfflinePageMetadataStore::OnTaskBegin(bool is_initialized) { … }
void OfflinePageMetadataStore::OnTaskRunComplete() { … }
void OfflinePageMetadataStore::OnTaskReturnComplete() { … }
void OfflinePageMetadataStore::OnCloseStart(
InitializationStatus status_before_close) { … }
void OfflinePageMetadataStore::OnCloseComplete() { … }
}