| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { | 300 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { |
| 301 HostPortPair canonical_host(canonical_suffix, server.port()); | 301 HostPortPair canonical_host(canonical_suffix, server.port()); |
| 302 canonical_host_to_origin_map_[canonical_host] = server; | 302 canonical_host_to_origin_map_[canonical_host] = server; |
| 303 break; | 303 break; |
| 304 } | 304 } |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( | 308 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( |
| 309 const HostPortPair& server) { | 309 const HostPortPair& server) { |
| 310 AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server); | |
| 311 const AlternateProtocolInfo alternate = GetAlternateProtocol(server); | 310 const AlternateProtocolInfo alternate = GetAlternateProtocol(server); |
| 312 if (it == alternate_protocol_map_.end()) { | 311 if (alternate.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| 313 if (alternate.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { | 312 LOG(DFATAL) << "Trying to mark unknown alternate protocol broken."; |
| 314 LOG(DFATAL) << "Trying to mark unknown alternate protocol broken."; | 313 return; |
| 315 return; | |
| 316 } | |
| 317 // This server's alternate protocol information is coming from a canonical | |
| 318 // server. Add an entry in the map for this server explicitly so that | |
| 319 // it can be marked as broken. | |
| 320 it = alternate_protocol_map_.Put(server, alternate); | |
| 321 } | 314 } |
| 322 const AlternativeService alternative_service(alternate.protocol, | 315 const AlternativeService alternative_service(alternate.protocol, |
| 323 server.host(), alternate.port); | 316 server.host(), alternate.port); |
| 324 int count = ++recently_broken_alternative_services_[alternative_service]; | 317 int count = ++recently_broken_alternative_services_[alternative_service]; |
| 325 base::TimeDelta delay = | 318 base::TimeDelta delay = |
| 326 base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs); | 319 base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs); |
| 327 base::TimeTicks when = base::TimeTicks::Now() + delay * (1 << (count - 1)); | 320 base::TimeTicks when = base::TimeTicks::Now() + delay * (1 << (count - 1)); |
| 328 auto result = broken_alternative_services_.insert( | 321 auto result = broken_alternative_services_.insert( |
| 329 std::make_pair(alternative_service, when)); | 322 std::make_pair(alternative_service, when)); |
| 330 // Return if alternative service is already in expiration queue. | 323 // Return if alternative service is already in expiration queue. |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 555 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 563 base::MessageLoop::current()->PostDelayedTask( | 556 base::MessageLoop::current()->PostDelayedTask( |
| 564 FROM_HERE, | 557 FROM_HERE, |
| 565 base::Bind( | 558 base::Bind( |
| 566 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 559 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 567 weak_ptr_factory_.GetWeakPtr()), | 560 weak_ptr_factory_.GetWeakPtr()), |
| 568 delay); | 561 delay); |
| 569 } | 562 } |
| 570 | 563 |
| 571 } // namespace net | 564 } // namespace net |
| OLD | NEW |