Chromium Code Reviews| Index: chrome/browser/profiles/profile_impl_io_data.cc |
| diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc |
| index e2cb0ec4ef3e10a0c01acdce32227b3e2d5591a7..835f8f88fdfb9a7a235b327f587e03fe4910e71a 100644 |
| --- a/chrome/browser/profiles/profile_impl_io_data.cc |
| +++ b/chrome/browser/profiles/profile_impl_io_data.cc |
| @@ -4,11 +4,15 @@ |
| #include "chrome/browser/profiles/profile_impl_io_data.h" |
| +#include <set> |
| + |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/metrics/field_trial.h" |
| +#include "base/prefs/json_pref_store.h" |
| +#include "base/prefs/pref_filter.h" |
| #include "base/prefs/pref_member.h" |
| #include "base/prefs/pref_service.h" |
| #include "base/profiler/scoped_tracker.h" |
| @@ -90,6 +94,20 @@ net::BackendType ChooseCacheBackendType() { |
| #endif |
| } |
| +bool ShouldUseSdchPersistence() { |
| + const std::string group = |
| + base::FieldTrialList::FindFullName("SdchPersistence"); |
|
gab
2015/03/04 16:46:14
nit: This is not needed until after you've handled
|
| + const base::CommandLine* command_line = |
| + base::CommandLine::ForCurrentProcess(); |
| + if (command_line->HasSwitch(switches::kEnableSdchPersistence)) { |
| + return true; |
| + } |
| + if (command_line->HasSwitch(switches::kDisableSdchPersistence)) { |
| + return false; |
| + } |
|
gab
2015/03/04 16:46:14
nit: Can remove {} for one-line ifs.
|
| + return group == "Enabled"; |
| +} |
| + |
| } // namespace |
| using content::BrowserThread; |
| @@ -424,6 +442,16 @@ void ProfileImplIOData::InitializeInternal( |
| FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| "436671 ProfileImplIOData::InitializeInternal")); |
| + // Set up a persistent store for use by the network stack on the IO thread. |
| + base::FilePath network_json_store_filepath( |
| + profile_path_.Append(chrome::kNetworkPersistentStateFilename)); |
| + network_json_store_ = new JsonPrefStore( |
| + network_json_store_filepath, |
| + JsonPrefStore::GetTaskRunnerForFile(network_json_store_filepath, |
| + BrowserThread::GetBlockingPool()), |
| + scoped_ptr<PrefFilter>()); |
| + network_json_store_->ReadPrefsAsync(nullptr); |
| + |
| net::URLRequestContext* main_context = main_request_context(); |
| IOThread* const io_thread = profile_params->io_thread; |
| @@ -612,6 +640,9 @@ void ProfileImplIOData::InitializeInternal( |
| sdch_manager_.reset(new net::SdchManager); |
| sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context)); |
| main_context->set_sdch_manager(sdch_manager_.get()); |
| + if (ShouldUseSdchPersistence()) { |
| + sdch_policy_->EnablePersistentStorage(network_json_store_.get()); |
| + } |
|
gab
2015/03/04 16:46:14
nit: Remove {}
|
| // Create a media request context based on the main context, but using a |
| // media cache. It shares the same job factory as the main context. |