// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_EXTRAS_SQLITE_SQLITE_PERSISTENT_STORE_BACKEND_BASE_H_ #define NET_EXTRAS_SQLITE_SQLITE_PERSISTENT_STORE_BACKEND_BASE_H_ #include <memory> #include <optional> #include <string> #include "base/files/file_path.h" #include "base/functional/callback.h" #include "base/functional/callback_forward.h" #include "base/memory/ref_counted.h" #include "base/thread_annotations.h" #include "sql/meta_table.h" namespace base { class Location; class SequencedTaskRunner; } // namespace base namespace sql { class Database; class Statement; } // namespace sql namespace net { // This class handles the initialization and closing of a SQLite database. It // is designed to be shared between a client thread and a background task // runner. // // Subclasses will want to have: // - methods to load the data from the database, which should call // InitializeDatabase() from the background thread to ensure the database has // been initialized before attempting to load data, // - overridden DoMigrateDatabaseSchema() and CreateDatabaseSchema(), // which will be called in the course of initializing the database, // - optionally overridden DoInitializeDatabase() which performs any other // initialization tasks, // - a way to keep track of pending operations in order to commit them // by invoking Commit() on the background thread, e.g. when a certain batch // size is reached or a certain amount of time has passed, // - overridden DoCommit() to actually handle the logic of committing // pending operations to the database, // - optionally overridden Record*() to record the appropriate metrics. class SQLitePersistentStoreBackendBase : public base::RefCountedThreadSafe<SQLitePersistentStoreBackendBase> { … }; } // namespace net #endif // NET_EXTRAS_SQLITE_SQLITE_PERSISTENT_STORE_BACKEND_BASE_H_