Chromium Code Reviews| Index: components/cronet/android/cronet_url_request_context_adapter.cc |
| diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc |
| index 5274d9e69b88fbfa28e1116a5cbc3956c95cf9df..1961958f48f50ddc001bc84677d9cdc134b59096 100644 |
| --- a/components/cronet/android/cronet_url_request_context_adapter.cc |
| +++ b/components/cronet/android/cronet_url_request_context_adapter.cc |
| @@ -38,6 +38,7 @@ |
| #include "components/cronet/android/cert/proto/cert_verification.pb.h" |
| #include "components/cronet/android/cronet_library_loader.h" |
| #include "components/cronet/histogram_manager.h" |
| +#include "components/cronet/host_cache_persistence_manager.h" |
| #include "components/cronet/url_request_context_config.h" |
| #include "components/prefs/pref_change_registrar.h" |
| #include "components/prefs/pref_filter.h" |
| @@ -114,6 +115,7 @@ class NetLogWithNetworkChangeEvents { |
| static base::LazyInstance<NetLogWithNetworkChangeEvents>::Leaky g_net_log = |
| LAZY_INSTANCE_INITIALIZER; |
| +const char kHostCache[] = "net.host_cache"; |
|
pauljensen
2017/06/26 16:37:17
Can we add a comment? and can we change name to in
mgersh
2017/06/26 23:21:44
Done, but the inconsistency bothered me so I chang
|
| const char kHttpServerProperties[] = "net.http_server_properties"; |
| const char kNetworkQualities[] = "net.network_qualities"; |
| // Current version of disk storage. |
| @@ -643,7 +645,7 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread( |
| std::unique_ptr<PrefFilter>()); |
| context_builder.SetFileTaskRunner(GetFileThread()->task_runner()); |
| - // Set up HttpServerPropertiesManager. |
| + // Register prefs and set up the PrefService. |
| PrefServiceFactory factory; |
| factory.set_user_prefs(json_pref_store_); |
| scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple()); |
| @@ -654,8 +656,12 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread( |
| registry->RegisterDictionaryPref(kNetworkQualities, |
| PrefRegistry::LOSSY_PREF); |
| } |
| + if (config->enable_host_cache_persistence) { |
| + registry->RegisterListPref(kHostCache); |
| + } |
| pref_service_ = factory.Create(registry.get()); |
| + // Set up the HttpServerPropertiesManager. |
| std::unique_ptr<net::HttpServerPropertiesManager> |
| http_server_properties_manager(new net::HttpServerPropertiesManager( |
| new PrefServiceAdapter(pref_service_.get()), |
| @@ -709,6 +715,17 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread( |
| context_ = context_builder.Build(); |
| + // Set up host cache persistence if it's enabled. Done after building the |
|
pauljensen
2017/06/26 16:37:17
nit: Done->Performed? "Done" can be confused with
mgersh
2017/06/26 23:21:44
Done. (And also performed.)
|
| + // URLRequestContext to get access to the HostCache. |
| + if (!config->storage_path.empty() && config->enable_host_cache_persistence) { |
|
pauljensen
2017/06/26 16:37:17
Can we change the storage_path check to a check fo
mgersh
2017/06/26 23:21:44
Done.
|
| + net::HostCache* host_cache = context_->host_resolver()->GetHostCache(); |
| + host_cache_persistence_manager_ = |
| + base::MakeUnique<HostCachePersistenceManager>( |
| + host_cache, pref_service_.get(), kHostCache, |
| + base::TimeDelta::FromMilliseconds( |
| + config->host_cache_persistence_timer)); |
| + } |
| + |
| context_->set_check_cleartext_permitted(true); |
| context_->set_enable_brotli(config->enable_brotli); |