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

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

Issue 1091283007: Rename methods and members and const variables to alternative service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace { 19 namespace {
20 20
21 const uint64 kBrokenAlternativeProtocolDelaySecs = 300; 21 const uint64 kBrokenAlternativeProtocolDelaySecs = 300;
22 22
23 } // namespace 23 } // namespace
24 24
25 HttpServerPropertiesImpl::HttpServerPropertiesImpl() 25 HttpServerPropertiesImpl::HttpServerPropertiesImpl()
26 : spdy_servers_map_(SpdyServerHostPortMap::NO_AUTO_EVICT), 26 : spdy_servers_map_(SpdyServerHostPortMap::NO_AUTO_EVICT),
27 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), 27 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT),
28 spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT), 28 spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT),
29 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), 29 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT),
30 alternate_protocol_probability_threshold_(1), 30 alternative_service_probability_threshold_(1.0),
31 weak_ptr_factory_(this) { 31 weak_ptr_factory_(this) {
32 canonical_suffixes_.push_back(".c.youtube.com"); 32 canonical_suffixes_.push_back(".c.youtube.com");
33 canonical_suffixes_.push_back(".googlevideo.com"); 33 canonical_suffixes_.push_back(".googlevideo.com");
34 canonical_suffixes_.push_back(".googleusercontent.com"); 34 canonical_suffixes_.push_back(".googleusercontent.com");
35 } 35 }
36 36
37 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { 37 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() {
38 } 38 }
39 39
40 void HttpServerPropertiesImpl::InitializeSpdyServers( 40 void HttpServerPropertiesImpl::InitializeSpdyServers(
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 } 221 }
222 return std::string(); 222 return std::string();
223 } 223 }
224 224
225 AlternativeService HttpServerPropertiesImpl::GetAlternativeService( 225 AlternativeService HttpServerPropertiesImpl::GetAlternativeService(
226 const HostPortPair& origin) { 226 const HostPortPair& origin) {
227 AlternativeServiceMap::const_iterator it = 227 AlternativeServiceMap::const_iterator it =
228 alternative_service_map_.Get(origin); 228 alternative_service_map_.Get(origin);
229 if (it != alternative_service_map_.end()) { 229 if (it != alternative_service_map_.end()) {
230 if (it->second.probability < alternate_protocol_probability_threshold_) { 230 if (it->second.probability < alternative_service_probability_threshold_) {
231 return AlternativeService(); 231 return AlternativeService();
232 } 232 }
233 AlternativeService alternative_service(it->second.alternative_service); 233 AlternativeService alternative_service(it->second.alternative_service);
234 if (alternative_service.host.empty()) { 234 if (alternative_service.host.empty()) {
235 alternative_service.host = origin.host(); 235 alternative_service.host = origin.host();
236 } 236 }
237 return alternative_service; 237 return alternative_service;
238 } 238 }
239 239
240 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(origin); 240 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(origin);
241 if (canonical == canonical_host_to_origin_map_.end()) { 241 if (canonical == canonical_host_to_origin_map_.end()) {
242 return AlternativeService(); 242 return AlternativeService();
243 } 243 }
244 it = alternative_service_map_.Get(canonical->second); 244 it = alternative_service_map_.Get(canonical->second);
245 if (it == alternative_service_map_.end()) { 245 if (it == alternative_service_map_.end()) {
246 return AlternativeService(); 246 return AlternativeService();
247 } 247 }
248 if (it->second.probability < alternate_protocol_probability_threshold_) { 248 if (it->second.probability < alternative_service_probability_threshold_) {
249 return AlternativeService(); 249 return AlternativeService();
250 } 250 }
251 AlternativeService alternative_service(it->second.alternative_service); 251 AlternativeService alternative_service(it->second.alternative_service);
252 if (alternative_service.host.empty()) { 252 if (alternative_service.host.empty()) {
253 alternative_service.host = canonical->second.host(); 253 alternative_service.host = canonical->second.host();
254 } 254 }
255 if (IsAlternativeServiceBroken(alternative_service)) { 255 if (IsAlternativeServiceBroken(alternative_service)) {
256 RemoveCanonicalHost(canonical->second); 256 RemoveCanonicalHost(canonical->second);
257 return AlternativeService(); 257 return AlternativeService();
258 } 258 }
(...skipping 24 matching lines...) Expand all
283 GetAlternateProtocolIterator(origin); 283 GetAlternateProtocolIterator(origin);
284 if (it != alternative_service_map_.end()) { 284 if (it != alternative_service_map_.end()) {
285 const AlternativeServiceInfo existing_alternative_service_info = it->second; 285 const AlternativeServiceInfo existing_alternative_service_info = it->second;
286 if (existing_alternative_service_info != alternative_service_info) { 286 if (existing_alternative_service_info != alternative_service_info) {
287 LOG(WARNING) << "Changing the alternative service for: " 287 LOG(WARNING) << "Changing the alternative service for: "
288 << origin.ToString() << " from " 288 << origin.ToString() << " from "
289 << existing_alternative_service_info.ToString() << " to " 289 << existing_alternative_service_info.ToString() << " to "
290 << alternative_service_info.ToString() << "."; 290 << alternative_service_info.ToString() << ".";
291 } 291 }
292 } else { 292 } else {
293 if (alternative_probability >= alternate_protocol_probability_threshold_) { 293 if (alternative_probability >= alternative_service_probability_threshold_) {
294 // TODO(rch): Consider the case where multiple requests are started 294 // TODO(rch): Consider the case where multiple requests are started
295 // before the first completes. In this case, only one of the jobs 295 // before the first completes. In this case, only one of the jobs
296 // would reach this code, whereas all of them should should have. 296 // would reach this code, whereas all of them should should have.
297 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); 297 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING);
298 } 298 }
299 } 299 }
300 300
301 alternative_service_map_.Put(origin, alternative_service_info); 301 alternative_service_map_.Put(origin, alternative_service_info);
302 302
303 // If this host ends with a canonical suffix, then set it as the 303 // If this host ends with a canonical suffix, then set it as the
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return NULL; 499 return NULL;
500 } 500 }
501 return &it->second; 501 return &it->second;
502 } 502 }
503 503
504 const ServerNetworkStatsMap& 504 const ServerNetworkStatsMap&
505 HttpServerPropertiesImpl::server_network_stats_map() const { 505 HttpServerPropertiesImpl::server_network_stats_map() const {
506 return server_network_stats_map_; 506 return server_network_stats_map_;
507 } 507 }
508 508
509 void HttpServerPropertiesImpl::SetAlternateProtocolProbabilityThreshold( 509 void HttpServerPropertiesImpl::SetAlternativeServiceProbabilityThreshold(
510 double threshold) { 510 double threshold) {
511 alternate_protocol_probability_threshold_ = threshold; 511 alternative_service_probability_threshold_ = threshold;
512 } 512 }
513 513
514 AlternativeServiceMap::const_iterator 514 AlternativeServiceMap::const_iterator
515 HttpServerPropertiesImpl::GetAlternateProtocolIterator( 515 HttpServerPropertiesImpl::GetAlternateProtocolIterator(
516 const HostPortPair& server) { 516 const HostPortPair& server) {
517 AlternativeServiceMap::const_iterator it = 517 AlternativeServiceMap::const_iterator it =
518 alternative_service_map_.Get(server); 518 alternative_service_map_.Get(server);
519 if (it != alternative_service_map_.end()) 519 if (it != alternative_service_map_.end())
520 return it; 520 return it;
521 521
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 594 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
595 base::MessageLoop::current()->PostDelayedTask( 595 base::MessageLoop::current()->PostDelayedTask(
596 FROM_HERE, 596 FROM_HERE,
597 base::Bind( 597 base::Bind(
598 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 598 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
599 weak_ptr_factory_.GetWeakPtr()), 599 weak_ptr_factory_.GetWeakPtr()),
600 delay); 600 delay);
601 } 601 }
602 602
603 } // namespace net 603 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698