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

Unified Diff: chrome/browser/chromeos/login/user_manager.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/user_manager.cc
diff --git a/chrome/browser/chromeos/login/user_manager.cc b/chrome/browser/chromeos/login/user_manager.cc
index 57075a01cbeb95dd7c0db8dd4716850816916873..edf76e2371acb81d531fcb580c0aef56f466a6d0 100644
--- a/chrome/browser/chromeos/login/user_manager.cc
+++ b/chrome/browser/chromeos/login/user_manager.cc
@@ -70,11 +70,14 @@ void SaveOAuthTokenStatusToLocalState(const std::string& username,
UserManager::OAuthTokenStatus oauth_token_status) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
PrefService* local_state = g_browser_process->local_state();
- DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus);
- oauth_status_update->SetWithoutPathExpansion(username,
- new base::FundamentalValue(static_cast<int>(oauth_token_status)));
- DVLOG(1) << "Saving user OAuth token status in Local State.";
- local_state->SavePersistentPrefs();
+ {
+ DictionaryPrefUpdate oauth_status_update(
+ local_state, kUserOAuthTokenStatus);
+ oauth_status_update->SetWithoutPathExpansion(username,
+ new base::FundamentalValue(static_cast<int>(oauth_token_status)));
+ DVLOG(1) << "Saving user OAuth token status in Local State.";
+ }
+ local_state->CommitPendingWrite();
}
// Gets user's OAuthTokenStatus from local state.
@@ -108,14 +111,16 @@ void SaveImageToLocalState(const std::string& username,
int image_index) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
PrefService* local_state = g_browser_process->local_state();
- DictionaryPrefUpdate images_update(local_state, kUserImages);
- base::DictionaryValue* image_properties = new base::DictionaryValue();
- image_properties->Set(kImagePathNodeName, new StringValue(image_path));
- image_properties->Set(kImageIndexNodeName,
- new base::FundamentalValue(image_index));
- images_update->SetWithoutPathExpansion(username, image_properties);
- DVLOG(1) << "Saving path to user image in Local State.";
- local_state->SavePersistentPrefs();
+ {
+ DictionaryPrefUpdate images_update(local_state, kUserImages);
+ base::DictionaryValue* image_properties = new base::DictionaryValue();
+ image_properties->Set(kImagePathNodeName, new StringValue(image_path));
+ image_properties->Set(kImageIndexNodeName,
+ new base::FundamentalValue(image_index));
+ images_update->SetWithoutPathExpansion(username, image_properties);
+ DVLOG(1) << "Saving path to user image in Local State.";
+ }
+ local_state->CommitPendingWrite();
UserManager::Get()->NotifyLocalStateChanged();
UserManager* user_manager = UserManager::Get();
NotificationService::current()->Notify(
@@ -435,27 +440,29 @@ void UserManager::UserLoggedIn(const std::string& email) {
// Clear the prefs view of the users.
PrefService* prefs = g_browser_process->local_state();
- ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers);
- prefs_users_update->Clear();
-
- user_is_logged_in_ = true;
- logged_in_user_ = User();
- logged_in_user_.set_email(email);
-
- // Make sure this user is first.
- prefs_users_update->Append(Value::CreateStringValue(email));
- for (std::vector<User>::iterator it = users.begin();
- it != users.end();
- ++it) {
- std::string user_email = it->email();
- // Skip the most recent user.
- if (email != user_email) {
- prefs_users_update->Append(Value::CreateStringValue(user_email));
- } else {
- logged_in_user_ = *it;
+ {
+ ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers);
+ prefs_users_update->Clear();
+
+ user_is_logged_in_ = true;
+ logged_in_user_ = User();
+ logged_in_user_.set_email(email);
+
+ // Make sure this user is first.
+ prefs_users_update->Append(Value::CreateStringValue(email));
+ for (std::vector<User>::iterator it = users.begin();
+ it != users.end();
+ ++it) {
+ std::string user_email = it->email();
+ // Skip the most recent user.
+ if (email != user_email) {
+ prefs_users_update->Append(Value::CreateStringValue(user_email));
+ } else {
+ logged_in_user_ = *it;
+ }
}
}
- prefs->SavePersistentPrefs();
+ prefs->CommitPendingWrite();
NotifyOnLogin();
if (current_user_is_new_) {
SetDefaultUserImage(email);
@@ -517,29 +524,31 @@ void UserManager::RemoveUserFromList(const std::string& email) {
// Clear the prefs view of the users.
PrefService* prefs = g_browser_process->local_state();
- ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers);
- prefs_users_update->Clear();
-
- for (std::vector<User>::iterator it = users.begin();
- it != users.end();
- ++it) {
- std::string user_email = it->email();
- // Skip user that we would like to delete.
- if (email != user_email)
- prefs_users_update->Append(Value::CreateStringValue(user_email));
- }
-
- DictionaryPrefUpdate prefs_images_update(prefs, kUserImages);
std::string image_path_string;
- prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string);
- prefs_images_update->RemoveWithoutPathExpansion(email, NULL);
+ {
+ ListPrefUpdate prefs_users_update(prefs, kLoggedInUsers);
+ prefs_users_update->Clear();
- DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus);
- int oauth_status;
- prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status);
- prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL);
+ for (std::vector<User>::iterator it = users.begin();
+ it != users.end();
+ ++it) {
+ std::string user_email = it->email();
+ // Skip user that we would like to delete.
+ if (email != user_email)
+ prefs_users_update->Append(Value::CreateStringValue(user_email));
+ }
- prefs->SavePersistentPrefs();
+ DictionaryPrefUpdate prefs_images_update(prefs, kUserImages);
+ prefs_images_update->GetStringWithoutPathExpansion(
+ email, &image_path_string);
+ prefs_images_update->RemoveWithoutPathExpansion(email, NULL);
+
+ DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus);
+ int oauth_status;
+ prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status);
+ prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL);
+ }
+ prefs->CommitPendingWrite();
int default_image_id = kDefaultImagesCount;
if (!IsDefaultImagePath(image_path_string, &default_image_id)) {

Powered by Google App Engine
This is Rietveld 408576698