Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Side by Side Diff: net/http/http_server_properties_impl.cc

Issue 1205633002: Set alternative service even if it is broken. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: #7. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 573 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
583 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 574 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
584 FROM_HERE, 575 FROM_HERE,
585 base::Bind( 576 base::Bind(
586 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 577 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
587 weak_ptr_factory_.GetWeakPtr()), 578 weak_ptr_factory_.GetWeakPtr()),
588 delay); 579 delay);
589 } 580 }
590 581
591 } // namespace net 582 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698