| Index: net/http/http_server_properties_impl.cc
|
| diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc
|
| index a0a6bfe644f35fbde0ac8fb00d0c1a98d830f307..ab2088f0f65d6d321dfeaa812444260031c70444 100644
|
| --- a/net/http/http_server_properties_impl.cc
|
| +++ b/net/http/http_server_properties_impl.cc
|
| @@ -32,6 +32,7 @@
|
| alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT),
|
| spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT),
|
| server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT),
|
| + alternative_service_probability_threshold_(1.0),
|
| quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT),
|
| max_server_configs_stored_in_properties_(kMaxQuicServersToPersist),
|
| weak_ptr_factory_(this) {
|
| @@ -322,8 +323,9 @@
|
|
|
| AlternativeServiceVector HttpServerPropertiesImpl::GetAlternativeServices(
|
| const HostPortPair& origin) {
|
| - // Copy valid alternative services into |valid_alternative_services|.
|
| - AlternativeServiceVector valid_alternative_services;
|
| + // Copy alternative services with probability greater than or equal to the
|
| + // threshold into |alternative_services_above_threshold|.
|
| + AlternativeServiceVector alternative_services_above_threshold;
|
| const base::Time now = base::Time::Now();
|
| AlternativeServiceMap::iterator map_it = alternative_service_map_.Get(origin);
|
| if (map_it != alternative_service_map_.end()) {
|
| @@ -333,6 +335,11 @@
|
| it = map_it->second.erase(it);
|
| continue;
|
| }
|
| + if (it->probability == 0 ||
|
| + it->probability < alternative_service_probability_threshold_) {
|
| + ++it;
|
| + continue;
|
| + }
|
| AlternativeService alternative_service(it->alternative_service);
|
| if (alternative_service.host.empty()) {
|
| alternative_service.host = origin.host();
|
| @@ -346,13 +353,13 @@
|
| ++it;
|
| continue;
|
| }
|
| - valid_alternative_services.push_back(alternative_service);
|
| + alternative_services_above_threshold.push_back(alternative_service);
|
| ++it;
|
| }
|
| if (map_it->second.empty()) {
|
| alternative_service_map_.Erase(map_it);
|
| }
|
| - return valid_alternative_services;
|
| + return alternative_services_above_threshold;
|
| }
|
|
|
| CanonicalHostMap::const_iterator canonical = GetCanonicalHost(origin);
|
| @@ -367,6 +374,10 @@
|
| it != map_it->second.end();) {
|
| if (it->expiration < now) {
|
| it = map_it->second.erase(it);
|
| + continue;
|
| + }
|
| + if (it->probability < alternative_service_probability_threshold_) {
|
| + ++it;
|
| continue;
|
| }
|
| AlternativeService alternative_service(it->alternative_service);
|
| @@ -381,23 +392,25 @@
|
| ++it;
|
| continue;
|
| }
|
| - valid_alternative_services.push_back(alternative_service);
|
| + alternative_services_above_threshold.push_back(alternative_service);
|
| ++it;
|
| }
|
| if (map_it->second.empty()) {
|
| alternative_service_map_.Erase(map_it);
|
| }
|
| - return valid_alternative_services;
|
| + return alternative_services_above_threshold;
|
| }
|
|
|
| bool HttpServerPropertiesImpl::SetAlternativeService(
|
| const HostPortPair& origin,
|
| const AlternativeService& alternative_service,
|
| + double alternative_probability,
|
| base::Time expiration) {
|
| return SetAlternativeServices(
|
| - origin,
|
| - AlternativeServiceInfoVector(
|
| - /*size=*/1, AlternativeServiceInfo(alternative_service, expiration)));
|
| + origin, AlternativeServiceInfoVector(
|
| + /*size=*/1,
|
| + AlternativeServiceInfo(alternative_service,
|
| + alternative_probability, expiration)));
|
| }
|
|
|
| bool HttpServerPropertiesImpl::SetAlternativeServices(
|
| @@ -682,6 +695,11 @@
|
| }
|
|
|
| quic_server_info_map_.Swap(temp_map);
|
| +}
|
| +
|
| +void HttpServerPropertiesImpl::SetAlternativeServiceProbabilityThreshold(
|
| + double threshold) {
|
| + alternative_service_probability_threshold_ = threshold;
|
| }
|
|
|
| AlternativeServiceMap::const_iterator
|
|
|