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

Side by Side Diff: chrome/browser/chromeos/login/signin/auth_sync_observer.cc

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Add SyncService* to OnStateChanged Created 3 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/signin/auth_sync_observer.h" 5 #include "chrome/browser/chromeos/login/signin/auth_sync_observer.h"
6 6
7 #include "base/metrics/user_metrics.h" 7 #include "base/metrics/user_metrics.h"
8 #include "base/metrics/user_metrics_action.h" 8 #include "base/metrics/user_metrics_action.h"
9 #include "chrome/browser/chromeos/login/reauth_stats.h" 9 #include "chrome/browser/chromeos/login/reauth_stats.h"
10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
(...skipping 29 matching lines...) Expand all
40 sync_service->AddObserver(this); 40 sync_service->AddObserver(this);
41 } 41 }
42 42
43 void AuthSyncObserver::Shutdown() { 43 void AuthSyncObserver::Shutdown() {
44 browser_sync::ProfileSyncService* sync_service = 44 browser_sync::ProfileSyncService* sync_service =
45 ProfileSyncServiceFactory::GetForProfile(profile_); 45 ProfileSyncServiceFactory::GetForProfile(profile_);
46 if (sync_service) 46 if (sync_service)
47 sync_service->RemoveObserver(this); 47 sync_service->RemoveObserver(this);
48 } 48 }
49 49
50 void AuthSyncObserver::OnStateChanged() { 50 void AuthSyncObserver::OnStateChanged(syncer::SyncService* sync) {
51 DCHECK(user_manager::UserManager::Get()->IsLoggedInAsUserWithGaiaAccount() || 51 DCHECK(user_manager::UserManager::Get()->IsLoggedInAsUserWithGaiaAccount() ||
52 user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()); 52 user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser());
53 browser_sync::ProfileSyncService* sync_service = 53 browser_sync::ProfileSyncService* sync_service =
skym 2017/01/26 23:43:22 This variable can be replaced by |sync|.
Steven Holte 2017/01/27 02:27:19 Done.
54 ProfileSyncServiceFactory::GetForProfile(profile_); 54 ProfileSyncServiceFactory::GetForProfile(profile_);
55 const user_manager::User* user = 55 const user_manager::User* user =
56 ProfileHelper::Get()->GetUserByProfile(profile_); 56 ProfileHelper::Get()->GetUserByProfile(profile_);
57 GoogleServiceAuthError::State state = 57 GoogleServiceAuthError::State state =
58 sync_service->GetAuthError().state(); 58 sync_service->GetAuthError().state();
59 if (state != GoogleServiceAuthError::NONE && 59 if (state != GoogleServiceAuthError::NONE &&
60 state != GoogleServiceAuthError::CONNECTION_FAILED && 60 state != GoogleServiceAuthError::CONNECTION_FAILED &&
61 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE && 61 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE &&
62 state != GoogleServiceAuthError::REQUEST_CANCELED) { 62 state != GoogleServiceAuthError::REQUEST_CANCELED) {
63 // Invalidate OAuth2 refresh token to force Gaia sign-in flow. This is 63 // Invalidate OAuth2 refresh token to force Gaia sign-in flow. This is
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 } 99 }
100 } 100 }
101 101
102 void AuthSyncObserver::OnSupervisedTokenLoaded(const std::string& token) { 102 void AuthSyncObserver::OnSupervisedTokenLoaded(const std::string& token) {
103 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken( 103 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken(
104 profile_, token); 104 profile_, token);
105 } 105 }
106 106
107 } // namespace chromeos 107 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698