#include "net/http/http_server_properties.h"
#include "base/check_op.h"
#include "base/containers/adapters.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
#include "base/values.h"
#include "net/base/features.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/url_util.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties_manager.h"
#include "net/socket/ssl_client_socket.h"
#include "net/ssl/ssl_config.h"
namespace net {
namespace {
constexpr base::TimeDelta kUpdatePrefsDelay = …;
url::SchemeHostPort NormalizeSchemeHostPort(
const url::SchemeHostPort& scheme_host_port) { … }
}
HttpServerProperties::PrefDelegate::~PrefDelegate() = default;
HttpServerProperties::ServerInfo::ServerInfo() = default;
HttpServerProperties::ServerInfo::ServerInfo(const ServerInfo& server_info) =
default;
HttpServerProperties::ServerInfo::ServerInfo(ServerInfo&& server_info) =
default;
HttpServerProperties::ServerInfo::~ServerInfo() = default;
bool HttpServerProperties::ServerInfo::empty() const { … }
bool HttpServerProperties::ServerInfo::operator==(
const ServerInfo& other) const { … }
HttpServerProperties::ServerInfoMapKey::ServerInfoMapKey(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key,
bool use_network_anonymization_key)
: … { … }
HttpServerProperties::ServerInfoMapKey::~ServerInfoMapKey() = default;
bool HttpServerProperties::ServerInfoMapKey::operator<(
const ServerInfoMapKey& other) const { … }
HttpServerProperties::QuicServerInfoMapKey::QuicServerInfoMapKey(
const quic::QuicServerId& server_id,
const NetworkAnonymizationKey& network_anonymization_key,
bool use_network_anonymization_key)
: … { … }
HttpServerProperties::QuicServerInfoMapKey::~QuicServerInfoMapKey() = default;
bool HttpServerProperties::QuicServerInfoMapKey::operator<(
const QuicServerInfoMapKey& other) const { … }
bool HttpServerProperties::QuicServerInfoMapKey::operator==(
const QuicServerInfoMapKey& other) const { … }
HttpServerProperties::ServerInfoMap::ServerInfoMap()
: … { … }
HttpServerProperties::ServerInfoMap::iterator
HttpServerProperties::ServerInfoMap::GetOrPut(const ServerInfoMapKey& key) { … }
HttpServerProperties::ServerInfoMap::iterator
HttpServerProperties::ServerInfoMap::EraseIfEmpty(iterator server_info_it) { … }
HttpServerProperties::HttpServerProperties(
std::unique_ptr<PrefDelegate> pref_delegate,
NetLog* net_log,
const base::TickClock* tick_clock,
base::Clock* clock)
: … { … }
HttpServerProperties::~HttpServerProperties() { … }
void HttpServerProperties::Clear(base::OnceClosure callback) { … }
bool HttpServerProperties::SupportsRequestPriority(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
bool HttpServerProperties::GetSupportsSpdy(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::SetSupportsSpdy(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key,
bool supports_spdy) { … }
bool HttpServerProperties::RequiresHTTP11(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::SetHTTP11Required(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::MaybeForceHTTP11(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key,
SSLConfig* ssl_config) { … }
AlternativeServiceInfoVector HttpServerProperties::GetAlternativeServiceInfos(
const url::SchemeHostPort& origin,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::SetHttp2AlternativeService(
const url::SchemeHostPort& origin,
const NetworkAnonymizationKey& network_anonymization_key,
const AlternativeService& alternative_service,
base::Time expiration) { … }
void HttpServerProperties::SetQuicAlternativeService(
const url::SchemeHostPort& origin,
const NetworkAnonymizationKey& network_anonymization_key,
const AlternativeService& alternative_service,
base::Time expiration,
const quic::ParsedQuicVersionVector& advertised_versions) { … }
void HttpServerProperties::SetAlternativeServices(
const url::SchemeHostPort& origin,
const NetworkAnonymizationKey& network_anonymization_key,
const AlternativeServiceInfoVector& alternative_service_info_vector) { … }
void HttpServerProperties::MarkAlternativeServiceBroken(
const AlternativeService& alternative_service,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::
MarkAlternativeServiceBrokenUntilDefaultNetworkChanges(
const AlternativeService& alternative_service,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::MarkAlternativeServiceRecentlyBroken(
const AlternativeService& alternative_service,
const NetworkAnonymizationKey& network_anonymization_key) { … }
bool HttpServerProperties::IsAlternativeServiceBroken(
const AlternativeService& alternative_service,
const NetworkAnonymizationKey& network_anonymization_key) const { … }
bool HttpServerProperties::WasAlternativeServiceRecentlyBroken(
const AlternativeService& alternative_service,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::ConfirmAlternativeService(
const AlternativeService& alternative_service,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::OnDefaultNetworkChanged() { … }
base::Value HttpServerProperties::GetAlternativeServiceInfoAsValue() const { … }
bool HttpServerProperties::WasLastLocalAddressWhenQuicWorked(
const IPAddress& local_address) const { … }
bool HttpServerProperties::HasLastLocalAddressWhenQuicWorked() const { … }
void HttpServerProperties::SetLastLocalAddressWhenQuicWorked(
IPAddress last_local_address_when_quic_worked) { … }
void HttpServerProperties::ClearLastLocalAddressWhenQuicWorked() { … }
void HttpServerProperties::SetServerNetworkStats(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key,
ServerNetworkStats stats) { … }
void HttpServerProperties::ClearServerNetworkStats(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
const ServerNetworkStats* HttpServerProperties::GetServerNetworkStats(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::SetQuicServerInfo(
const quic::QuicServerId& server_id,
const NetworkAnonymizationKey& network_anonymization_key,
const std::string& server_info) { … }
const std::string* HttpServerProperties::GetQuicServerInfo(
const quic::QuicServerId& server_id,
const NetworkAnonymizationKey& network_anonymization_key) { … }
const HttpServerProperties::QuicServerInfoMap&
HttpServerProperties::quic_server_info_map() const { … }
size_t HttpServerProperties::max_server_configs_stored_in_properties() const { … }
void HttpServerProperties::SetMaxServerConfigsStoredInProperties(
size_t max_server_configs_stored_in_properties) { … }
void HttpServerProperties::SetBrokenAlternativeServicesDelayParams(
std::optional<base::TimeDelta> initial_delay,
std::optional<bool> exponential_backoff_on_initial_delay) { … }
bool HttpServerProperties::IsInitialized() const { … }
void HttpServerProperties::OnExpireBrokenAlternativeService(
const AlternativeService& expired_alternative_service,
const NetworkAnonymizationKey& network_anonymization_key) { … }
base::TimeDelta HttpServerProperties::GetUpdatePrefsDelayForTesting() { … }
bool HttpServerProperties::GetSupportsSpdyInternal(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::SetSupportsSpdyInternal(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key,
bool supports_spdy) { … }
bool HttpServerProperties::RequiresHTTP11Internal(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::SetHTTP11RequiredInternal(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::MaybeForceHTTP11Internal(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key,
SSLConfig* ssl_config) { … }
AlternativeServiceInfoVector
HttpServerProperties::GetAlternativeServiceInfosInternal(
const url::SchemeHostPort& origin,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::SetAlternativeServicesInternal(
const url::SchemeHostPort& origin,
const NetworkAnonymizationKey& network_anonymization_key,
const AlternativeServiceInfoVector& alternative_service_info_vector) { … }
void HttpServerProperties::SetServerNetworkStatsInternal(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key,
ServerNetworkStats stats) { … }
void HttpServerProperties::ClearServerNetworkStatsInternal(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
const ServerNetworkStats* HttpServerProperties::GetServerNetworkStatsInternal(
url::SchemeHostPort server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
HttpServerProperties::QuicServerInfoMapKey
HttpServerProperties::CreateQuicServerInfoKey(
const quic::QuicServerId& server_id,
const NetworkAnonymizationKey& network_anonymization_key) const { … }
HttpServerProperties::ServerInfoMapKey
HttpServerProperties::CreateServerInfoKey(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) const { … }
HttpServerProperties::ServerInfoMap::const_iterator
HttpServerProperties::GetIteratorWithAlternativeServiceInfo(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
HttpServerProperties::CanonicalMap::const_iterator
HttpServerProperties::GetCanonicalAltSvcHost(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) const { … }
HttpServerProperties::QuicCanonicalMap::const_iterator
HttpServerProperties::GetCanonicalServerInfoHost(
const QuicServerInfoMapKey& key) const { … }
void HttpServerProperties::RemoveAltSvcCanonicalHost(
const url::SchemeHostPort& server,
const NetworkAnonymizationKey& network_anonymization_key) { … }
void HttpServerProperties::UpdateCanonicalServerInfoMap(
const QuicServerInfoMapKey& key) { … }
const std::string* HttpServerProperties::GetCanonicalSuffix(
const std::string& host) const { … }
void HttpServerProperties::OnPrefsLoaded(
std::unique_ptr<ServerInfoMap> server_info_map,
const IPAddress& last_local_address_when_quic_worked,
std::unique_ptr<QuicServerInfoMap> quic_server_info_map,
std::unique_ptr<BrokenAlternativeServiceList>
broken_alternative_service_list,
std::unique_ptr<RecentlyBrokenAlternativeServices>
recently_broken_alternative_services) { … }
void HttpServerProperties::OnServerInfoLoaded(
std::unique_ptr<ServerInfoMap> server_info_map) { … }
void HttpServerProperties::OnLastLocalAddressWhenQuicWorkedLoaded(
const IPAddress& last_local_address_when_quic_worked) { … }
void HttpServerProperties::OnQuicServerInfoMapLoaded(
std::unique_ptr<QuicServerInfoMap> quic_server_info_map) { … }
void HttpServerProperties::OnBrokenAndRecentlyBrokenAlternativeServicesLoaded(
std::unique_ptr<BrokenAlternativeServiceList>
broken_alternative_service_list,
std::unique_ptr<RecentlyBrokenAlternativeServices>
recently_broken_alternative_services) { … }
void HttpServerProperties::MaybeQueueWriteProperties() { … }
void HttpServerProperties::FlushWritePropertiesForTesting(
base::OnceClosure callback) { … }
void HttpServerProperties::WriteProperties(base::OnceClosure callback) const { … }
}