#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/cronet/cronet_prefs_manager.h"
#include <memory>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/cronet/host_cache_persistence_manager.h"
#include "components/prefs/json_pref_store.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_service_factory.h"
#include "net/http/http_server_properties.h"
#include "net/nqe/network_qualities_prefs_manager.h"
#include "net/url_request/url_request_context_builder.h"
namespace cronet {
namespace {
const char kHttpServerPropertiesPref[] = …;
const base::FilePath::CharType kPrefsDirectoryName[] = …);
const base::FilePath::CharType kPrefsFileName[] = …);
const int32_t kStorageVersion = …;
const uint32_t kStorageVersionUnknown = …;
const char kHostCachePref[] = …;
const char kNetworkQualitiesPref[] = …;
bool IsCurrentVersion(const base::FilePath& version_filepath) { … }
void InitializeStorageDirectory(const base::FilePath& dir) { … }
class PrefServiceAdapter : public net::HttpServerProperties::PrefDelegate { … };
class NetworkQualitiesPrefDelegateImpl
: public net::NetworkQualitiesPrefsManager::PrefDelegate { … };
}
CronetPrefsManager::CronetPrefsManager(
const std::string& storage_path,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
scoped_refptr<base::SequencedTaskRunner> file_task_runner,
bool enable_network_quality_estimator,
bool enable_host_cache_persistence,
net::NetLog* net_log,
net::URLRequestContextBuilder* context_builder) { … }
CronetPrefsManager::~CronetPrefsManager() { … }
void CronetPrefsManager::SetupNqePersistence(
net::NetworkQualityEstimator* nqe) { … }
void CronetPrefsManager::SetupHostCachePersistence(
net::HostCache* host_cache,
int host_cache_persistence_delay_ms,
net::NetLog* net_log) { … }
void CronetPrefsManager::PrepareForShutdown() { … }
}