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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 if (it->second.alternative_service.host.empty()) { | 271 if (it->second.alternative_service.host.empty()) { |
272 alternative_service.host = origin.host(); | 272 alternative_service.host = origin.host(); |
273 } | 273 } |
274 return alternative_service; | 274 return alternative_service; |
275 } | 275 } |
276 | 276 |
277 void HttpServerPropertiesImpl::SetAlternativeService( | 277 void HttpServerPropertiesImpl::SetAlternativeService( |
278 const HostPortPair& origin, | 278 const HostPortPair& origin, |
279 const AlternativeService& alternative_service, | 279 const AlternativeService& alternative_service, |
280 double alternative_probability) { | 280 double alternative_probability) { |
281 AlternativeService complete_alternative_service(alternative_service); | |
282 if (complete_alternative_service.host.empty()) { | |
283 complete_alternative_service.host = origin.host(); | |
284 } | |
285 if (IsAlternativeServiceBroken(complete_alternative_service)) { | |
286 DVLOG(1) << "Ignore alternative service since it is known to be broken."; | |
287 return; | |
288 } | |
289 | |
290 const AlternativeServiceInfo alternative_service_info( | 281 const AlternativeServiceInfo alternative_service_info( |
291 alternative_service, alternative_probability); | 282 alternative_service, alternative_probability); |
292 AlternativeServiceMap::const_iterator it = | 283 AlternativeServiceMap::const_iterator it = |
293 GetAlternateProtocolIterator(origin); | 284 GetAlternateProtocolIterator(origin); |
294 if (it == alternative_service_map_.end() && | 285 if (it == alternative_service_map_.end() && |
295 alternative_probability >= alternative_service_probability_threshold_) { | 286 alternative_probability >= alternative_service_probability_threshold_) { |
296 // TODO(rch): Consider the case where multiple requests are started | 287 // TODO(rch): Consider the case where multiple requests are started |
297 // before the first completes. In this case, only one of the jobs | 288 // before the first completes. In this case, only one of the jobs |
298 // would reach this code, whereas all of them should should have. | 289 // would reach this code, whereas all of them should should have. |
299 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); | 290 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 587 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
597 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 588 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
598 FROM_HERE, | 589 FROM_HERE, |
599 base::Bind( | 590 base::Bind( |
600 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 591 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
601 weak_ptr_factory_.GetWeakPtr()), | 592 weak_ptr_factory_.GetWeakPtr()), |
602 delay); | 593 delay); |
603 } | 594 } |
604 | 595 |
605 } // namespace net | 596 } // namespace net |
OLD | NEW |