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 66e6df85b337780541ffb84d924f09f661088573..d99af2c82767c90d19089934cc737c739a68c1fc 100644 |
--- a/chrome/browser/net/http_server_properties_manager.cc |
+++ b/chrome/browser/net/http_server_properties_manager.cc |
@@ -65,7 +65,7 @@ |
PrefService* pref_service) |
: pref_service_(pref_service), |
setting_prefs_(false) { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
DCHECK(pref_service); |
ui_weak_ptr_factory_.reset( |
new base::WeakPtrFactory<HttpServerPropertiesManager>(this)); |
@@ -80,12 +80,12 @@ |
} |
HttpServerPropertiesManager::~HttpServerPropertiesManager() { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
io_weak_ptr_factory_.reset(); |
} |
void HttpServerPropertiesManager::InitializeOnIOThread() { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
io_weak_ptr_factory_.reset( |
new base::WeakPtrFactory<HttpServerPropertiesManager>(this)); |
http_server_properties_impl_.reset(new net::HttpServerPropertiesImpl()); |
@@ -101,7 +101,7 @@ |
} |
void HttpServerPropertiesManager::ShutdownOnUIThread() { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
// Cancel any pending updates, and stop listening for pref change updates. |
ui_cache_update_timer_->Stop(); |
ui_weak_ptr_factory_.reset(); |
@@ -130,7 +130,7 @@ |
// This is required for conformance with the HttpServerProperties interface. |
base::WeakPtr<net::HttpServerProperties> |
HttpServerPropertiesManager::GetWeakPtr() { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return io_weak_ptr_factory_->GetWeakPtr(); |
} |
@@ -139,7 +139,7 @@ |
} |
void HttpServerPropertiesManager::Clear(const base::Closure& completion) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->Clear(); |
UpdatePrefsFromCacheOnIO(completion); |
@@ -147,14 +147,14 @@ |
bool HttpServerPropertiesManager::SupportsSpdy( |
const net::HostPortPair& server) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->SupportsSpdy(server); |
} |
void HttpServerPropertiesManager::SetSupportsSpdy( |
const net::HostPortPair& server, |
bool support_spdy) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); |
ScheduleUpdatePrefsOnIO(); |
@@ -162,85 +162,75 @@ |
bool HttpServerPropertiesManager::HasAlternateProtocol( |
const net::HostPortPair& server) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->HasAlternateProtocol(server); |
} |
-net::AlternateProtocolInfo |
+net::PortAlternateProtocolPair |
HttpServerPropertiesManager::GetAlternateProtocol( |
const net::HostPortPair& server) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->GetAlternateProtocol(server); |
} |
void HttpServerPropertiesManager::SetAlternateProtocol( |
const net::HostPortPair& server, |
uint16 alternate_port, |
- net::AlternateProtocol alternate_protocol, |
- double alternate_probability) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ net::AlternateProtocol alternate_protocol) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->SetAlternateProtocol( |
- server, alternate_port, alternate_protocol, alternate_probability); |
+ server, alternate_port, alternate_protocol); |
ScheduleUpdatePrefsOnIO(); |
} |
void HttpServerPropertiesManager::SetBrokenAlternateProtocol( |
const net::HostPortPair& server) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->SetBrokenAlternateProtocol(server); |
ScheduleUpdatePrefsOnIO(); |
} |
bool HttpServerPropertiesManager::WasAlternateProtocolRecentlyBroken( |
const net::HostPortPair& server) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->WasAlternateProtocolRecentlyBroken( |
server); |
} |
void HttpServerPropertiesManager::ConfirmAlternateProtocol( |
const net::HostPortPair& server) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->ConfirmAlternateProtocol(server); |
ScheduleUpdatePrefsOnIO(); |
} |
void HttpServerPropertiesManager::ClearAlternateProtocol( |
const net::HostPortPair& server) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->ClearAlternateProtocol(server); |
ScheduleUpdatePrefsOnIO(); |
} |
const net::AlternateProtocolMap& |
HttpServerPropertiesManager::alternate_protocol_map() const { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->alternate_protocol_map(); |
} |
void HttpServerPropertiesManager::SetAlternateProtocolExperiment( |
net::AlternateProtocolExperiment experiment) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
http_server_properties_impl_->SetAlternateProtocolExperiment(experiment); |
-} |
- |
-void HttpServerPropertiesManager::SetAlternateProtocolProbabilityThreshold( |
- double threshold) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
- http_server_properties_impl_->SetAlternateProtocolProbabilityThreshold( |
- threshold); |
} |
net::AlternateProtocolExperiment |
HttpServerPropertiesManager::GetAlternateProtocolExperiment() const { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
return http_server_properties_impl_->GetAlternateProtocolExperiment(); |
} |
const net::SettingsMap& |
HttpServerPropertiesManager::GetSpdySettings( |
const net::HostPortPair& host_port_pair) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->GetSpdySettings(host_port_pair); |
} |
@@ -249,7 +239,7 @@ |
net::SpdySettingsIds id, |
net::SpdySettingsFlags flags, |
uint32 value) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
bool persist = http_server_properties_impl_->SetSpdySetting( |
host_port_pair, id, flags, value); |
if (persist) |
@@ -259,34 +249,34 @@ |
void HttpServerPropertiesManager::ClearSpdySettings( |
const net::HostPortPair& host_port_pair) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->ClearSpdySettings(host_port_pair); |
ScheduleUpdatePrefsOnIO(); |
} |
void HttpServerPropertiesManager::ClearAllSpdySettings() { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->ClearAllSpdySettings(); |
ScheduleUpdatePrefsOnIO(); |
} |
const net::SpdySettingsMap& |
HttpServerPropertiesManager::spdy_settings_map() const { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->spdy_settings_map(); |
} |
void HttpServerPropertiesManager::SetServerNetworkStats( |
const net::HostPortPair& host_port_pair, |
NetworkStats stats) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); |
} |
const HttpServerPropertiesManager::NetworkStats* |
HttpServerPropertiesManager::GetServerNetworkStats( |
const net::HostPortPair& host_port_pair) const { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); |
} |
@@ -294,7 +284,7 @@ |
// Update the HttpServerPropertiesImpl's cache with data from preferences. |
// |
void HttpServerPropertiesManager::ScheduleUpdateCacheOnUI() { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
// Cancel pending updates, if any. |
ui_cache_update_timer_->Stop(); |
StartCacheUpdateTimerOnUI( |
@@ -303,7 +293,7 @@ |
void HttpServerPropertiesManager::StartCacheUpdateTimerOnUI( |
base::TimeDelta delay) { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
ui_cache_update_timer_->Start( |
FROM_HERE, delay, this, |
&HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI); |
@@ -311,7 +301,7 @@ |
void HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI() { |
// The preferences can only be read on the UI thread. |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
if (!pref_service_->HasPrefPath(prefs::kHttpServerProperties)) |
return; |
@@ -449,18 +439,10 @@ |
continue; |
} |
- 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); |
+ net::PortAlternateProtocolPair port_alternate_protocol; |
+ port_alternate_protocol.port = port; |
+ port_alternate_protocol.protocol = protocol; |
+ |
alternate_protocol_map->Put(server, port_alternate_protocol); |
++count; |
} while (false); |
@@ -487,7 +469,7 @@ |
bool detected_corrupted_prefs) { |
// Preferences have the master data because admins might have pushed new |
// preferences. Update the cached data with new data from preferences. |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
UMA_HISTOGRAM_COUNTS("Net.CountOfSpdyServers", spdy_servers->size()); |
http_server_properties_impl_->InitializeSpdyServers(spdy_servers, true); |
@@ -516,7 +498,7 @@ |
// Update Preferences with data from the cached data. |
// |
void HttpServerPropertiesManager::ScheduleUpdatePrefsOnIO() { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
// Cancel pending updates, if any. |
io_prefs_update_timer_->Stop(); |
StartPrefsUpdateTimerOnIO( |
@@ -525,7 +507,7 @@ |
void HttpServerPropertiesManager::StartPrefsUpdateTimerOnIO( |
base::TimeDelta delay) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
// This is overridden in tests to post the task without the delay. |
io_prefs_update_timer_->Start( |
FROM_HERE, delay, this, |
@@ -539,7 +521,7 @@ |
void HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO( |
const base::Closure& completion) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
base::ListValue* spdy_server_list = new base::ListValue; |
http_server_properties_impl_->GetSpdyServerList( |
@@ -591,7 +573,7 @@ |
} |
// A local or temporary data structure to hold |supports_spdy|, SpdySettings, |
-// and AlternateProtocolInfo preferences for a server. This is used only in |
+// and PortAlternateProtocolPair preferences for a server. This is used only in |
// UpdatePrefsOnUI. |
struct ServerPref { |
ServerPref() |
@@ -601,14 +583,14 @@ |
} |
ServerPref(bool supports_spdy, |
const net::SettingsMap* settings_map, |
- const net::AlternateProtocolInfo* alternate_protocol) |
+ const net::PortAlternateProtocolPair* alternate_protocol) |
: supports_spdy(supports_spdy), |
settings_map(settings_map), |
alternate_protocol(alternate_protocol) { |
} |
bool supports_spdy; |
const net::SettingsMap* settings_map; |
- const net::AlternateProtocolInfo* alternate_protocol; |
+ const net::PortAlternateProtocolPair* alternate_protocol; |
}; |
void HttpServerPropertiesManager::UpdatePrefsOnUI( |
@@ -620,7 +602,7 @@ |
typedef std::map<net::HostPortPair, ServerPref> ServerPrefMap; |
ServerPrefMap server_pref_map; |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
// Add servers that support spdy to server_pref_map. |
std::string s; |
@@ -658,7 +640,7 @@ |
alternate_protocol_map->begin(); |
map_it != alternate_protocol_map->end(); ++map_it) { |
const net::HostPortPair& server = map_it->first; |
- const net::AlternateProtocolInfo& port_alternate_protocol = |
+ const net::PortAlternateProtocolPair& port_alternate_protocol = |
map_it->second; |
if (!net::IsAlternateProtocolValid(port_alternate_protocol.protocol)) { |
continue; |
@@ -706,15 +688,13 @@ |
if (server_pref.alternate_protocol) { |
base::DictionaryValue* port_alternate_protocol_dict = |
new base::DictionaryValue; |
- const net::AlternateProtocolInfo* port_alternate_protocol = |
+ const net::PortAlternateProtocolPair* 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); |
} |
@@ -738,7 +718,7 @@ |
} |
void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
if (!setting_prefs_) |
ScheduleUpdateCacheOnUI(); |
} |