OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_server_properties_impl.h" | 5 #include "net/http/http_server_properties_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 285 } |
286 if (IsAlternativeServiceBroken(complete_alternative_service)) { | 286 if (IsAlternativeServiceBroken(complete_alternative_service)) { |
287 DVLOG(1) << "Ignore alternative service since it is known to be broken."; | 287 DVLOG(1) << "Ignore alternative service since it is known to be broken."; |
288 return; | 288 return; |
289 } | 289 } |
290 | 290 |
291 const AlternativeServiceInfo alternative_service_info( | 291 const AlternativeServiceInfo alternative_service_info( |
292 alternative_service, alternative_probability); | 292 alternative_service, alternative_probability); |
293 AlternativeServiceMap::const_iterator it = | 293 AlternativeServiceMap::const_iterator it = |
294 GetAlternateProtocolIterator(origin); | 294 GetAlternateProtocolIterator(origin); |
295 if (it != alternative_service_map_.end()) { | 295 if (it == alternative_service_map_.end() && |
296 const AlternativeServiceInfo existing_alternative_service_info = it->second; | 296 alternative_probability >= alternative_service_probability_threshold_) { |
297 if (existing_alternative_service_info != alternative_service_info) { | 297 // TODO(rch): Consider the case where multiple requests are started |
298 LOG(WARNING) << "Changing the alternative service for: " | 298 // before the first completes. In this case, only one of the jobs |
299 << origin.ToString() << " from " | 299 // would reach this code, whereas all of them should should have. |
300 << existing_alternative_service_info.ToString() << " to " | 300 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); |
301 << alternative_service_info.ToString() << "."; | |
302 } | |
303 } else { | |
304 if (alternative_probability >= alternative_service_probability_threshold_) { | |
305 // TODO(rch): Consider the case where multiple requests are started | |
306 // before the first completes. In this case, only one of the jobs | |
307 // would reach this code, whereas all of them should should have. | |
308 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); | |
309 } | |
310 } | 301 } |
311 | 302 |
312 alternative_service_map_.Put(origin, alternative_service_info); | 303 alternative_service_map_.Put(origin, alternative_service_info); |
313 | 304 |
314 // If this host ends with a canonical suffix, then set it as the | 305 // If this host ends with a canonical suffix, then set it as the |
315 // canonical host. | 306 // canonical host. |
316 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 307 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
317 std::string canonical_suffix = canonical_suffixes_[i]; | 308 std::string canonical_suffix = canonical_suffixes_[i]; |
318 if (base::EndsWith(origin.host(), canonical_suffixes_[i], false)) { | 309 if (base::EndsWith(origin.host(), canonical_suffixes_[i], false)) { |
319 HostPortPair canonical_host(canonical_suffix, origin.port()); | 310 HostPortPair canonical_host(canonical_suffix, origin.port()); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 597 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
607 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 598 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
608 FROM_HERE, | 599 FROM_HERE, |
609 base::Bind( | 600 base::Bind( |
610 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 601 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
611 weak_ptr_factory_.GetWeakPtr()), | 602 weak_ptr_factory_.GetWeakPtr()), |
612 delay); | 603 delay); |
613 } | 604 } |
614 | 605 |
615 } // namespace net | 606 } // namespace net |
OLD | NEW |