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

Unified Diff: chrome/browser/net/http_server_properties_manager.cc

Issue 339663010: Add a probability to Alternate-Protocol support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better plumbing Created 6 years, 6 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
Index: chrome/browser/net/http_server_properties_manager.cc
diff --git a/chrome/browser/net/http_server_properties_manager.cc b/chrome/browser/net/http_server_properties_manager.cc
index d99af2c82767c90d19089934cc737c739a68c1fc..14837fe8b6a6b99bd0419d6bfd65e6dde3a6cbf4 100644
--- a/chrome/browser/net/http_server_properties_manager.cc
+++ b/chrome/browser/net/http_server_properties_manager.cc
@@ -166,7 +166,7 @@ bool HttpServerPropertiesManager::HasAlternateProtocol(
return http_server_properties_impl_->HasAlternateProtocol(server);
}
-net::PortAlternateProtocolPair
+net::AlternateProtocolInfo
HttpServerPropertiesManager::GetAlternateProtocol(
const net::HostPortPair& server) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -176,10 +176,11 @@ HttpServerPropertiesManager::GetAlternateProtocol(
void HttpServerPropertiesManager::SetAlternateProtocol(
const net::HostPortPair& server,
uint16 alternate_port,
- net::AlternateProtocol alternate_protocol) {
+ net::AlternateProtocol alternate_protocol,
+ double alternate_probability) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
http_server_properties_impl_->SetAlternateProtocol(
- server, alternate_port, alternate_protocol);
+ server, alternate_port, alternate_protocol, alternate_probability);
ScheduleUpdatePrefsOnIO();
}
@@ -219,11 +220,20 @@ HttpServerPropertiesManager::alternate_protocol_map() const {
void HttpServerPropertiesManager::SetAlternateProtocolExperiment(
net::AlternateProtocolExperiment experiment) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ramant (doing other things) 2014/06/27 22:38:13 Thanks for adding the DCHECKs.
Ryan Hamilton 2014/06/30 19:02:34 My pleasure!
http_server_properties_impl_->SetAlternateProtocolExperiment(experiment);
}
+void HttpServerPropertiesManager::SetAlternateProtocolProbabilityThreshold(
+ double threshold) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ http_server_properties_impl_->SetAlternateProtocolProbabilityThreshold(
+ threshold);
+}
+
net::AlternateProtocolExperiment
HttpServerPropertiesManager::GetAlternateProtocolExperiment() const {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
return http_server_properties_impl_->GetAlternateProtocolExperiment();
}
@@ -439,10 +449,18 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI() {
continue;
}
- net::PortAlternateProtocolPair port_alternate_protocol;
- port_alternate_protocol.port = port;
- port_alternate_protocol.protocol = protocol;
+ double probability = 1;
+ if (port_alternate_protocol_dict->HasKey("probability") &&
+ !port_alternate_protocol_dict->GetDoubleWithoutPathExpansion(
+ "probability", &probability)) {
+ DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str;
+ detected_corrupted_prefs = true;
+ continue;
+ }
+ net::AlternateProtocolInfo port_alternate_protocol(port,
+ protocol,
+ probability);
alternate_protocol_map->Put(server, port_alternate_protocol);
++count;
} while (false);
@@ -573,7 +591,7 @@ void HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO(
}
// A local or temporary data structure to hold |supports_spdy|, SpdySettings,
-// and PortAlternateProtocolPair preferences for a server. This is used only in
+// and AlternateProtocolInfo preferences for a server. This is used only in
// UpdatePrefsOnUI.
struct ServerPref {
ServerPref()
@@ -583,14 +601,14 @@ struct ServerPref {
}
ServerPref(bool supports_spdy,
const net::SettingsMap* settings_map,
- const net::PortAlternateProtocolPair* alternate_protocol)
+ const net::AlternateProtocolInfo* alternate_protocol)
: supports_spdy(supports_spdy),
settings_map(settings_map),
alternate_protocol(alternate_protocol) {
}
bool supports_spdy;
const net::SettingsMap* settings_map;
- const net::PortAlternateProtocolPair* alternate_protocol;
+ const net::AlternateProtocolInfo* alternate_protocol;
};
void HttpServerPropertiesManager::UpdatePrefsOnUI(
@@ -640,7 +658,7 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI(
alternate_protocol_map->begin();
map_it != alternate_protocol_map->end(); ++map_it) {
const net::HostPortPair& server = map_it->first;
- const net::PortAlternateProtocolPair& port_alternate_protocol =
+ const net::AlternateProtocolInfo& port_alternate_protocol =
map_it->second;
if (!net::IsAlternateProtocolValid(port_alternate_protocol.protocol)) {
continue;
@@ -688,13 +706,15 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI(
if (server_pref.alternate_protocol) {
base::DictionaryValue* port_alternate_protocol_dict =
new base::DictionaryValue;
- const net::PortAlternateProtocolPair* port_alternate_protocol =
+ const net::AlternateProtocolInfo* port_alternate_protocol =
server_pref.alternate_protocol;
port_alternate_protocol_dict->SetInteger(
"port", port_alternate_protocol->port);
const char* protocol_str =
net::AlternateProtocolToString(port_alternate_protocol->protocol);
port_alternate_protocol_dict->SetString("protocol_str", protocol_str);
+ port_alternate_protocol_dict->SetDouble(
+ "probability", port_alternate_protocol->probability);
server_pref_dict->SetWithoutPathExpansion(
"alternate_protocol", port_alternate_protocol_dict);
}

Powered by Google App Engine
This is Rietveld 408576698