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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 break; | 283 break; |
284 } | 284 } |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( | 288 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( |
289 const HostPortPair& server) { | 289 const HostPortPair& server) { |
290 AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server); | 290 AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server); |
291 if (it != alternate_protocol_map_.end()) { | 291 if (it != alternate_protocol_map_.end()) { |
292 it->second.protocol = ALTERNATE_PROTOCOL_BROKEN; | 292 it->second.protocol = ALTERNATE_PROTOCOL_BROKEN; |
293 return; | 293 } else { |
| 294 PortAlternateProtocolPair alternate; |
| 295 alternate.protocol = ALTERNATE_PROTOCOL_BROKEN; |
| 296 alternate_protocol_map_.Put(server, alternate); |
294 } | 297 } |
295 PortAlternateProtocolPair alternate; | |
296 alternate.protocol = ALTERNATE_PROTOCOL_BROKEN; | |
297 alternate_protocol_map_.Put(server, alternate); | |
298 | |
299 int count = ++broken_alternate_protocol_map_[server]; | 298 int count = ++broken_alternate_protocol_map_[server]; |
300 base::TimeDelta delay = | 299 base::TimeDelta delay = |
301 base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs); | 300 base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs); |
302 BrokenAlternateProtocolEntry entry; | 301 BrokenAlternateProtocolEntry entry; |
303 entry.server = server; | 302 entry.server = server; |
304 entry.when = base::TimeTicks::Now() + delay * (1 << (count - 1)); | 303 entry.when = base::TimeTicks::Now() + delay * (1 << (count - 1)); |
305 broken_alternate_protocol_list_.push_back(entry); | 304 broken_alternate_protocol_list_.push_back(entry); |
306 // If this is the only entry in the list, schedule an expiration task. | 305 // If this is the only entry in the list, schedule an expiration task. |
307 // Otherwse it will be rescheduled automatically when the pending | 306 // Otherwse it will be rescheduled automatically when the pending |
308 // task runs. | 307 // task runs. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 444 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
446 base::MessageLoop::current()->PostDelayedTask( | 445 base::MessageLoop::current()->PostDelayedTask( |
447 FROM_HERE, | 446 FROM_HERE, |
448 base::Bind( | 447 base::Bind( |
449 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 448 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
450 weak_ptr_factory_.GetWeakPtr()), | 449 weak_ptr_factory_.GetWeakPtr()), |
451 delay); | 450 delay); |
452 } | 451 } |
453 | 452 |
454 } // namespace net | 453 } // namespace net |
OLD | NEW |