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 2f736a9dc1c3161d501ad938a1c01dbe468e7cf1..d163ff4d8d2ca5459ae200d3e68d8064ade3e908 100644 |
| --- a/components/cronet/android/cronet_url_request_context_adapter.cc |
| +++ b/components/cronet/android/cronet_url_request_context_adapter.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/files/scoped_file.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_vector.h" |
| +#include "base/prefs/pref_filter.h" |
| #include "base/single_thread_task_runner.h" |
| #include "base/values.h" |
| #include "components/cronet/url_request_context_config.h" |
| @@ -185,6 +186,21 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread( |
| context_builder.set_net_log(net_log.release()); |
| context_builder.set_proxy_config_service(proxy_config_service_.release()); |
| config->ConfigureURLRequestContextBuilder(&context_builder); |
| + |
| + // Set up pref file if storage path is specified. |
| + if (!config->storage_path.empty()) { |
|
mmenke
2015/05/26 19:34:40
Suggest checking if sdch is enabled...Could get ug
xunjieli
2015/05/26 20:28:28
Done. I know HttpServerProperties will use the sam
mmenke
2015/05/27 14:40:43
That was a type...my == many (For some reason, a d
mmenke
2015/05/27 14:41:31
type == typo (Case in point...)
|
| + base::FilePath filepath(config->storage_path); |
| + filepath = filepath.Append(FILE_PATH_LITERAL("local_prefs.json")); |
| + if (!file_thread_) { |
|
mmenke
2015/05/26 19:34:40
Suggest a method GetFileThread, which creates it i
xunjieli
2015/05/26 20:28:28
Done.
|
| + file_thread_.reset(new base::Thread("Network File Thread")); |
| + file_thread_->Start(); |
| + } |
| + json_pref_store_ = new JsonPrefStore(filepath, file_thread_->task_runner(), |
| + scoped_ptr<PrefFilter>()); |
| + json_pref_store_->ReadPrefsAsync(nullptr); |
| + context_builder.SetFileTaskRunner(file_thread_->task_runner()); |
| + } |
| + |
| context_.reset(context_builder.Build()); |
| default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES | |
| @@ -196,6 +212,8 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread( |
| DCHECK(context_->sdch_manager()); |
| sdch_owner_.reset( |
| new net::SdchOwner(context_->sdch_manager(), context_.get())); |
| + if (json_pref_store_) |
| + sdch_owner_->EnablePersistentStorage(json_pref_store_.get()); |
| } |
| // Currently (circa M39) enabling QUIC requires setting probability threshold. |