#ifndef NET_EXTRAS_SQLITE_SQLITE_PERSISTENT_COOKIE_STORE_H_
#define NET_EXTRAS_SQLITE_SQLITE_PERSISTENT_COOKIE_STORE_H_
#include <list>
#include <string>
#include <utility>
#include <vector>
#include "base/component_export.h"
#include "base/functional/callback_forward.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/task_traits.h"
#include "net/cookies/cookie_monster.h"
#include "net/extras/sqlite/cookie_crypto_delegate.h"
#include "net/log/net_log_with_source.h"
namespace base {
class FilePath;
class SequencedTaskRunner;
}
namespace net {
class CanonicalCookie;
base::TaskPriority COMPONENT_EXPORT(NET_EXTRAS)
GetCookieStoreBackgroundSequencePriority();
class COMPONENT_EXPORT(NET_EXTRAS) SQLitePersistentCookieStore
: public CookieMonster::PersistentCookieStore {
public:
typedef std::pair<std::string, bool> CookieOrigin;
static constexpr int kDefaultUnknownPort = -1;
SQLitePersistentCookieStore(
const base::FilePath& path,
const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
bool restore_old_session_cookies,
std::unique_ptr<CookieCryptoDelegate> crypto_delegate,
bool enable_exclusive_access);
SQLitePersistentCookieStore(const SQLitePersistentCookieStore&) = delete;
SQLitePersistentCookieStore& operator=(const SQLitePersistentCookieStore&) =
delete;
void DeleteAllInList(const std::list<CookieOrigin>& cookies);
void Load(LoadedCallback loaded_callback,
const NetLogWithSource& net_log) override;
void LoadCookiesForKey(const std::string& key,
LoadedCallback callback) override;
void AddCookie(const CanonicalCookie& cc) override;
void UpdateCookieAccessTime(const CanonicalCookie& cc) override;
void DeleteCookie(const CanonicalCookie& cc) override;
void SetForceKeepSessionState() override;
void SetBeforeCommitCallback(base::RepeatingClosure callback) override;
void Flush(base::OnceClosure callback) override;
size_t GetQueueLengthForTesting();
private:
~SQLitePersistentCookieStore() override;
void CompleteLoad(LoadedCallback callback,
std::vector<std::unique_ptr<CanonicalCookie>> cookie_list);
void CompleteKeyedLoad(
const std::string& key,
LoadedCallback callback,
std::vector<std::unique_ptr<CanonicalCookie>> cookie_list);
class Backend;
const scoped_refptr<Backend> backend_;
NetLogWithSource net_log_;
};
}
#endif