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

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

Issue 1233453011: Revert of 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], 120 if (base::EndsWith(it->first.host(), canonical_suffixes_[i], false)) {
121 base::CompareCase::INSENSITIVE_ASCII)) {
122 canonical_host_to_origin_map_[canonical_host] = it->first; 121 canonical_host_to_origin_map_[canonical_host] = it->first;
123 break; 122 break;
124 } 123 }
125 } 124 }
126 } 125 }
127 } 126 }
128 } 127 }
129 128
130 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( 129 void HttpServerPropertiesImpl::InitializeSpdySettingsServers(
131 SpdySettingsMap* spdy_settings_map) { 130 SpdySettingsMap* spdy_settings_map) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 ForceHTTP11(ssl_config); 253 ForceHTTP11(ssl_config);
255 } 254 }
256 } 255 }
257 256
258 std::string HttpServerPropertiesImpl::GetCanonicalSuffix( 257 std::string HttpServerPropertiesImpl::GetCanonicalSuffix(
259 const std::string& host) { 258 const std::string& host) {
260 // If this host ends with a canonical suffix, then return the canonical 259 // If this host ends with a canonical suffix, then return the canonical
261 // suffix. 260 // suffix.
262 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 261 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
263 std::string canonical_suffix = canonical_suffixes_[i]; 262 std::string canonical_suffix = canonical_suffixes_[i];
264 if (base::EndsWith(host, canonical_suffixes_[i], 263 if (base::EndsWith(host, canonical_suffixes_[i], false)) {
265 base::CompareCase::INSENSITIVE_ASCII)) {
266 return canonical_suffix; 264 return canonical_suffix;
267 } 265 }
268 } 266 }
269 return std::string(); 267 return std::string();
270 } 268 }
271 269
272 AlternativeServiceVector HttpServerPropertiesImpl::GetAlternativeServices( 270 AlternativeServiceVector HttpServerPropertiesImpl::GetAlternativeServices(
273 const HostPortPair& origin) { 271 const HostPortPair& origin) {
274 // Copy alternative services with probability greater than or equal to the 272 // Copy alternative services with probability greater than or equal to the
275 // threshold into |alternative_services_above_threshold|. 273 // threshold into |alternative_services_above_threshold|.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // TODO(rch): Consider the case where multiple requests are started 361 // TODO(rch): Consider the case where multiple requests are started
364 // before the first completes. In this case, only one of the jobs 362 // before the first completes. In this case, only one of the jobs
365 // would reach this code, whereas all of them should should have. 363 // would reach this code, whereas all of them should should have.
366 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); 364 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING);
367 } 365 }
368 366
369 // If this host ends with a canonical suffix, then set it as the 367 // If this host ends with a canonical suffix, then set it as the
370 // canonical host. 368 // canonical host.
371 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 369 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
372 std::string canonical_suffix = canonical_suffixes_[i]; 370 std::string canonical_suffix = canonical_suffixes_[i];
373 if (base::EndsWith(origin.host(), canonical_suffixes_[i], 371 if (base::EndsWith(origin.host(), canonical_suffixes_[i], false)) {
374 base::CompareCase::INSENSITIVE_ASCII)) {
375 HostPortPair canonical_host(canonical_suffix, origin.port()); 372 HostPortPair canonical_host(canonical_suffix, origin.port());
376 canonical_host_to_origin_map_[canonical_host] = origin; 373 canonical_host_to_origin_map_[canonical_host] = origin;
377 break; 374 break;
378 } 375 }
379 } 376 }
380 377
381 return changed; 378 return changed;
382 } 379 }
383 380
384 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( 381 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 } 604 }
608 605
609 RemoveCanonicalHost(canonical_host_port); 606 RemoveCanonicalHost(canonical_host_port);
610 return alternative_service_map_.end(); 607 return alternative_service_map_.end();
611 } 608 }
612 609
613 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator 610 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator
614 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const { 611 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const {
615 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 612 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
616 std::string canonical_suffix = canonical_suffixes_[i]; 613 std::string canonical_suffix = canonical_suffixes_[i];
617 if (base::EndsWith(server.host(), canonical_suffixes_[i], 614 if (base::EndsWith(server.host(), canonical_suffixes_[i], false)) {
618 base::CompareCase::INSENSITIVE_ASCII)) {
619 HostPortPair canonical_host(canonical_suffix, server.port()); 615 HostPortPair canonical_host(canonical_suffix, server.port());
620 return canonical_host_to_origin_map_.find(canonical_host); 616 return canonical_host_to_origin_map_.find(canonical_host);
621 } 617 }
622 } 618 }
623 619
624 return canonical_host_to_origin_map_.end(); 620 return canonical_host_to_origin_map_.end();
625 } 621 }
626 622
627 void HttpServerPropertiesImpl::RemoveCanonicalHost( 623 void HttpServerPropertiesImpl::RemoveCanonicalHost(
628 const HostPortPair& server) { 624 const HostPortPair& server) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 660 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
665 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 661 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
666 FROM_HERE, 662 FROM_HERE,
667 base::Bind( 663 base::Bind(
668 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 664 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
669 weak_ptr_factory_.GetWeakPtr()), 665 weak_ptr_factory_.GetWeakPtr()),
670 delay); 666 delay);
671 } 667 }
672 668
673 } // namespace net 669 } // 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