Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 8198007: Remove PrefService::ScheduleSavePersistentPrefs and SavePersistentPrefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 browser::MigrateBrowserPrefs(prefs_.get(), 917 browser::MigrateBrowserPrefs(prefs_.get(),
918 g_browser_process->local_state()); 918 g_browser_process->local_state());
919 } 919 }
920 920
921 // The last session exited cleanly if there is no pref for 921 // The last session exited cleanly if there is no pref for
922 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. 922 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true.
923 last_session_exited_cleanly_ = 923 last_session_exited_cleanly_ =
924 prefs_->GetBoolean(prefs::kSessionExitedCleanly); 924 prefs_->GetBoolean(prefs::kSessionExitedCleanly);
925 // Mark the session as open. 925 // Mark the session as open.
926 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); 926 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false);
927 // Make sure we save to disk that the session has opened.
928 prefs_->ScheduleSavePersistentPrefs();
Mattias Nissler (ping if slow) 2011/10/12 09:23:39 At this point I think we actually want a CommitPen
Bernhard Bauer 2011/10/12 11:00:11 Hm, could this adversely affect startup performanc
Mattias Nissler (ping if slow) 2011/10/12 11:02:27 Ah, the old fast vs. correct tradeoff :) I'm OK ei
929 927
930 bool extensions_disabled = 928 bool extensions_disabled =
931 prefs_->GetBoolean(prefs::kDisableExtensions) || 929 prefs_->GetBoolean(prefs::kDisableExtensions) ||
932 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions); 930 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions);
933 931
934 // Ensure that preferences set by extensions are restored in the profile 932 // Ensure that preferences set by extensions are restored in the profile
935 // as early as possible. The constructor takes care of that. 933 // as early as possible. The constructor takes care of that.
936 extension_prefs_.reset(new ExtensionPrefs( 934 extension_prefs_.reset(new ExtensionPrefs(
937 prefs_.get(), 935 prefs_.get(),
938 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), 936 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName),
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 return webkit_context_.get(); 1459 return webkit_context_.get();
1462 } 1460 }
1463 1461
1464 void ProfileImpl::MarkAsCleanShutdown() { 1462 void ProfileImpl::MarkAsCleanShutdown() {
1465 if (prefs_.get()) { 1463 if (prefs_.get()) {
1466 // The session cleanly exited, set kSessionExitedCleanly appropriately. 1464 // The session cleanly exited, set kSessionExitedCleanly appropriately.
1467 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); 1465 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true);
1468 1466
1469 // NOTE: If you change what thread this writes on, be sure and update 1467 // NOTE: If you change what thread this writes on, be sure and update
1470 // ChromeFrame::EndSession(). 1468 // ChromeFrame::EndSession().
1471 prefs_->SavePersistentPrefs(); 1469 prefs_->CommitPendingWrite();
1472 } 1470 }
1473 } 1471 }
1474 1472
1475 void ProfileImpl::Observe(int type, 1473 void ProfileImpl::Observe(int type,
1476 const NotificationSource& source, 1474 const NotificationSource& source,
1477 const NotificationDetails& details) { 1475 const NotificationDetails& details) {
1478 switch (type) { 1476 switch (type) {
1479 case chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED: { 1477 case chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED: {
1480 bool* succeeded = Details<bool>(details).ptr(); 1478 bool* succeeded = Details<bool>(details).ptr();
1481 PrefService *prefs = Source<PrefService>(source).ptr(); 1479 PrefService *prefs = Source<PrefService>(source).ptr();
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 NOTREACHED(); 1710 NOTREACHED();
1713 break; 1711 break;
1714 } 1712 }
1715 } 1713 }
1716 if (do_update_pref) 1714 if (do_update_pref)
1717 GetPrefs()->SetString(prefs::kApplicationLocale, new_locale); 1715 GetPrefs()->SetString(prefs::kApplicationLocale, new_locale);
1718 local_state->SetString(prefs::kApplicationLocale, new_locale); 1716 local_state->SetString(prefs::kApplicationLocale, new_locale);
1719 1717
1720 if (chromeos::UserManager::Get()->current_user_is_owner()) 1718 if (chromeos::UserManager::Get()->current_user_is_owner())
1721 local_state->SetString(prefs::kOwnerLocale, new_locale); 1719 local_state->SetString(prefs::kOwnerLocale, new_locale);
1722
1723 GetPrefs()->ScheduleSavePersistentPrefs();
1724 local_state->ScheduleSavePersistentPrefs();
1725 } 1720 }
1726 1721
1727 void ProfileImpl::OnLogin() { 1722 void ProfileImpl::OnLogin() {
1728 if (locale_change_guard_ == NULL) 1723 if (locale_change_guard_ == NULL)
1729 locale_change_guard_.reset(new chromeos::LocaleChangeGuard(this)); 1724 locale_change_guard_.reset(new chromeos::LocaleChangeGuard(this));
1730 locale_change_guard_->OnLogin(); 1725 locale_change_guard_->OnLogin();
1731 } 1726 }
1732 1727
1733 void ProfileImpl::SetupChromeOSEnterpriseExtensionObserver() { 1728 void ProfileImpl::SetupChromeOSEnterpriseExtensionObserver() {
1734 DCHECK(!chromeos_enterprise_extension_observer_.get()); 1729 DCHECK(!chromeos_enterprise_extension_observer_.get());
(...skipping 25 matching lines...) Expand all
1760 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { 1755 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() {
1761 if (!spellcheck_profile_.get()) 1756 if (!spellcheck_profile_.get())
1762 spellcheck_profile_.reset(new SpellCheckProfile()); 1757 spellcheck_profile_.reset(new SpellCheckProfile());
1763 return spellcheck_profile_.get(); 1758 return spellcheck_profile_.get();
1764 } 1759 }
1765 1760
1766 void ProfileImpl::SetDownloadManagerDelegate( 1761 void ProfileImpl::SetDownloadManagerDelegate(
1767 ChromeDownloadManagerDelegate* delegate) { 1762 ChromeDownloadManagerDelegate* delegate) {
1768 download_manager_delegate_ = delegate; 1763 download_manager_delegate_ = delegate;
1769 } 1764 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698