#include "services/network/shared_dictionary/shared_dictionary_storage_on_disk.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/pattern.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_id_helper.h"
#include "base/types/expected.h"
#include "net/base/io_buffer.h"
#include "services/network/public/cpp/request_destination.h"
#include "services/network/public/mojom/shared_dictionary_error.mojom.h"
#include "services/network/shared_dictionary/shared_dictionary_manager_on_disk.h"
#include "services/network/shared_dictionary/shared_dictionary_on_disk.h"
#include "services/network/shared_dictionary/shared_dictionary_writer_on_disk.h"
#include "services/network/shared_dictionary/simple_url_pattern_matcher.h"
#include "url/scheme_host_port.h"
namespace network {
namespace {
void RecordMetadataReadTimeMetrics(
const net::SQLitePersistentSharedDictionaryStore::DictionaryListOrError&
result,
base::TimeDelta time_delta) { … }
std::set<mojom::RequestDestination> ToRequestDestinationSet(
std::string_view input) { … }
}
SharedDictionaryStorageOnDisk::WrappedDictionaryInfo::WrappedDictionaryInfo(
net::SharedDictionaryInfo info,
std::unique_ptr<SimpleUrlPatternMatcher> matcher)
: … { … }
SharedDictionaryStorageOnDisk::WrappedDictionaryInfo::~WrappedDictionaryInfo() =
default;
SharedDictionaryStorageOnDisk::WrappedDictionaryInfo::WrappedDictionaryInfo(
WrappedDictionaryInfo&&) = default;
SharedDictionaryStorageOnDisk::WrappedDictionaryInfo&
SharedDictionaryStorageOnDisk::WrappedDictionaryInfo::operator=(
WrappedDictionaryInfo&&) = default;
SharedDictionaryStorageOnDisk::SharedDictionaryStorageOnDisk(
base::WeakPtr<SharedDictionaryManagerOnDisk> manager,
const net::SharedDictionaryIsolationKey& isolation_key,
base::ScopedClosureRunner on_deleted_closure_runner)
: … { … }
SharedDictionaryStorageOnDisk::~SharedDictionaryStorageOnDisk() = default;
scoped_refptr<net::SharedDictionary>
SharedDictionaryStorageOnDisk::GetDictionarySync(
const GURL& url,
mojom::RequestDestination destination) { … }
void SharedDictionaryStorageOnDisk::GetDictionary(
const GURL& url,
mojom::RequestDestination destination,
base::OnceCallback<void(scoped_refptr<net::SharedDictionary>)> callback) { … }
base::expected<scoped_refptr<SharedDictionaryWriter>,
mojom::SharedDictionaryError>
SharedDictionaryStorageOnDisk::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 SharedDictionaryStorageOnDisk::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 SharedDictionaryStorageOnDisk::OnDatabaseRead(
net::SQLitePersistentSharedDictionaryStore::DictionaryListOrError result) { … }
void SharedDictionaryStorageOnDisk::OnDictionaryWritten(
std::unique_ptr<SimpleUrlPatternMatcher> matcher,
net::SharedDictionaryInfo info) { … }
void SharedDictionaryStorageOnDisk::OnSharedDictionaryDeleted(
const base::UnguessableToken& disk_cache_key_token) { … }
void SharedDictionaryStorageOnDisk::OnDictionaryDeleted(
const std::set<base::UnguessableToken>& disk_cache_key_tokens) { … }
}