Chromium Code Reviews| 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 84a7a9edb47f226f4b7e94b45996038de4b1d97b..ba615845145bcbaa65b9107bb78670ea963d297b 100644 |
| --- a/net/http/http_server_properties_impl.cc |
| +++ b/net/http/http_server_properties_impl.cc |
| @@ -255,20 +255,18 @@ AlternativeService HttpServerPropertiesImpl::GetAlternativeService( |
| return uninitialize_alternative_service; |
| } |
| -void HttpServerPropertiesImpl::SetAlternateProtocol( |
| +void HttpServerPropertiesImpl::SetAlternativeService( |
| const HostPortPair& origin, |
| - uint16 alternate_port, |
| - AlternateProtocol alternate_protocol, |
| - double alternate_probability) { |
| - const AlternativeService alternative_service(alternate_protocol, |
| - origin.host(), alternate_port); |
| + const AlternativeService& alternative_service, |
| + double alternative_probability) { |
| if (IsAlternativeServiceBroken(alternative_service)) { |
| DVLOG(1) << "Ignore alternative service since it is known to be broken."; |
| return; |
| } |
| - const AlternateProtocolInfo alternate(alternate_port, alternate_protocol, |
| - alternate_probability); |
| + const AlternateProtocolInfo alternate(alternative_service.port, |
| + alternative_service.protocol, |
| + alternative_probability); |
| AlternateProtocolMap::const_iterator it = |
| GetAlternateProtocolIterator(origin); |
| if (it != alternate_protocol_map_.end()) { |
| @@ -280,12 +278,12 @@ void HttpServerPropertiesImpl::SetAlternateProtocol( |
| << " from [Port: " << existing_alternate.port |
| << ", Protocol: " << existing_alternate.protocol |
| << ", Probability: " << existing_alternate.probability |
| - << "] to [Port: " << alternate_port |
| - << ", Protocol: " << alternate_protocol |
| - << ", Probability: " << alternate_probability << "]."; |
| + << "] to [Port: " << alternative_service.port |
| + << ", Protocol: " << alternative_service.protocol |
| + << ", Probability: " << alternative_probability << "]."; |
| } |
| } else { |
| - if (alternate_probability >= alternate_protocol_probability_threshold_) { |
| + if (alternative_probability >= alternate_protocol_probability_threshold_) { |
| // TODO(rch): Consider the case where multiple requests are started |
| // before the first completes. In this case, only one of the jobs |
| // would reach this code, whereas all of them should should have. |
| @@ -307,9 +305,8 @@ void HttpServerPropertiesImpl::SetAlternateProtocol( |
| } |
| } |
| -void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( |
| - const HostPortPair& origin) { |
| - const AlternativeService alternative_service = GetAlternativeService(origin); |
| +void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( |
| + const AlternativeService& alternative_service) { |
| if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| LOG(DFATAL) << "Trying to mark unknown alternate protocol broken."; |
| return; |
| @@ -325,10 +322,6 @@ void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( |
| return; |
| } |
| - // Do not leave this host as canonical so that we don't infer the other |
| - // hosts are also broken without testing them first. |
| - RemoveCanonicalHost(origin); |
|
Ryan Hamilton
2015/03/18 22:55:42
Because of your "Lazy delete" CL you don't need th
Bence
2015/03/19 12:45:39
Correct. This part of the diff will disappear onc
|
| - |
| // If this is the only entry in the list, schedule an expiration task. |
| // Otherwise it will be rescheduled automatically when the pending task runs. |
| if (broken_alternative_services_.size() == 1) { |
| @@ -347,25 +340,23 @@ bool HttpServerPropertiesImpl::IsAlternativeServiceBroken( |
| return ContainsKey(broken_alternative_services_, alternative_service); |
| } |
| -bool HttpServerPropertiesImpl::WasAlternateProtocolRecentlyBroken( |
| - const HostPortPair& origin) { |
| - const AlternativeService alternative_service = GetAlternativeService(origin); |
| +bool HttpServerPropertiesImpl::WasAlternativeServiceRecentlyBroken( |
| + const AlternativeService& alternative_service) { |
| if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| return false; |
| return ContainsKey(recently_broken_alternative_services_, |
| alternative_service); |
| } |
| -void HttpServerPropertiesImpl::ConfirmAlternateProtocol( |
| - const HostPortPair& origin) { |
| - const AlternativeService alternative_service = GetAlternativeService(origin); |
| +void HttpServerPropertiesImpl::ConfirmAlternativeService( |
| + const AlternativeService& alternative_service) { |
| if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| return; |
| broken_alternative_services_.erase(alternative_service); |
| recently_broken_alternative_services_.erase(alternative_service); |
| } |
| -void HttpServerPropertiesImpl::ClearAlternateProtocol( |
| +void HttpServerPropertiesImpl::ClearAlternativeService( |
| const HostPortPair& origin) { |
| RemoveCanonicalHost(origin); |
| @@ -493,9 +484,23 @@ HttpServerPropertiesImpl::GetAlternateProtocolIterator( |
| return it; |
| CanonicalHostMap::const_iterator canonical = GetCanonicalHost(server); |
| - if (canonical != canonical_host_to_origin_map_.end()) |
| - return alternate_protocol_map_.Get(canonical->second); |
| + if (canonical == canonical_host_to_origin_map_.end()) { |
| + return alternate_protocol_map_.end(); |
| + } |
| + |
| + const HostPortPair canonical_host_port = canonical->second; |
| + it = alternate_protocol_map_.Get(canonical_host_port); |
| + if (it == alternate_protocol_map_.end()) { |
| + return alternate_protocol_map_.end(); |
| + } |
| + |
| + const AlternativeService alternative_service( |
| + it->second.protocol, canonical_host_port.host(), it->second.port); |
| + if (!IsAlternativeServiceBroken(alternative_service)) { |
| + return it; |
| + } |
| + RemoveCanonicalHost(canonical_host_port); |
|
Ryan Hamilton
2015/03/18 22:55:42
Is in your other CL?
Bence
2015/03/19 12:45:39
Correct. This part of the diff will disappear onc
|
| return alternate_protocol_map_.end(); |
| } |
| @@ -535,7 +540,7 @@ void HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings() { |
| const AlternativeService alternative_service = it->first; |
| broken_alternative_services_.erase(it); |
| - ClearAlternateProtocol( |
| + ClearAlternativeService( |
| HostPortPair(alternative_service.host, alternative_service.port)); |
| } |
| ScheduleBrokenAlternateProtocolMappingsExpiration(); |