Chromium Code Reviews| Index: chrome/browser/profiles/profile_impl.cc |
| diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc |
| index 3449c31c9b4a2de4de7281e2bce8a118b1bf54c9..26c7c97257bcc0f3f76893f334952b70aede81e8 100644 |
| --- a/chrome/browser/profiles/profile_impl.cc |
| +++ b/chrome/browser/profiles/profile_impl.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/environment.h" |
| #include "base/file_util.h" |
| #include "base/files/file_path.h" |
| +#include "base/json/json_file_value_serializer.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/path_service.h" |
| #include "base/prefs/json_pref_store.h" |
| @@ -419,7 +420,7 @@ void ProfileImpl::InitializePrefHashStoreIfRequired( |
| const base::FilePath& profile_path) { |
| scoped_ptr<PrefHashStoreImpl> pref_hash_store(GetPrefHashStore(profile_path)); |
| if (pref_hash_store && !pref_hash_store->IsInitialized()) { |
| - chrome_prefs::InitializeHashStoreForPrefFile( |
| + chrome_prefs::InitializeHashStoreFromPrefFile( |
| GetPrefFilePathFromProfilePath(profile_path), |
| JsonPrefStore::GetTaskRunnerForFile( |
| profile_path, BrowserThread::GetBlockingPool()), |
| @@ -432,6 +433,35 @@ void ProfileImpl::ResetPrefHashStore(const base::FilePath& profile_path) { |
| GetPrefHashStore(profile_path)->Reset(); |
| } |
| +// static |
| +bool ProfileImpl::InitializePrefsFromMasterPrefs( |
|
noms (inactive)
2014/02/04 20:36:35
As discussed offline, these prefs related methods
|
| + const base::FilePath& profile_path, |
| + const base::DictionaryValue& master_prefs) { |
| + // Create the profile directory if it doesn't exist yet (very possible on |
| + // first run). |
| + if (!base::CreateDirectory(profile_path)) |
| + return false; |
| + |
| + JSONFileValueSerializer serializer( |
| + GetPrefFilePathFromProfilePath(profile_path)); |
| + |
| + // Call Serialize (which does IO) on the main thread, which would _normally_ |
| + // be verboten. In this case however, we require this IO to synchronously |
| + // complete before Chrome can start (as master preferences seed the Local |
| + // State and Preferences files). This won't trip ThreadIORestrictions as they |
| + // won't have kicked in yet on the main thread. |
| + bool success = serializer.Serialize(master_prefs); |
| + |
| + if (success) { |
| + scoped_ptr<PrefHashStore> pref_hash_store(GetPrefHashStore(profile_path)); |
| + chrome_prefs::InitializeHashStoreFromMasterPrefs(master_prefs, |
| + pref_hash_store.Pass()); |
| + } |
| + |
| + UMA_HISTOGRAM_BOOLEAN("Settings.InitializedFromMasterPrefs", success); |
| + return success; |
| +} |
| + |
| ProfileImpl::ProfileImpl( |
| const base::FilePath& path, |
| Delegate* delegate, |