Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1905)

Unified Diff: net/http/http_server_properties_manager.cc

Issue 1802893002: Revert of Remove support for Alt-Svc/Alternate Protocol Probability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_server_properties_manager.cc
diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc
index a592f441bb09eb71cb7371d421b33e5fb63f5600..f8d133c91b0bd3fda6dd03c1c4392e1f7eb08c4a 100644
--- a/net/http/http_server_properties_manager.cc
+++ b/net/http/http_server_properties_manager.cc
@@ -61,6 +61,7 @@
const char kProtocolKey[] = "protocol_str";
const char kHostKey[] = "host";
const char kPortKey[] = "port";
+const char kProbabilityKey[] = "probability";
const char kExpirationKey[] = "expiration";
const char kNetworkStatsKey[] = "network_stats";
const char kSrttKey[] = "srtt";
@@ -194,10 +195,11 @@
bool HttpServerPropertiesManager::SetAlternativeService(
const HostPortPair& origin,
const AlternativeService& alternative_service,
+ double alternative_probability,
base::Time expiration) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
const bool changed = http_server_properties_impl_->SetAlternativeService(
- origin, alternative_service, expiration);
+ origin, alternative_service, alternative_probability, expiration);
if (changed) {
ScheduleUpdatePrefsOnNetworkThread(SET_ALTERNATIVE_SERVICES);
}
@@ -284,6 +286,13 @@
const {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
return http_server_properties_impl_->GetAlternativeServiceInfoAsValue();
+}
+
+void HttpServerPropertiesManager::SetAlternativeServiceProbabilityThreshold(
+ double threshold) {
+ DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
+ http_server_properties_impl_->SetAlternativeServiceProbabilityThreshold(
+ threshold);
}
const SettingsMap& HttpServerPropertiesManager::GetSpdySettings(
@@ -652,6 +661,16 @@
}
alternative_service_info->alternative_service.port =
static_cast<uint32_t>(port);
+
+ // Probability is optional, defaults to 1.0.
+ alternative_service_info->probability = 1.0;
+ if (alternative_service_dict.HasKey(kProbabilityKey) &&
+ !alternative_service_dict.GetDoubleWithoutPathExpansion(
+ kProbabilityKey, &(alternative_service_info->probability))) {
+ DVLOG(1) << "Malformed alternative service probability for server: "
+ << server_str;
+ return false;
+ }
// Expiration is optional, defaults to one day.
base::Time expiration;
@@ -1177,6 +1196,8 @@
}
alternative_service_dict->SetString(
kProtocolKey, AlternateProtocolToString(alternative_service.protocol));
+ alternative_service_dict->SetDouble(kProbabilityKey,
+ alternative_service_info.probability);
// JSON cannot store int64_t, so expiration is converted to a string.
alternative_service_dict->SetString(
kExpirationKey,
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698