| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 policy_service_ = | 381 policy_service_ = |
| 382 g_browser_process->browser_policy_connector()->CreatePolicyService(this); | 382 g_browser_process->browser_policy_connector()->CreatePolicyService(this); |
| 383 #else | 383 #else |
| 384 policy_service_.reset(new policy::PolicyServiceStub()); | 384 policy_service_.reset(new policy::PolicyServiceStub()); |
| 385 #endif | 385 #endif |
| 386 | 386 |
| 387 DCHECK(create_mode == CREATE_MODE_ASYNCHRONOUS || | 387 DCHECK(create_mode == CREATE_MODE_ASYNCHRONOUS || |
| 388 create_mode == CREATE_MODE_SYNCHRONOUS); | 388 create_mode == CREATE_MODE_SYNCHRONOUS); |
| 389 bool async_prefs = create_mode == CREATE_MODE_ASYNCHRONOUS; | 389 bool async_prefs = create_mode == CREATE_MODE_ASYNCHRONOUS; |
| 390 | 390 |
| 391 chrome::RegisterUserPrefs(pref_registry_); |
| 392 |
| 391 { | 393 { |
| 392 // On startup, preference loading is always synchronous so a scoped timer | 394 // On startup, preference loading is always synchronous so a scoped timer |
| 393 // will work here. | 395 // will work here. |
| 394 startup_metric_utils::ScopedSlowStartupUMA | 396 startup_metric_utils::ScopedSlowStartupUMA |
| 395 scoped_timer("Startup.SlowStartupPreferenceLoading"); | 397 scoped_timer("Startup.SlowStartupPreferenceLoading"); |
| 396 prefs_.reset(chrome_prefs::CreateProfilePrefs( | 398 prefs_.reset(chrome_prefs::CreateProfilePrefs( |
| 397 GetPrefFilePath(), | 399 GetPrefFilePath(), |
| 398 sequenced_task_runner, | 400 sequenced_task_runner, |
| 399 policy_service_.get(), | 401 policy_service_.get(), |
| 400 new ExtensionPrefStore( | 402 new ExtensionPrefStore( |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 return extension_special_storage_policy_.get(); | 702 return extension_special_storage_policy_.get(); |
| 701 } | 703 } |
| 702 | 704 |
| 703 void ProfileImpl::OnPrefsLoaded(bool success) { | 705 void ProfileImpl::OnPrefsLoaded(bool success) { |
| 704 if (!success) { | 706 if (!success) { |
| 705 if (delegate_) | 707 if (delegate_) |
| 706 delegate_->OnProfileCreated(this, false, false); | 708 delegate_->OnProfileCreated(this, false, false); |
| 707 return; | 709 return; |
| 708 } | 710 } |
| 709 | 711 |
| 710 // TODO(joi): Registration can move to the constructor once it | |
| 711 // doesn't need the PrefService parameter. | |
| 712 chrome::RegisterUserPrefs(prefs_.get(), pref_registry_); | |
| 713 | |
| 714 // TODO(mirandac): remove migration code after 6 months (crbug.com/69995). | 712 // TODO(mirandac): remove migration code after 6 months (crbug.com/69995). |
| 715 if (g_browser_process->local_state()) | 713 if (g_browser_process->local_state()) |
| 716 chrome::MigrateBrowserPrefs(this, g_browser_process->local_state()); | 714 chrome::MigrateBrowserPrefs(this, g_browser_process->local_state()); |
| 717 // TODO(ivankr): remove cleanup code eventually (crbug.com/165672). | 715 // TODO(ivankr): remove cleanup code eventually (crbug.com/165672). |
| 718 chrome::MigrateUserPrefs(this); | 716 chrome::MigrateUserPrefs(this); |
| 719 | 717 |
| 720 // |kSessionExitType| was added after |kSessionExitedCleanly|. If the pref | 718 // |kSessionExitType| was added after |kSessionExitedCleanly|. If the pref |
| 721 // value is empty fallback to checking for |kSessionExitedCleanly|. | 719 // value is empty fallback to checking for |kSessionExitedCleanly|. |
| 722 const std::string exit_type_pref_value( | 720 const std::string exit_type_pref_value( |
| 723 prefs_->GetString(prefs::kSessionExitType)); | 721 prefs_->GetString(prefs::kSessionExitType)); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 base::FilePath* cache_path, | 1180 base::FilePath* cache_path, |
| 1183 int* max_size) { | 1181 int* max_size) { |
| 1184 DCHECK(cache_path); | 1182 DCHECK(cache_path); |
| 1185 DCHECK(max_size); | 1183 DCHECK(max_size); |
| 1186 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1184 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
| 1187 if (!path.empty()) | 1185 if (!path.empty()) |
| 1188 *cache_path = path; | 1186 *cache_path = path; |
| 1189 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1187 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1190 prefs_->GetInteger(prefs::kDiskCacheSize); | 1188 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1191 } | 1189 } |
| OLD | NEW |