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

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

Issue 1182183003: Move EndsWith to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « 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 "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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 (alternative_service_map_.Peek( 82 (alternative_service_map_.Peek(
83 canonical_host_to_origin_map_[canonical_host]) != 83 canonical_host_to_origin_map_[canonical_host]) !=
84 alternative_service_map_.end())) { 84 alternative_service_map_.end())) {
85 continue; 85 continue;
86 } 86 }
87 // Now attempt to find a server which matches this origin and set it as 87 // Now attempt to find a server which matches this origin and set it as
88 // canonical. 88 // canonical.
89 for (AlternativeServiceMap::const_iterator it = 89 for (AlternativeServiceMap::const_iterator it =
90 alternative_service_map_.begin(); 90 alternative_service_map_.begin();
91 it != alternative_service_map_.end(); ++it) { 91 it != alternative_service_map_.end(); ++it) {
92 if (EndsWith(it->first.host(), canonical_suffixes_[i], false)) { 92 if (base::EndsWith(it->first.host(), canonical_suffixes_[i], false)) {
93 canonical_host_to_origin_map_[canonical_host] = it->first; 93 canonical_host_to_origin_map_[canonical_host] = it->first;
94 break; 94 break;
95 } 95 }
96 } 96 }
97 } 97 }
98 } 98 }
99 } 99 }
100 100
101 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( 101 void HttpServerPropertiesImpl::InitializeSpdySettingsServers(
102 SpdySettingsMap* spdy_settings_map) { 102 SpdySettingsMap* spdy_settings_map) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 ForceHTTP11(ssl_config); 219 ForceHTTP11(ssl_config);
220 } 220 }
221 } 221 }
222 222
223 std::string HttpServerPropertiesImpl::GetCanonicalSuffix( 223 std::string HttpServerPropertiesImpl::GetCanonicalSuffix(
224 const std::string& host) { 224 const std::string& host) {
225 // If this host ends with a canonical suffix, then return the canonical 225 // If this host ends with a canonical suffix, then return the canonical
226 // suffix. 226 // suffix.
227 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 227 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
228 std::string canonical_suffix = canonical_suffixes_[i]; 228 std::string canonical_suffix = canonical_suffixes_[i];
229 if (EndsWith(host, canonical_suffixes_[i], false)) { 229 if (base::EndsWith(host, canonical_suffixes_[i], false)) {
230 return canonical_suffix; 230 return canonical_suffix;
231 } 231 }
232 } 232 }
233 return std::string(); 233 return std::string();
234 } 234 }
235 235
236 AlternativeService HttpServerPropertiesImpl::GetAlternativeService( 236 AlternativeService HttpServerPropertiesImpl::GetAlternativeService(
237 const HostPortPair& origin) { 237 const HostPortPair& origin) {
238 AlternativeServiceMap::const_iterator it = 238 AlternativeServiceMap::const_iterator it =
239 alternative_service_map_.Get(origin); 239 alternative_service_map_.Get(origin);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); 308 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING);
309 } 309 }
310 } 310 }
311 311
312 alternative_service_map_.Put(origin, alternative_service_info); 312 alternative_service_map_.Put(origin, alternative_service_info);
313 313
314 // If this host ends with a canonical suffix, then set it as the 314 // If this host ends with a canonical suffix, then set it as the
315 // canonical host. 315 // canonical host.
316 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 316 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
317 std::string canonical_suffix = canonical_suffixes_[i]; 317 std::string canonical_suffix = canonical_suffixes_[i];
318 if (EndsWith(origin.host(), canonical_suffixes_[i], false)) { 318 if (base::EndsWith(origin.host(), canonical_suffixes_[i], false)) {
319 HostPortPair canonical_host(canonical_suffix, origin.port()); 319 HostPortPair canonical_host(canonical_suffix, origin.port());
320 canonical_host_to_origin_map_[canonical_host] = origin; 320 canonical_host_to_origin_map_[canonical_host] = origin;
321 break; 321 break;
322 } 322 }
323 } 323 }
324 } 324 }
325 325
326 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( 326 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken(
327 const AlternativeService& alternative_service) { 327 const AlternativeService& alternative_service) {
328 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { 328 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } 550 }
551 551
552 RemoveCanonicalHost(canonical_host_port); 552 RemoveCanonicalHost(canonical_host_port);
553 return alternative_service_map_.end(); 553 return alternative_service_map_.end();
554 } 554 }
555 555
556 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator 556 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator
557 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const { 557 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const {
558 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 558 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
559 std::string canonical_suffix = canonical_suffixes_[i]; 559 std::string canonical_suffix = canonical_suffixes_[i];
560 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { 560 if (base::EndsWith(server.host(), canonical_suffixes_[i], false)) {
561 HostPortPair canonical_host(canonical_suffix, server.port()); 561 HostPortPair canonical_host(canonical_suffix, server.port());
562 return canonical_host_to_origin_map_.find(canonical_host); 562 return canonical_host_to_origin_map_.find(canonical_host);
563 } 563 }
564 } 564 }
565 565
566 return canonical_host_to_origin_map_.end(); 566 return canonical_host_to_origin_map_.end();
567 } 567 }
568 568
569 void HttpServerPropertiesImpl::RemoveCanonicalHost( 569 void HttpServerPropertiesImpl::RemoveCanonicalHost(
570 const HostPortPair& server) { 570 const HostPortPair& server) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 606 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
607 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 607 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
608 FROM_HERE, 608 FROM_HERE,
609 base::Bind( 609 base::Bind(
610 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 610 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
611 weak_ptr_factory_.GetWeakPtr()), 611 weak_ptr_factory_.GetWeakPtr()),
612 delay); 612 delay);
613 } 613 }
614 614
615 } // namespace net 615 } // 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