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

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

Issue 1233043003: Remove some legacy versions of StartsWith and EndsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | « net/http/http_network_transaction.cc ('k') | net/quic/crypto/quic_crypto_client_config.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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 (alternative_service_map_.Peek( 110 (alternative_service_map_.Peek(
111 canonical_host_to_origin_map_[canonical_host]) != 111 canonical_host_to_origin_map_[canonical_host]) !=
112 alternative_service_map_.end())) { 112 alternative_service_map_.end())) {
113 continue; 113 continue;
114 } 114 }
115 // Now attempt to find a server which matches this origin and set it as 115 // Now attempt to find a server which matches this origin and set it as
116 // canonical. 116 // canonical.
117 for (AlternativeServiceMap::const_iterator it = 117 for (AlternativeServiceMap::const_iterator it =
118 alternative_service_map_.begin(); 118 alternative_service_map_.begin();
119 it != alternative_service_map_.end(); ++it) { 119 it != alternative_service_map_.end(); ++it) {
120 if (base::EndsWith(it->first.host(), canonical_suffixes_[i], false)) { 120 if (base::EndsWith(it->first.host(), canonical_suffixes_[i],
121 base::CompareCase::INSENSITIVE_ASCII)) {
121 canonical_host_to_origin_map_[canonical_host] = it->first; 122 canonical_host_to_origin_map_[canonical_host] = it->first;
122 break; 123 break;
123 } 124 }
124 } 125 }
125 } 126 }
126 } 127 }
127 } 128 }
128 129
129 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( 130 void HttpServerPropertiesImpl::InitializeSpdySettingsServers(
130 SpdySettingsMap* spdy_settings_map) { 131 SpdySettingsMap* spdy_settings_map) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ForceHTTP11(ssl_config); 254 ForceHTTP11(ssl_config);
254 } 255 }
255 } 256 }
256 257
257 std::string HttpServerPropertiesImpl::GetCanonicalSuffix( 258 std::string HttpServerPropertiesImpl::GetCanonicalSuffix(
258 const std::string& host) { 259 const std::string& host) {
259 // If this host ends with a canonical suffix, then return the canonical 260 // If this host ends with a canonical suffix, then return the canonical
260 // suffix. 261 // suffix.
261 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 262 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
262 std::string canonical_suffix = canonical_suffixes_[i]; 263 std::string canonical_suffix = canonical_suffixes_[i];
263 if (base::EndsWith(host, canonical_suffixes_[i], false)) { 264 if (base::EndsWith(host, canonical_suffixes_[i],
265 base::CompareCase::INSENSITIVE_ASCII)) {
264 return canonical_suffix; 266 return canonical_suffix;
265 } 267 }
266 } 268 }
267 return std::string(); 269 return std::string();
268 } 270 }
269 271
270 AlternativeServiceVector HttpServerPropertiesImpl::GetAlternativeServices( 272 AlternativeServiceVector HttpServerPropertiesImpl::GetAlternativeServices(
271 const HostPortPair& origin) { 273 const HostPortPair& origin) {
272 // Copy alternative services with probability greater than or equal to the 274 // Copy alternative services with probability greater than or equal to the
273 // threshold into |alternative_services_above_threshold|. 275 // threshold into |alternative_services_above_threshold|.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // TODO(rch): Consider the case where multiple requests are started 363 // TODO(rch): Consider the case where multiple requests are started
362 // before the first completes. In this case, only one of the jobs 364 // before the first completes. In this case, only one of the jobs
363 // would reach this code, whereas all of them should should have. 365 // would reach this code, whereas all of them should should have.
364 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); 366 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING);
365 } 367 }
366 368
367 // If this host ends with a canonical suffix, then set it as the 369 // If this host ends with a canonical suffix, then set it as the
368 // canonical host. 370 // canonical host.
369 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 371 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
370 std::string canonical_suffix = canonical_suffixes_[i]; 372 std::string canonical_suffix = canonical_suffixes_[i];
371 if (base::EndsWith(origin.host(), canonical_suffixes_[i], false)) { 373 if (base::EndsWith(origin.host(), canonical_suffixes_[i],
374 base::CompareCase::INSENSITIVE_ASCII)) {
372 HostPortPair canonical_host(canonical_suffix, origin.port()); 375 HostPortPair canonical_host(canonical_suffix, origin.port());
373 canonical_host_to_origin_map_[canonical_host] = origin; 376 canonical_host_to_origin_map_[canonical_host] = origin;
374 break; 377 break;
375 } 378 }
376 } 379 }
377 380
378 return changed; 381 return changed;
379 } 382 }
380 383
381 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( 384 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 607 }
605 608
606 RemoveCanonicalHost(canonical_host_port); 609 RemoveCanonicalHost(canonical_host_port);
607 return alternative_service_map_.end(); 610 return alternative_service_map_.end();
608 } 611 }
609 612
610 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator 613 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator
611 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const { 614 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const {
612 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 615 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
613 std::string canonical_suffix = canonical_suffixes_[i]; 616 std::string canonical_suffix = canonical_suffixes_[i];
614 if (base::EndsWith(server.host(), canonical_suffixes_[i], false)) { 617 if (base::EndsWith(server.host(), canonical_suffixes_[i],
618 base::CompareCase::INSENSITIVE_ASCII)) {
615 HostPortPair canonical_host(canonical_suffix, server.port()); 619 HostPortPair canonical_host(canonical_suffix, server.port());
616 return canonical_host_to_origin_map_.find(canonical_host); 620 return canonical_host_to_origin_map_.find(canonical_host);
617 } 621 }
618 } 622 }
619 623
620 return canonical_host_to_origin_map_.end(); 624 return canonical_host_to_origin_map_.end();
621 } 625 }
622 626
623 void HttpServerPropertiesImpl::RemoveCanonicalHost( 627 void HttpServerPropertiesImpl::RemoveCanonicalHost(
624 const HostPortPair& server) { 628 const HostPortPair& server) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 664 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
661 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 665 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
662 FROM_HERE, 666 FROM_HERE,
663 base::Bind( 667 base::Bind(
664 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 668 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
665 weak_ptr_factory_.GetWeakPtr()), 669 weak_ptr_factory_.GetWeakPtr()),
666 delay); 670 delay);
667 } 671 }
668 672
669 } // namespace net 673 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/quic/crypto/quic_crypto_client_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698