Chromium Code Reviews| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 | 275 |
| 276 void HttpServerPropertiesImpl::SetAlternateProtocol( | 276 void HttpServerPropertiesImpl::SetAlternateProtocol( |
| 277 const HostPortPair& server, | 277 const HostPortPair& server, |
| 278 uint16 alternate_port, | 278 uint16 alternate_port, |
| 279 AlternateProtocol alternate_protocol, | 279 AlternateProtocol alternate_protocol, |
| 280 double alternate_probability) { | 280 double alternate_probability) { |
| 281 | 281 |
| 282 AlternateProtocolInfo alternate(alternate_port, | 282 AlternateProtocolInfo alternate(alternate_port, |
| 283 alternate_protocol, | 283 alternate_protocol, |
| 284 alternate_probability); | 284 alternate_probability); |
| 285 if (HasAlternateProtocol(server)) { | 285 // Do not call HasAlternateProtocol(), because we do not care about |
| 286 const AlternateProtocolInfo existing_alternate = | 286 // |g_forced_alternate_protocol|, or whether the alternate protocol |
| 287 GetAlternateProtocol(server); | 287 // probability is higher than the threshold. |
| 288 AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server); | |
| 289 if (it == alternate_protocol_map_.end()) { | |
| 290 const CanonicalHostMap::const_iterator canonical_host = | |
| 291 GetCanonicalHost(server); | |
| 292 if (canonical_host != canonical_host_to_origin_map_.end()) { | |
| 293 it = alternate_protocol_map_.Get(canonical_host->second); | |
| 294 } | |
| 295 } | |
|
Ryan Hamilton
2015/01/16 22:42:45
This looks like a good change. I wonder if this sh
Bence
2015/01/23 16:45:58
Done.
| |
| 296 if (it != alternate_protocol_map_.end()) { | |
| 297 const AlternateProtocolInfo existing_alternate = it->second; | |
| 288 | 298 |
| 289 if (existing_alternate.is_broken) { | 299 if (existing_alternate.is_broken) { |
| 290 DVLOG(1) << "Ignore alternate protocol since it's known to be broken."; | 300 DVLOG(1) << "Ignore alternate protocol since it's known to be broken."; |
| 291 return; | 301 return; |
| 292 } | 302 } |
| 293 | 303 |
| 294 if (!existing_alternate.Equals(alternate)) { | 304 if (!existing_alternate.Equals(alternate)) { |
| 295 LOG(WARNING) << "Changing the alternate protocol for: " | 305 LOG(WARNING) << "Changing the alternate protocol for: " |
| 296 << server.ToString() | 306 << server.ToString() |
| 297 << " from [Port: " << existing_alternate.port | 307 << " from [Port: " << existing_alternate.port |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 538 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 529 base::MessageLoop::current()->PostDelayedTask( | 539 base::MessageLoop::current()->PostDelayedTask( |
| 530 FROM_HERE, | 540 FROM_HERE, |
| 531 base::Bind( | 541 base::Bind( |
| 532 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 542 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 533 weak_ptr_factory_.GetWeakPtr()), | 543 weak_ptr_factory_.GetWeakPtr()), |
| 534 delay); | 544 delay); |
| 535 } | 545 } |
| 536 | 546 |
| 537 } // namespace net | 547 } // namespace net |
| OLD | NEW |