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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return; | 49 return; |
50 // Add the entries from persisted data. | 50 // Add the entries from persisted data. |
51 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); | 51 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); |
52 it != spdy_servers->rend(); ++it) { | 52 it != spdy_servers->rend(); ++it) { |
53 spdy_servers_map_.Put(*it, support_spdy); | 53 spdy_servers_map_.Put(*it, support_spdy); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 void HttpServerPropertiesImpl::InitializeAlternativeServiceServers( | 57 void HttpServerPropertiesImpl::InitializeAlternativeServiceServers( |
58 AlternativeServiceMap* alternative_service_map) { | 58 AlternativeServiceMap* alternative_service_map) { |
| 59 AlternativeServiceMap new_alternative_service_map( |
| 60 AlternativeServiceMap::NO_AUTO_EVICT); |
59 // Add the entries from persisted data. | 61 // Add the entries from persisted data. |
60 for (AlternativeServiceMap::reverse_iterator input_it = | 62 for (AlternativeServiceMap::reverse_iterator input_it = |
61 alternative_service_map->rbegin(); | 63 alternative_service_map->rbegin(); |
62 input_it != alternative_service_map->rend(); ++input_it) { | 64 input_it != alternative_service_map->rend(); ++input_it) { |
63 DCHECK(!input_it->second.empty()); | 65 DCHECK(!input_it->second.empty()); |
64 alternative_service_map_.Put(input_it->first, input_it->second); | 66 new_alternative_service_map.Put(input_it->first, input_it->second); |
| 67 } |
| 68 |
| 69 alternative_service_map_.Swap(new_alternative_service_map); |
| 70 |
| 71 // Add the entries from the memory cache. |
| 72 for (AlternativeServiceMap::reverse_iterator input_it = |
| 73 new_alternative_service_map.rbegin(); |
| 74 input_it != new_alternative_service_map.rend(); ++input_it) { |
| 75 if (alternative_service_map_.Get(input_it->first) == |
| 76 alternative_service_map_.end()) { |
| 77 alternative_service_map_.Put(input_it->first, input_it->second); |
| 78 } |
65 } | 79 } |
66 | 80 |
67 // Attempt to find canonical servers. | 81 // Attempt to find canonical servers. |
68 uint16 canonical_ports[] = { 80, 443 }; | 82 uint16 canonical_ports[] = { 80, 443 }; |
69 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 83 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
70 std::string canonical_suffix = canonical_suffixes_[i]; | 84 std::string canonical_suffix = canonical_suffixes_[i]; |
71 for (size_t j = 0; j < arraysize(canonical_ports); ++j) { | 85 for (size_t j = 0; j < arraysize(canonical_ports); ++j) { |
72 HostPortPair canonical_host(canonical_suffix, canonical_ports[j]); | 86 HostPortPair canonical_host(canonical_suffix, canonical_ports[j]); |
73 // If we already have a valid canonical server, we're done. | 87 // If we already have a valid canonical server, we're done. |
74 if (ContainsKey(canonical_host_to_origin_map_, canonical_host) && | 88 if (ContainsKey(canonical_host_to_origin_map_, canonical_host) && |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 732 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
719 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 733 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
720 FROM_HERE, | 734 FROM_HERE, |
721 base::Bind( | 735 base::Bind( |
722 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 736 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
723 weak_ptr_factory_.GetWeakPtr()), | 737 weak_ptr_factory_.GetWeakPtr()), |
724 delay); | 738 delay); |
725 } | 739 } |
726 | 740 |
727 } // namespace net | 741 } // namespace net |
OLD | NEW |