| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_manager.h" | 5 #include "net/http/http_server_properties_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 alternative_service); | 258 alternative_service); |
| 259 http_server_properties_impl_->ConfirmAlternativeService(alternative_service); | 259 http_server_properties_impl_->ConfirmAlternativeService(alternative_service); |
| 260 bool new_value = http_server_properties_impl_->IsAlternativeServiceBroken( | 260 bool new_value = http_server_properties_impl_->IsAlternativeServiceBroken( |
| 261 alternative_service); | 261 alternative_service); |
| 262 // For persisting, we only care about the value returned by | 262 // For persisting, we only care about the value returned by |
| 263 // IsAlternativeServiceBroken. If that value changes, then call persist. | 263 // IsAlternativeServiceBroken. If that value changes, then call persist. |
| 264 if (old_value != new_value) | 264 if (old_value != new_value) |
| 265 ScheduleUpdatePrefsOnNetworkThread(CONFIRM_ALTERNATIVE_SERVICE); | 265 ScheduleUpdatePrefsOnNetworkThread(CONFIRM_ALTERNATIVE_SERVICE); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void HttpServerPropertiesManager::ClearAlternativeServices( | |
| 269 const url::SchemeHostPort& origin) { | |
| 270 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | |
| 271 const AlternativeServiceMap& map = | |
| 272 http_server_properties_impl_->alternative_service_map(); | |
| 273 size_t old_size = map.size(); | |
| 274 http_server_properties_impl_->ClearAlternativeServices(origin); | |
| 275 size_t new_size = map.size(); | |
| 276 // Persist only if we have deleted an entry. | |
| 277 if (old_size != new_size) | |
| 278 ScheduleUpdatePrefsOnNetworkThread(CLEAR_ALTERNATIVE_SERVICE); | |
| 279 } | |
| 280 | |
| 281 const AlternativeServiceMap& | 268 const AlternativeServiceMap& |
| 282 HttpServerPropertiesManager::alternative_service_map() const { | 269 HttpServerPropertiesManager::alternative_service_map() const { |
| 283 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 270 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 284 return http_server_properties_impl_->alternative_service_map(); | 271 return http_server_properties_impl_->alternative_service_map(); |
| 285 } | 272 } |
| 286 | 273 |
| 287 std::unique_ptr<base::Value> | 274 std::unique_ptr<base::Value> |
| 288 HttpServerPropertiesManager::GetAlternativeServiceInfoAsValue() const { | 275 HttpServerPropertiesManager::GetAlternativeServiceInfoAsValue() const { |
| 289 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 276 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 290 return http_server_properties_impl_->GetAlternativeServiceInfoAsValue(); | 277 return http_server_properties_impl_->GetAlternativeServiceInfoAsValue(); |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 quic_servers_dict); | 1252 quic_servers_dict); |
| 1266 } | 1253 } |
| 1267 | 1254 |
| 1268 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 1255 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
| 1269 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 1256 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
| 1270 if (!setting_prefs_) | 1257 if (!setting_prefs_) |
| 1271 ScheduleUpdateCacheOnPrefThread(); | 1258 ScheduleUpdateCacheOnPrefThread(); |
| 1272 } | 1259 } |
| 1273 | 1260 |
| 1274 } // namespace net | 1261 } // namespace net |
| OLD | NEW |