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 7cab0d9e281c190994deaa35c41974a1acb13c9f..5f94571e82ac1266cff128e2ff863254a30e6641 100644 |
| --- a/components/cronet/android/cronet_url_request_context_adapter.cc |
| +++ b/components/cronet/android/cronet_url_request_context_adapter.cc |
| @@ -11,8 +11,13 @@ |
| #include "base/files/scoped_file.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_vector.h" |
| +#include "base/message_loop/message_loop.h" |
|
xunjieli
2015/06/24 20:38:02
Added this include because this file uses base::Me
|
| #include "base/prefs/pref_filter.h" |
| +#include "base/prefs/pref_registry_simple.h" |
| +#include "base/prefs/pref_service.h" |
| +#include "base/prefs/pref_service_factory.h" |
| #include "base/single_thread_task_runner.h" |
| +#include "base/thread_task_runner_handle.h" |
| #include "base/values.h" |
| #include "components/cronet/url_request_context_config.h" |
| #include "jni/CronetUrlRequestContext_jni.h" |
| @@ -20,6 +25,7 @@ |
| #include "net/base/net_errors.h" |
| #include "net/base/network_delegate_impl.h" |
| #include "net/http/http_auth_handler_factory.h" |
| +#include "net/http/http_server_properties_manager.h" |
| #include "net/log/write_to_file_net_log_observer.h" |
| #include "net/proxy/proxy_service.h" |
| #include "net/sdch/sdch_owner.h" |
| @@ -33,6 +39,8 @@ |
| namespace { |
| +const char kHttpServerProperties[] = "net.http_server_properties"; |
| + |
| class BasicNetworkDelegate : public net::NetworkDelegateImpl { |
| public: |
| BasicNetworkDelegate() {} |
| @@ -188,14 +196,27 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread( |
| config->ConfigureURLRequestContextBuilder(&context_builder); |
| // Set up pref file if storage path is specified. |
| - // TODO(xunjieli): maybe get rid of the condition on sdch. |
| - if (!config->storage_path.empty() && config->enable_sdch) { |
| + if (!config->storage_path.empty()) { |
| base::FilePath filepath(config->storage_path); |
| filepath = filepath.Append(FILE_PATH_LITERAL("local_prefs.json")); |
| json_pref_store_ = new JsonPrefStore( |
| filepath, GetFileThread()->task_runner(), scoped_ptr<PrefFilter>()); |
| - json_pref_store_->ReadPrefsAsync(nullptr); |
| context_builder.SetFileTaskRunner(GetFileThread()->task_runner()); |
| + |
| + // Set up HttpServerPropertiesManager. |
| + base::PrefServiceFactory factory; |
| + factory.set_user_prefs(json_pref_store_); |
| + scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
| + registry->RegisterDictionaryPref(kHttpServerProperties, |
| + new base::DictionaryValue()); |
| + pref_service_ = factory.Create(registry.get()).Pass(); |
| + |
| + http_server_properties_manager_.reset(new net::HttpServerPropertiesManager( |
| + pref_service_.get(), kHttpServerProperties, |
| + base::ThreadTaskRunnerHandle::Get())); |
| + http_server_properties_manager_->InitializeOnNetworkThread(); |
| + context_builder.SetHttpServerPropertiesManager( |
| + http_server_properties_manager_.Pass()); |
| } |
| context_.reset(context_builder.Build()); |