| 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_macros.h" | 8 #include "base/metrics/histogram_macros.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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 399 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 400 return http_server_properties_impl_->GetQuicServerInfo(server_id); | 400 return http_server_properties_impl_->GetQuicServerInfo(server_id); |
| 401 } | 401 } |
| 402 | 402 |
| 403 const QuicServerInfoMap& HttpServerPropertiesManager::quic_server_info_map() | 403 const QuicServerInfoMap& HttpServerPropertiesManager::quic_server_info_map() |
| 404 const { | 404 const { |
| 405 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 405 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 406 return http_server_properties_impl_->quic_server_info_map(); | 406 return http_server_properties_impl_->quic_server_info_map(); |
| 407 } | 407 } |
| 408 | 408 |
| 409 size_t HttpServerPropertiesManager::max_server_configs_stored_in_properties() |
| 410 const { |
| 411 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 412 return http_server_properties_impl_ |
| 413 ->max_server_configs_stored_in_properties(); |
| 414 } |
| 415 |
| 416 void HttpServerPropertiesManager::SetMaxServerConfigsStoredInProperties( |
| 417 size_t max_server_configs_stored_in_properties) { |
| 418 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 419 return http_server_properties_impl_->SetMaxServerConfigsStoredInProperties( |
| 420 max_server_configs_stored_in_properties); |
| 421 } |
| 422 |
| 409 // | 423 // |
| 410 // Update the HttpServerPropertiesImpl's cache with data from preferences. | 424 // Update the HttpServerPropertiesImpl's cache with data from preferences. |
| 411 // | 425 // |
| 412 void HttpServerPropertiesManager::ScheduleUpdateCacheOnPrefThread() { | 426 void HttpServerPropertiesManager::ScheduleUpdateCacheOnPrefThread() { |
| 413 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 427 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
| 414 // Cancel pending updates, if any. | 428 // Cancel pending updates, if any. |
| 415 pref_cache_update_timer_->Stop(); | 429 pref_cache_update_timer_->Stop(); |
| 416 StartCacheUpdateTimerOnPrefThread( | 430 StartCacheUpdateTimerOnPrefThread( |
| 417 base::TimeDelta::FromMilliseconds(kUpdateCacheDelayMs)); | 431 base::TimeDelta::FromMilliseconds(kUpdateCacheDelayMs)); |
| 418 } | 432 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 504 |
| 491 // String is host/port pair of spdy server. | 505 // String is host/port pair of spdy server. |
| 492 scoped_ptr<ServerList> spdy_servers(new ServerList); | 506 scoped_ptr<ServerList> spdy_servers(new ServerList); |
| 493 scoped_ptr<SpdySettingsMap> spdy_settings_map( | 507 scoped_ptr<SpdySettingsMap> spdy_settings_map( |
| 494 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); | 508 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); |
| 495 scoped_ptr<AlternativeServiceMap> alternative_service_map( | 509 scoped_ptr<AlternativeServiceMap> alternative_service_map( |
| 496 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist)); | 510 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist)); |
| 497 scoped_ptr<ServerNetworkStatsMap> server_network_stats_map( | 511 scoped_ptr<ServerNetworkStatsMap> server_network_stats_map( |
| 498 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist)); | 512 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist)); |
| 499 scoped_ptr<QuicServerInfoMap> quic_server_info_map( | 513 scoped_ptr<QuicServerInfoMap> quic_server_info_map( |
| 500 new QuicServerInfoMap(kMaxQuicServersToPersist)); | 514 new QuicServerInfoMap(QuicServerInfoMap::NO_AUTO_EVICT)); |
| 501 | 515 |
| 502 if (version < 4) { | 516 if (version < 4) { |
| 503 if (!AddServersData(*servers_dict, spdy_servers.get(), | 517 if (!AddServersData(*servers_dict, spdy_servers.get(), |
| 504 spdy_settings_map.get(), alternative_service_map.get(), | 518 spdy_settings_map.get(), alternative_service_map.get(), |
| 505 server_network_stats_map.get())) { | 519 server_network_stats_map.get())) { |
| 506 detected_corrupted_prefs = true; | 520 detected_corrupted_prefs = true; |
| 507 } | 521 } |
| 508 } else { | 522 } else { |
| 509 for (base::ListValue::const_iterator it = servers_list->begin(); | 523 for (base::ListValue::const_iterator it = servers_list->begin(); |
| 510 it != servers_list->end(); ++it) { | 524 it != servers_list->end(); ++it) { |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 it != network_stats_map.rend() && | 987 it != network_stats_map.rend() && |
| 974 count < kMaxServerNetworkStatsHostsToPersist; | 988 count < kMaxServerNetworkStatsHostsToPersist; |
| 975 ++it, ++count) { | 989 ++it, ++count) { |
| 976 server_network_stats_map->Put(it->first, it->second); | 990 server_network_stats_map->Put(it->first, it->second); |
| 977 } | 991 } |
| 978 | 992 |
| 979 QuicServerInfoMap* quic_server_info_map = nullptr; | 993 QuicServerInfoMap* quic_server_info_map = nullptr; |
| 980 const QuicServerInfoMap& main_quic_server_info_map = | 994 const QuicServerInfoMap& main_quic_server_info_map = |
| 981 http_server_properties_impl_->quic_server_info_map(); | 995 http_server_properties_impl_->quic_server_info_map(); |
| 982 if (main_quic_server_info_map.size() > 0) { | 996 if (main_quic_server_info_map.size() > 0) { |
| 983 quic_server_info_map = new QuicServerInfoMap(kMaxQuicServersToPersist); | 997 quic_server_info_map = |
| 998 new QuicServerInfoMap(max_server_configs_stored_in_properties()); |
| 984 for (const std::pair<const QuicServerId, std::string>& entry : | 999 for (const std::pair<const QuicServerId, std::string>& entry : |
| 985 main_quic_server_info_map) { | 1000 main_quic_server_info_map) { |
| 986 quic_server_info_map->Put(entry.first, entry.second); | 1001 quic_server_info_map->Put(entry.first, entry.second); |
| 987 } | 1002 } |
| 988 } | 1003 } |
| 989 | 1004 |
| 990 IPAddressNumber* last_quic_addr = new IPAddressNumber; | 1005 IPAddressNumber* last_quic_addr = new IPAddressNumber; |
| 991 http_server_properties_impl_->GetSupportsQuic(last_quic_addr); | 1006 http_server_properties_impl_->GetSupportsQuic(last_quic_addr); |
| 992 // Update the preferences on the pref thread. | 1007 // Update the preferences on the pref thread. |
| 993 pref_task_runner_->PostTask( | 1008 pref_task_runner_->PostTask( |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 quic_servers_dict); | 1265 quic_servers_dict); |
| 1251 } | 1266 } |
| 1252 | 1267 |
| 1253 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 1268 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
| 1254 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 1269 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
| 1255 if (!setting_prefs_) | 1270 if (!setting_prefs_) |
| 1256 ScheduleUpdateCacheOnPrefThread(); | 1271 ScheduleUpdateCacheOnPrefThread(); |
| 1257 } | 1272 } |
| 1258 | 1273 |
| 1259 } // namespace net | 1274 } // namespace net |
| OLD | NEW |