| OLD | NEW |
| 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" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 (alternative_service_map_.Peek( | 80 (alternative_service_map_.Peek( |
| 81 canonical_host_to_origin_map_[canonical_host]) != | 81 canonical_host_to_origin_map_[canonical_host]) != |
| 82 alternative_service_map_.end())) { | 82 alternative_service_map_.end())) { |
| 83 continue; | 83 continue; |
| 84 } | 84 } |
| 85 // Now attempt to find a server which matches this origin and set it as | 85 // Now attempt to find a server which matches this origin and set it as |
| 86 // canonical. | 86 // canonical. |
| 87 for (AlternativeServiceMap::const_iterator it = | 87 for (AlternativeServiceMap::const_iterator it = |
| 88 alternative_service_map_.begin(); | 88 alternative_service_map_.begin(); |
| 89 it != alternative_service_map_.end(); ++it) { | 89 it != alternative_service_map_.end(); ++it) { |
| 90 if (EndsWith(it->first.host(), canonical_suffixes_[i], false)) { | 90 if (base::EndsWith(it->first.host(), canonical_suffixes_[i], |
| 91 base::CompareCase::SENSITIVE)) { |
| 91 canonical_host_to_origin_map_[canonical_host] = it->first; | 92 canonical_host_to_origin_map_[canonical_host] = it->first; |
| 92 break; | 93 break; |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 | 99 |
| 99 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( | 100 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( |
| 100 SpdySettingsMap* spdy_settings_map) { | 101 SpdySettingsMap* spdy_settings_map) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 ForceHTTP11(ssl_config); | 209 ForceHTTP11(ssl_config); |
| 209 } | 210 } |
| 210 } | 211 } |
| 211 | 212 |
| 212 std::string HttpServerPropertiesImpl::GetCanonicalSuffix( | 213 std::string HttpServerPropertiesImpl::GetCanonicalSuffix( |
| 213 const std::string& host) { | 214 const std::string& host) { |
| 214 // If this host ends with a canonical suffix, then return the canonical | 215 // If this host ends with a canonical suffix, then return the canonical |
| 215 // suffix. | 216 // suffix. |
| 216 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 217 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
| 217 std::string canonical_suffix = canonical_suffixes_[i]; | 218 std::string canonical_suffix = canonical_suffixes_[i]; |
| 218 if (EndsWith(host, canonical_suffixes_[i], false)) { | 219 if (base::EndsWith(host, canonical_suffixes_[i], |
| 220 base::CompareCase::SENSITIVE)) { |
| 219 return canonical_suffix; | 221 return canonical_suffix; |
| 220 } | 222 } |
| 221 } | 223 } |
| 222 return std::string(); | 224 return std::string(); |
| 223 } | 225 } |
| 224 | 226 |
| 225 AlternativeService HttpServerPropertiesImpl::GetAlternativeService( | 227 AlternativeService HttpServerPropertiesImpl::GetAlternativeService( |
| 226 const HostPortPair& origin) { | 228 const HostPortPair& origin) { |
| 227 AlternativeServiceMap::const_iterator it = | 229 AlternativeServiceMap::const_iterator it = |
| 228 alternative_service_map_.Get(origin); | 230 alternative_service_map_.Get(origin); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); | 299 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); |
| 298 } | 300 } |
| 299 } | 301 } |
| 300 | 302 |
| 301 alternative_service_map_.Put(origin, alternative_service_info); | 303 alternative_service_map_.Put(origin, alternative_service_info); |
| 302 | 304 |
| 303 // If this host ends with a canonical suffix, then set it as the | 305 // If this host ends with a canonical suffix, then set it as the |
| 304 // canonical host. | 306 // canonical host. |
| 305 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 307 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
| 306 std::string canonical_suffix = canonical_suffixes_[i]; | 308 std::string canonical_suffix = canonical_suffixes_[i]; |
| 307 if (EndsWith(origin.host(), canonical_suffixes_[i], false)) { | 309 if (base::EndsWith(origin.host(), canonical_suffixes_[i], |
| 310 base::CompareCase::SENSITIVE)) { |
| 308 HostPortPair canonical_host(canonical_suffix, origin.port()); | 311 HostPortPair canonical_host(canonical_suffix, origin.port()); |
| 309 canonical_host_to_origin_map_[canonical_host] = origin; | 312 canonical_host_to_origin_map_[canonical_host] = origin; |
| 310 break; | 313 break; |
| 311 } | 314 } |
| 312 } | 315 } |
| 313 } | 316 } |
| 314 | 317 |
| 315 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( | 318 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( |
| 316 const AlternativeService& alternative_service) { | 319 const AlternativeService& alternative_service) { |
| 317 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { | 320 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 541 } |
| 539 | 542 |
| 540 RemoveCanonicalHost(canonical_host_port); | 543 RemoveCanonicalHost(canonical_host_port); |
| 541 return alternative_service_map_.end(); | 544 return alternative_service_map_.end(); |
| 542 } | 545 } |
| 543 | 546 |
| 544 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator | 547 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator |
| 545 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const { | 548 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const { |
| 546 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 549 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
| 547 std::string canonical_suffix = canonical_suffixes_[i]; | 550 std::string canonical_suffix = canonical_suffixes_[i]; |
| 548 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { | 551 if (base::EndsWith(server.host(), canonical_suffixes_[i], |
| 552 base::CompareCase::SENSITIVE)) { |
| 549 HostPortPair canonical_host(canonical_suffix, server.port()); | 553 HostPortPair canonical_host(canonical_suffix, server.port()); |
| 550 return canonical_host_to_origin_map_.find(canonical_host); | 554 return canonical_host_to_origin_map_.find(canonical_host); |
| 551 } | 555 } |
| 552 } | 556 } |
| 553 | 557 |
| 554 return canonical_host_to_origin_map_.end(); | 558 return canonical_host_to_origin_map_.end(); |
| 555 } | 559 } |
| 556 | 560 |
| 557 void HttpServerPropertiesImpl::RemoveCanonicalHost( | 561 void HttpServerPropertiesImpl::RemoveCanonicalHost( |
| 558 const HostPortPair& server) { | 562 const HostPortPair& server) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 598 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 595 base::MessageLoop::current()->PostDelayedTask( | 599 base::MessageLoop::current()->PostDelayedTask( |
| 596 FROM_HERE, | 600 FROM_HERE, |
| 597 base::Bind( | 601 base::Bind( |
| 598 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 602 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 599 weak_ptr_factory_.GetWeakPtr()), | 603 weak_ptr_factory_.GetWeakPtr()), |
| 600 delay); | 604 delay); |
| 601 } | 605 } |
| 602 | 606 |
| 603 } // namespace net | 607 } // namespace net |
| OLD | NEW |