#include "net/http/transport_security_persister.h"
#include <algorithm>
#include <cstdint>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/base64.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/location.h"
#include "base/metrics/field_trial_params.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/features.h"
#include "net/base/network_anonymization_key.h"
#include "net/cert/x509_certificate.h"
#include "net/http/transport_security_state.h"
namespace net {
BASE_FEATURE(…);
namespace {
constexpr base::TimeDelta kMinCommitInterval = …;
constexpr base::TimeDelta kMaxCommitInterval = …;
const base::FeatureParam<base::TimeDelta> kCommitIntervalParam(
&kTransportSecurityFileWriterSchedule,
"commit_interval",
kMinCommitInterval);
constexpr const char* kHistogramSuffix = …;
std::string HashedDomainToExternalString(
const TransportSecurityState::HashedHost& hashed) { … }
std::optional<TransportSecurityState::HashedHost> ExternalStringToHashedDomain(
const std::string& external) { … }
const char kVersionKey[] = …;
const int kCurrentVersionValue = …;
const char kSTSKey[] = …;
const char kExpectCTKey[] = …;
const char kHostname[] = …;
const char kStsIncludeSubdomains[] = …;
const char kStsObserved[] = …;
const char kExpiry[] = …;
const char kMode[] = …;
const char kForceHTTPS[] = …;
const char kDefault[] = …;
std::string LoadState(const base::FilePath& path) { … }
base::Value::List SerializeSTSData(const TransportSecurityState* state) { … }
void DeserializeSTSData(const base::Value& sts_list,
TransportSecurityState* state) { … }
void OnWriteFinishedTask(scoped_refptr<base::SequencedTaskRunner> task_runner,
base::OnceClosure callback,
bool result) { … }
}
TransportSecurityPersister::TransportSecurityPersister(
TransportSecurityState* state,
const scoped_refptr<base::SequencedTaskRunner>& background_runner,
const base::FilePath& data_path)
: … { … }
TransportSecurityPersister::~TransportSecurityPersister() { … }
void TransportSecurityPersister::StateIsDirty(TransportSecurityState* state) { … }
void TransportSecurityPersister::WriteNow(TransportSecurityState* state,
base::OnceClosure callback) { … }
void TransportSecurityPersister::OnWriteFinished(base::OnceClosure callback) { … }
std::optional<std::string> TransportSecurityPersister::SerializeData() { … }
void TransportSecurityPersister::LoadEntries(const std::string& serialized) { … }
base::TimeDelta TransportSecurityPersister::GetCommitInterval() { … }
void TransportSecurityPersister::Deserialize(
const std::string& serialized,
TransportSecurityState* state,
bool& contains_legacy_expect_ct_data) { … }
void TransportSecurityPersister::CompleteLoad(const std::string& state) { … }
}