#include "services/network/sct_auditing/sct_auditing_handler.h"
#include "base/base64.h"
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/metrics/histogram_functions.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/backoff_entry.h"
#include "net/base/backoff_entry_serializer.h"
#include "net/base/hash_value.h"
#include "net/cert/merkle_tree_leaf.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/network_context.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/public/proto/sct_audit_report.pb.h"
#include "services/network/sct_auditing/sct_auditing_cache.h"
#include "services/network/sct_auditing/sct_auditing_reporter.h"
namespace network {
namespace {
std::string LoadReports(const base::FilePath& path) { … }
const char kReporterKeyKey[] = …;
const char kBackoffEntryKey[] = …;
const char kReportKey[] = …;
const char kSCTHashdanceMetadataKey[] = …;
const char kAlreadyCountedKey[] = …;
void RecordPopularSCTSkippedMetrics(bool popular_sct_skipped) { … }
void RecordReportDroppedDueToLogNotFound(bool report_dropped) { … }
}
SCTAuditingHandler::SCTAuditingHandler(NetworkContext* context,
const base::FilePath& persistence_path,
size_t cache_size)
: … { … }
SCTAuditingHandler::~SCTAuditingHandler() { … }
void SCTAuditingHandler::MaybeEnqueueReport(
const net::HostPortPair& host_port_pair,
const net::X509Certificate* validated_certificate_chain,
const net::SignedCertificateTimestampAndStatusList&
signed_certificate_timestamps) { … }
std::optional<std::string> SCTAuditingHandler::SerializeData() { … }
void SCTAuditingHandler::DeserializeData(const std::string& serialized) { … }
void SCTAuditingHandler::OnStartupFinished() { … }
void SCTAuditingHandler::AddReporter(
net::HashValue reporter_key,
std::unique_ptr<sct_auditing::SCTClientReport> report,
std::optional<SCTAuditingReporter::SCTHashdanceMetadata> sct_metadata,
std::unique_ptr<net::BackoffEntry> backoff_entry,
bool already_counted) { … }
void SCTAuditingHandler::OnReportsLoadedFromDisk(
const std::string& serialized) { … }
void SCTAuditingHandler::ClearPendingReports(base::OnceClosure callback) { … }
void SCTAuditingHandler::SetMode(mojom::SCTAuditingMode mode) { … }
base::WeakPtr<SCTAuditingHandler> SCTAuditingHandler::GetWeakPtr() { … }
void SCTAuditingHandler::OnReporterStateUpdated() { … }
void SCTAuditingHandler::OnReporterFinished(net::HashValue reporter_key) { … }
void SCTAuditingHandler::ReportHWMMetrics() { … }
network::mojom::URLLoaderFactory* SCTAuditingHandler::GetURLLoaderFactory() { … }
}