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