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

Side by Side 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: '' 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/chromeos/login/user_manager.h" 5 #include "chrome/browser/chromeos/login/user_manager.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/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 // Stores user's OAuthTokenStatus in local state. Runs on UI thread. 68 // Stores user's OAuthTokenStatus in local state. Runs on UI thread.
69 void SaveOAuthTokenStatusToLocalState(const std::string& username, 69 void SaveOAuthTokenStatusToLocalState(const std::string& username,
70 UserManager::OAuthTokenStatus oauth_token_status) { 70 UserManager::OAuthTokenStatus oauth_token_status) {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
72 PrefService* local_state = g_browser_process->local_state(); 72 PrefService* local_state = g_browser_process->local_state();
73 DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus); 73 DictionaryPrefUpdate oauth_status_update(local_state, kUserOAuthTokenStatus);
74 oauth_status_update->SetWithoutPathExpansion(username, 74 oauth_status_update->SetWithoutPathExpansion(username,
75 new base::FundamentalValue(static_cast<int>(oauth_token_status))); 75 new base::FundamentalValue(static_cast<int>(oauth_token_status)));
76 DVLOG(1) << "Saving user OAuth token status in Local State."; 76 DVLOG(1) << "Saving user OAuth token status in Local State.";
77 local_state->SavePersistentPrefs(); 77 local_state->CommitPendingWrite();
battre 2011/10/11 18:46:23 DictionaryPrefUpdate triggers a ScheduleSavePersis
Bernhard Bauer 2011/10/11 19:24:20 Done.
78 } 78 }
79 79
80 // Gets user's OAuthTokenStatus from local state. 80 // Gets user's OAuthTokenStatus from local state.
81 UserManager::OAuthTokenStatus GetOAuthTokenStatusFromLocalState( 81 UserManager::OAuthTokenStatus GetOAuthTokenStatusFromLocalState(
82 const std::string& username) { 82 const std::string& username) {
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
84 84
85 if (CommandLine::ForCurrentProcess()->HasSwitch( 85 if (CommandLine::ForCurrentProcess()->HasSwitch(
86 switches::kSkipOAuthLogin)) { 86 switches::kSkipOAuthLogin)) {
87 // Use OAUTH_TOKEN_STATUS_VALID flag if kSkipOAuthLogin is present. 87 // Use OAUTH_TOKEN_STATUS_VALID flag if kSkipOAuthLogin is present.
(...skipping 20 matching lines...) Expand all
108 int image_index) { 108 int image_index) {
109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
110 PrefService* local_state = g_browser_process->local_state(); 110 PrefService* local_state = g_browser_process->local_state();
111 DictionaryPrefUpdate images_update(local_state, kUserImages); 111 DictionaryPrefUpdate images_update(local_state, kUserImages);
112 base::DictionaryValue* image_properties = new base::DictionaryValue(); 112 base::DictionaryValue* image_properties = new base::DictionaryValue();
113 image_properties->Set(kImagePathNodeName, new StringValue(image_path)); 113 image_properties->Set(kImagePathNodeName, new StringValue(image_path));
114 image_properties->Set(kImageIndexNodeName, 114 image_properties->Set(kImageIndexNodeName,
115 new base::FundamentalValue(image_index)); 115 new base::FundamentalValue(image_index));
116 images_update->SetWithoutPathExpansion(username, image_properties); 116 images_update->SetWithoutPathExpansion(username, image_properties);
117 DVLOG(1) << "Saving path to user image in Local State."; 117 DVLOG(1) << "Saving path to user image in Local State.";
118 local_state->SavePersistentPrefs(); 118 local_state->CommitPendingWrite();
119 UserManager::Get()->NotifyLocalStateChanged(); 119 UserManager::Get()->NotifyLocalStateChanged();
120 UserManager* user_manager = UserManager::Get(); 120 UserManager* user_manager = UserManager::Get();
121 NotificationService::current()->Notify( 121 NotificationService::current()->Notify(
122 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 122 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
123 Source<UserManager>(user_manager), 123 Source<UserManager>(user_manager),
124 Details<const UserManager::User>(&(user_manager->logged_in_user()))); 124 Details<const UserManager::User>(&(user_manager->logged_in_user())));
125 } 125 }
126 126
127 // Saves image to file with specified path. Runs on FILE thread. 127 // Saves image to file with specified path. Runs on FILE thread.
128 // Posts task for saving image info to local state on UI thread. 128 // Posts task for saving image info to local state on UI thread.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 it != users.end(); 448 it != users.end();
449 ++it) { 449 ++it) {
450 std::string user_email = it->email(); 450 std::string user_email = it->email();
451 // Skip the most recent user. 451 // Skip the most recent user.
452 if (email != user_email) { 452 if (email != user_email) {
453 prefs_users_update->Append(Value::CreateStringValue(user_email)); 453 prefs_users_update->Append(Value::CreateStringValue(user_email));
454 } else { 454 } else {
455 logged_in_user_ = *it; 455 logged_in_user_ = *it;
456 } 456 }
457 } 457 }
458 prefs->SavePersistentPrefs(); 458 prefs->CommitPendingWrite();
459 NotifyOnLogin(); 459 NotifyOnLogin();
460 if (current_user_is_new_) { 460 if (current_user_is_new_) {
461 SetDefaultUserImage(email); 461 SetDefaultUserImage(email);
462 } else { 462 } else {
463 // Download profile image if it's user image and see if it has changed. 463 // Download profile image if it's user image and see if it has changed.
464 int image_index = logged_in_user_.default_image_index(); 464 int image_index = logged_in_user_.default_image_index();
465 if (image_index == User::kProfileImageIndex) { 465 if (image_index == User::kProfileImageIndex) {
466 BrowserThread::PostDelayedTask( 466 BrowserThread::PostDelayedTask(
467 BrowserThread::UI, 467 BrowserThread::UI,
468 FROM_HERE, 468 FROM_HERE,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages); 532 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages);
533 std::string image_path_string; 533 std::string image_path_string;
534 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); 534 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string);
535 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); 535 prefs_images_update->RemoveWithoutPathExpansion(email, NULL);
536 536
537 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); 537 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus);
538 int oauth_status; 538 int oauth_status;
539 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); 539 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status);
540 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); 540 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL);
541 541
542 prefs->SavePersistentPrefs(); 542 prefs->CommitPendingWrite();
543 543
544 int default_image_id = kDefaultImagesCount; 544 int default_image_id = kDefaultImagesCount;
545 if (!IsDefaultImagePath(image_path_string, &default_image_id)) { 545 if (!IsDefaultImagePath(image_path_string, &default_image_id)) {
546 FilePath image_path(image_path_string); 546 FilePath image_path(image_path_string);
547 BrowserThread::PostTask( 547 BrowserThread::PostTask(
548 BrowserThread::FILE, 548 BrowserThread::FILE,
549 FROM_HERE, 549 FROM_HERE,
550 NewRunnableFunction(&DeleteUserImage, 550 NewRunnableFunction(&DeleteUserImage,
551 image_path)); 551 image_path));
552 } 552 }
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 observer_list_, 813 observer_list_,
814 LocalStateChanged(this)); 814 LocalStateChanged(this));
815 } 815 }
816 816
817 void UserManager::DownloadProfileImage() { 817 void UserManager::DownloadProfileImage() {
818 profile_image_downloader_.reset(new ProfileImageDownloader(this)); 818 profile_image_downloader_.reset(new ProfileImageDownloader(this));
819 profile_image_downloader_->Start(); 819 profile_image_downloader_->Start();
820 } 820 }
821 821
822 } // namespace chromeos 822 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_utils.cc ('k') | chrome/browser/chromeos/login/wizard_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698