| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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/broken_alternative_services.h" | 5 #include "net/http/broken_alternative_services.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/time/tick_clock.h" | 8 #include "base/time/tick_clock.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "net/http/http_server_properties_impl.h" | 10 #include "net/http/http_server_properties_impl.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 broken_alternative_service_list_.erase(map_it->second); | 107 broken_alternative_service_list_.erase(map_it->second); |
| 108 broken_alternative_service_map_.erase(map_it); | 108 broken_alternative_service_map_.erase(map_it); |
| 109 } | 109 } |
| 110 | 110 |
| 111 auto it = recently_broken_alternative_services_.Get(alternative_service); | 111 auto it = recently_broken_alternative_services_.Get(alternative_service); |
| 112 if (it != recently_broken_alternative_services_.end()) { | 112 if (it != recently_broken_alternative_services_.end()) { |
| 113 recently_broken_alternative_services_.Erase(it); | 113 recently_broken_alternative_services_.Erase(it); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 const BrokenAlternativeServiceList& | |
| 118 BrokenAlternativeServices::broken_alternative_service_list() const { | |
| 119 return broken_alternative_service_list_; | |
| 120 } | |
| 121 | |
| 122 const RecentlyBrokenAlternativeServices& | |
| 123 BrokenAlternativeServices::recently_broken_alternative_services() const { | |
| 124 return recently_broken_alternative_services_; | |
| 125 } | |
| 126 | |
| 127 void BrokenAlternativeServices::SetBrokenAndRecentlyBrokenAlternativeServices( | 117 void BrokenAlternativeServices::SetBrokenAndRecentlyBrokenAlternativeServices( |
| 128 std::unique_ptr<BrokenAlternativeServiceList> | 118 std::unique_ptr<BrokenAlternativeServiceList> |
| 129 broken_alternative_service_list, | 119 broken_alternative_service_list, |
| 130 std::unique_ptr<RecentlyBrokenAlternativeServices> | 120 std::unique_ptr<RecentlyBrokenAlternativeServices> |
| 131 recently_broken_alternative_services) { | 121 recently_broken_alternative_services) { |
| 132 DCHECK(broken_alternative_service_list); | 122 DCHECK(broken_alternative_service_list); |
| 133 DCHECK(recently_broken_alternative_services); | 123 DCHECK(recently_broken_alternative_services); |
| 134 | 124 |
| 135 // Make sure all alt svcs in |broken_alternative_service_list| has an entry | 125 // Make sure all alt svcs in |broken_alternative_service_list| has an entry |
| 136 // in |recently_broken_alternative_services| | 126 // in |recently_broken_alternative_services| |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 181 |
| 192 base::TimeTicks new_next_expiration = | 182 base::TimeTicks new_next_expiration = |
| 193 broken_alternative_service_list_.empty() | 183 broken_alternative_service_list_.empty() |
| 194 ? base::TimeTicks::Max() | 184 ? base::TimeTicks::Max() |
| 195 : broken_alternative_service_list_.front().second; | 185 : broken_alternative_service_list_.front().second; |
| 196 | 186 |
| 197 if (new_next_expiration != next_expiration) | 187 if (new_next_expiration != next_expiration) |
| 198 ScheduleBrokenAlternateProtocolMappingsExpiration(); | 188 ScheduleBrokenAlternateProtocolMappingsExpiration(); |
| 199 } | 189 } |
| 200 | 190 |
| 191 const BrokenAlternativeServiceList& |
| 192 BrokenAlternativeServices::broken_alternative_service_list() const { |
| 193 return broken_alternative_service_list_; |
| 194 } |
| 195 |
| 196 const RecentlyBrokenAlternativeServices& |
| 197 BrokenAlternativeServices::recently_broken_alternative_services() const { |
| 198 return recently_broken_alternative_services_; |
| 199 } |
| 200 |
| 201 bool BrokenAlternativeServices::AddToBrokenAlternativeServiceListAndMap( | 201 bool BrokenAlternativeServices::AddToBrokenAlternativeServiceListAndMap( |
| 202 const AlternativeService& alternative_service, | 202 const AlternativeService& alternative_service, |
| 203 base::TimeTicks expiration, | 203 base::TimeTicks expiration, |
| 204 BrokenAlternativeServiceList::iterator* it) { | 204 BrokenAlternativeServiceList::iterator* it) { |
| 205 DCHECK(it); | 205 DCHECK(it); |
| 206 | 206 |
| 207 auto map_it = broken_alternative_service_map_.find(alternative_service); | 207 auto map_it = broken_alternative_service_map_.find(alternative_service); |
| 208 if (map_it != broken_alternative_service_map_.end()) | 208 if (map_it != broken_alternative_service_map_.end()) |
| 209 return false; | 209 return false; |
| 210 | 210 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 256 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 257 expiration_timer_.Stop(); | 257 expiration_timer_.Stop(); |
| 258 expiration_timer_.Start( | 258 expiration_timer_.Start( |
| 259 FROM_HERE, delay, | 259 FROM_HERE, delay, |
| 260 base::Bind( | 260 base::Bind( |
| 261 &BrokenAlternativeServices ::ExpireBrokenAlternateProtocolMappings, | 261 &BrokenAlternativeServices ::ExpireBrokenAlternateProtocolMappings, |
| 262 weak_ptr_factory_.GetWeakPtr())); | 262 weak_ptr_factory_.GetWeakPtr())); |
| 263 } | 263 } |
| 264 | 264 |
| 265 } // namespace net | 265 } // namespace net |
| OLD | NEW |