Chromium Code Reviews

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

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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/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 49 matching lines...)
60 } 60 }
61 61
62 // Add the entries from persisted data. 62 // Add the entries from persisted data.
63 for (AlternateProtocolMap::reverse_iterator it = 63 for (AlternateProtocolMap::reverse_iterator it =
64 alternate_protocol_map->rbegin(); 64 alternate_protocol_map->rbegin();
65 it != alternate_protocol_map->rend(); ++it) { 65 it != alternate_protocol_map->rend(); ++it) {
66 alternate_protocol_map_.Put(it->first, it->second); 66 alternate_protocol_map_.Put(it->first, it->second);
67 } 67 }
68 68
69 // Attempt to find canonical servers. 69 // Attempt to find canonical servers.
70 int canonical_ports[] = { 80, 443 }; 70 uint16 canonical_ports[] = { 80, 443 };
71 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 71 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
72 std::string canonical_suffix = canonical_suffixes_[i]; 72 std::string canonical_suffix = canonical_suffixes_[i];
73 for (size_t j = 0; j < arraysize(canonical_ports); ++j) { 73 for (size_t j = 0; j < arraysize(canonical_ports); ++j) {
74 HostPortPair canonical_host(canonical_suffix, canonical_ports[j]); 74 HostPortPair canonical_host(canonical_suffix, canonical_ports[j]);
75 // If we already have a valid canonical server, we're done. 75 // If we already have a valid canonical server, we're done.
76 if (ContainsKey(canonical_host_to_origin_map_, canonical_host) && 76 if (ContainsKey(canonical_host_to_origin_map_, canonical_host) &&
77 (alternate_protocol_map_.Peek(canonical_host_to_origin_map_[ 77 (alternate_protocol_map_.Peek(canonical_host_to_origin_map_[
78 canonical_host]) != alternate_protocol_map_.end())) { 78 canonical_host]) != alternate_protocol_map_.end())) {
79 continue; 79 continue;
80 } 80 }
(...skipping 213 matching lines...)
294 canonical_host_to_origin_map_[canonical_host] = server; 294 canonical_host_to_origin_map_[canonical_host] = server;
295 break; 295 break;
296 } 296 }
297 } 297 }
298 } 298 }
299 299
300 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( 300 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol(
301 const HostPortPair& server) { 301 const HostPortPair& server) {
302 AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server); 302 AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server);
303 if (it == alternate_protocol_map_.end()) { 303 if (it == alternate_protocol_map_.end()) {
304 LOG(DFATAL) << "Trying to mark unknown alternate protocol broken."; 304 if (!HasAlternateProtocol(server)) {
305 return; 305 LOG(DFATAL) << "Trying to mark unknown alternate protocol broken.";
306 return;
307 }
308 // This server's alternate protocol information is coming from a canonical
309 // server. Add an entry in the map for this server explicitly so that
310 // it can be marked as broken.
311 it = alternate_protocol_map_.Put(server, GetAlternateProtocol(server));
306 } 312 }
307 it->second.is_broken = true; 313 it->second.is_broken = true;
308 int count = ++broken_alternate_protocol_map_[server]; 314 int count = ++broken_alternate_protocol_map_[server];
309 base::TimeDelta delay = 315 base::TimeDelta delay =
310 base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs); 316 base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs);
311 BrokenAlternateProtocolEntry entry; 317 BrokenAlternateProtocolEntry entry;
312 entry.server = server; 318 entry.server = server;
313 entry.when = base::TimeTicks::Now() + delay * (1 << (count - 1)); 319 entry.when = base::TimeTicks::Now() + delay * (1 << (count - 1));
314 broken_alternate_protocol_list_.push_back(entry); 320 broken_alternate_protocol_list_.push_back(entry);
315 321
(...skipping 175 matching lines...)
491 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 497 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
492 base::MessageLoop::current()->PostDelayedTask( 498 base::MessageLoop::current()->PostDelayedTask(
493 FROM_HERE, 499 FROM_HERE,
494 base::Bind( 500 base::Bind(
495 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 501 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
496 weak_ptr_factory_.GetWeakPtr()), 502 weak_ptr_factory_.GetWeakPtr()),
497 delay); 503 delay);
498 } 504 }
499 505
500 } // namespace net 506 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool_unittest.cc ('k') | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine