#include "services/network/shared_dictionary/shared_dictionary_storage_in_memory.h"
#include <map>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "net/base/io_buffer.h"
#include "services/network/shared_dictionary/shared_dictionary_in_memory.h"
#include "services/network/shared_dictionary/shared_dictionary_manager_in_memory.h"
#include "services/network/shared_dictionary/shared_dictionary_writer_in_memory.h"
#include "services/network/shared_dictionary/simple_url_pattern_matcher.h"
#include "url/scheme_host_port.h"
namespace network {
SharedDictionaryStorageInMemory::SharedDictionaryStorageInMemory(
base::WeakPtr<SharedDictionaryManagerInMemory> manager,
const net::SharedDictionaryIsolationKey& isolation_key,
base::ScopedClosureRunner on_deleted_closure_runner)
: … { … }
SharedDictionaryStorageInMemory::~SharedDictionaryStorageInMemory() = default;
scoped_refptr<net::SharedDictionary>
SharedDictionaryStorageInMemory::GetDictionarySync(
const GURL& url,
mojom::RequestDestination destination) { … }
void SharedDictionaryStorageInMemory::GetDictionary(
const GURL& url,
mojom::RequestDestination destination,
base::OnceCallback<void(scoped_refptr<net::SharedDictionary>)> callback) { … }
void SharedDictionaryStorageInMemory::DeleteDictionary(
const url::SchemeHostPort& host,
const std::string& match,
const std::set<mojom::RequestDestination>& match_dest) { … }
void SharedDictionaryStorageInMemory::ClearData(
base::Time start_time,
base::Time end_time,
base::RepeatingCallback<bool(const GURL&)> url_matcher) { … }
void SharedDictionaryStorageInMemory::ClearAllDictionaries() { … }
bool SharedDictionaryStorageInMemory::HasDictionaryBetween(
base::Time start_time,
base::Time end_time) { … }
base::expected<scoped_refptr<SharedDictionaryWriter>,
mojom::SharedDictionaryError>
SharedDictionaryStorageInMemory::CreateWriter(
const GURL& url,
base::Time last_fetch_time,
base::Time response_time,
base::TimeDelta expiration,
const std::string& match,
const std::set<mojom::RequestDestination>& match_dest,
const std::string& id,
std::unique_ptr<SimpleUrlPatternMatcher> matcher) { … }
bool SharedDictionaryStorageInMemory::UpdateLastFetchTimeIfAlreadyRegistered(
const GURL& url,
base::Time response_time,
base::TimeDelta expiration,
const std::string& match,
const std::set<mojom::RequestDestination>& match_dest,
const std::string& id,
base::Time last_fetch_time) { … }
void SharedDictionaryStorageInMemory::OnDictionaryWritten(
const GURL& url,
base::Time last_fetch_time,
base::Time response_time,
base::TimeDelta expiration,
const std::string& match,
std::unique_ptr<SimpleUrlPatternMatcher> matcher,
const std::set<mojom::RequestDestination>& match_dest,
const std::string& id,
SharedDictionaryWriterInMemory::Result result,
scoped_refptr<net::IOBuffer> data,
size_t size,
const net::SHA256HashValue& hash) { … }
SharedDictionaryStorageInMemory::DictionaryInfo::DictionaryInfo(
const GURL& url,
base::Time last_fetch_time,
base::Time response_time,
base::TimeDelta expiration,
const std::string& match,
std::set<mojom::RequestDestination> match_dest,
const std::string& id,
base::Time last_used_time,
scoped_refptr<net::IOBuffer> data,
size_t size,
const net::SHA256HashValue& hash,
std::unique_ptr<SimpleUrlPatternMatcher> matcher)
: … { … }
SharedDictionaryStorageInMemory::DictionaryInfo::DictionaryInfo(
DictionaryInfo&& other) = default;
SharedDictionaryStorageInMemory::DictionaryInfo&
SharedDictionaryStorageInMemory::DictionaryInfo::operator=(
SharedDictionaryStorageInMemory::DictionaryInfo&& other) = default;
SharedDictionaryStorageInMemory::DictionaryInfo::~DictionaryInfo() = default;
}