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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 const IPAddressNumber& address) { | 331 const IPAddressNumber& address) { |
332 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 332 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
333 http_server_properties_impl_->SetSupportsQuic(used_quic, address); | 333 http_server_properties_impl_->SetSupportsQuic(used_quic, address); |
334 ScheduleUpdatePrefsOnNetworkThread(SET_SUPPORTS_QUIC); | 334 ScheduleUpdatePrefsOnNetworkThread(SET_SUPPORTS_QUIC); |
335 } | 335 } |
336 | 336 |
337 void HttpServerPropertiesManager::SetServerNetworkStats( | 337 void HttpServerPropertiesManager::SetServerNetworkStats( |
338 const HostPortPair& host_port_pair, | 338 const HostPortPair& host_port_pair, |
339 ServerNetworkStats stats) { | 339 ServerNetworkStats stats) { |
340 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 340 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 341 ServerNetworkStats old_stats; |
| 342 const ServerNetworkStats* old_stats_ptr = |
| 343 http_server_properties_impl_->GetServerNetworkStats(host_port_pair); |
| 344 if (http_server_properties_impl_->GetServerNetworkStats(host_port_pair)) |
| 345 old_stats = *old_stats_ptr; |
341 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); | 346 http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats); |
342 ScheduleUpdatePrefsOnNetworkThread(SET_SERVER_NETWORK_STATS); | 347 ServerNetworkStats new_stats = |
| 348 *(http_server_properties_impl_->GetServerNetworkStats(host_port_pair)); |
| 349 if (old_stats != new_stats) |
| 350 ScheduleUpdatePrefsOnNetworkThread(SET_SERVER_NETWORK_STATS); |
343 } | 351 } |
344 | 352 |
345 const ServerNetworkStats* HttpServerPropertiesManager::GetServerNetworkStats( | 353 const ServerNetworkStats* HttpServerPropertiesManager::GetServerNetworkStats( |
346 const HostPortPair& host_port_pair) { | 354 const HostPortPair& host_port_pair) { |
347 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 355 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
348 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); | 356 return http_server_properties_impl_->GetServerNetworkStats(host_port_pair); |
349 } | 357 } |
350 | 358 |
351 const ServerNetworkStatsMap& | 359 const ServerNetworkStatsMap& |
352 HttpServerPropertiesManager::server_network_stats_map() const { | 360 HttpServerPropertiesManager::server_network_stats_map() const { |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 server_network_stats_dict); | 979 server_network_stats_dict); |
972 } | 980 } |
973 | 981 |
974 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 982 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
975 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 983 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
976 if (!setting_prefs_) | 984 if (!setting_prefs_) |
977 ScheduleUpdateCacheOnPrefThread(); | 985 ScheduleUpdateCacheOnPrefThread(); |
978 } | 986 } |
979 | 987 |
980 } // namespace net | 988 } // namespace net |
OLD | NEW |