diff options
author | bnc <bnc@chromium.org> | 2015-01-26 17:43:22 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-27 01:44:07 +0000 |
commit | e5213fce048c62b058e9c3c9b9906cc2d0af182b (patch) | |
tree | 7d99f81eb25be52785f060b8a18f65c7108719ee /net/http/http_server_properties_impl.cc | |
parent | 9be085c313537c895fcaf1b8ec2ab33593743fee (diff) | |
download | chromium_src-e5213fce048c62b058e9c3c9b9906cc2d0af182b.zip chromium_src-e5213fce048c62b058e9c3c9b9906cc2d0af182b.tar.gz chromium_src-e5213fce048c62b058e9c3c9b9906cc2d0af182b.tar.bz2 |
Modify SetAlternateProtocol logging behavior.
Modify SetAlternateProtocol() behavior with respect to logging and histograms, by
ignoring alternate protocol being shadowed by |g_forced_alternate_protocol| or
being inactive due to too high probability threshold.
Also clean up HasAlternateProtocol() and GetAlternateProtocol().
BUG=392575
Review URL: https://codereview.chromium.org/858433004
Cr-Commit-Position: refs/heads/master@{#313197}
Diffstat (limited to 'net/http/http_server_properties_impl.cc')
-rw-r--r-- | net/http/http_server_properties_impl.cc | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc index a8bc04a..d048e98 100644 --- a/net/http/http_server_properties_impl.cc +++ b/net/http/http_server_properties_impl.cc @@ -227,17 +227,10 @@ bool HttpServerPropertiesImpl::HasAlternateProtocol( const HostPortPair& server) { if (g_forced_alternate_protocol) return true; - AlternateProtocolMap::const_iterator it = alternate_protocol_map_.Get(server); - if (it != alternate_protocol_map_.end()) - return it->second.probability >= alternate_protocol_probability_threshold_; - - auto canonical = GetCanonicalHost(server); - if (canonical == canonical_host_to_origin_map_.end() || - canonical->second.Equals(server)) { - return false; - } - - return HasAlternateProtocol(canonical->second); + AlternateProtocolMap::const_iterator it = + GetAlternateProtocolIterator(server); + return it != alternate_protocol_map_.end() && + it->second.probability >= alternate_protocol_probability_threshold_; } std::string HttpServerPropertiesImpl::GetCanonicalSuffix( @@ -258,16 +251,11 @@ HttpServerPropertiesImpl::GetAlternateProtocol( const HostPortPair& server) { DCHECK(HasAlternateProtocol(server)); - // First check the map. - AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server); + AlternateProtocolMap::const_iterator it = + GetAlternateProtocolIterator(server); if (it != alternate_protocol_map_.end()) return it->second; - // Next check the canonical host. - CanonicalHostMap::const_iterator canonical_host = GetCanonicalHost(server); - if (canonical_host != canonical_host_to_origin_map_.end()) - return alternate_protocol_map_.Get(canonical_host->second)->second; - // We must be forcing an alternate. DCHECK(g_forced_alternate_protocol); return *g_forced_alternate_protocol; @@ -282,9 +270,10 @@ void HttpServerPropertiesImpl::SetAlternateProtocol( AlternateProtocolInfo alternate(alternate_port, alternate_protocol, alternate_probability); - if (HasAlternateProtocol(server)) { - const AlternateProtocolInfo existing_alternate = - GetAlternateProtocol(server); + AlternateProtocolMap::const_iterator it = + GetAlternateProtocolIterator(server); + if (it != alternate_protocol_map_.end()) { + const AlternateProtocolInfo existing_alternate = it->second; if (existing_alternate.is_broken) { DVLOG(1) << "Ignore alternate protocol since it's known to be broken."; @@ -478,6 +467,20 @@ void HttpServerPropertiesImpl::SetAlternateProtocolProbabilityThreshold( alternate_protocol_probability_threshold_ = threshold; } +AlternateProtocolMap::const_iterator +HttpServerPropertiesImpl::GetAlternateProtocolIterator( + const HostPortPair& server) { + AlternateProtocolMap::const_iterator it = alternate_protocol_map_.Get(server); + if (it != alternate_protocol_map_.end()) + return it; + + CanonicalHostMap::const_iterator canonical = GetCanonicalHost(server); + if (canonical != canonical_host_to_origin_map_.end()) + return alternate_protocol_map_.Get(canonical->second); + + return alternate_protocol_map_.end(); +} + HttpServerPropertiesImpl::CanonicalHostMap::const_iterator HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const { for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |