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

Side by Side Diff: components/signin/core/browser/signin_account_id_helper.cc

Issue 686963002: Switching profiler instrumentations from ScopedProfile to ScopedTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "components/signin/core/browser/signin_account_id_helper.h" 5 #include "components/signin/core/browser/signin_account_id_helper.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/profiler/scoped_profile.h" 8 #include "base/profiler/scoped_tracker.h"
9 #include "components/signin/core/browser/profile_oauth2_token_service.h" 9 #include "components/signin/core/browser/profile_oauth2_token_service.h"
10 #include "components/signin/core/browser/signin_client.h" 10 #include "components/signin/core/browser/signin_client.h"
11 #include "components/signin/core/common/signin_pref_names.h" 11 #include "components/signin/core/common/signin_pref_names.h"
12 #include "google_apis/gaia/gaia_oauth_client.h" 12 #include "google_apis/gaia/gaia_oauth_client.h"
13 13
14 // TODO(guohui): this class should be moved to a more generic place for reuse. 14 // TODO(guohui): this class should be moved to a more generic place for reuse.
15 class SigninAccountIdHelper::GaiaIdFetcher 15 class SigninAccountIdHelper::GaiaIdFetcher
16 : public OAuth2TokenService::Consumer, 16 : public OAuth2TokenService::Consumer,
17 public gaia::GaiaOAuthClient::Delegate { 17 public gaia::GaiaOAuthClient::Delegate {
18 public: 18 public:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 token_service_->RemoveObserver(this); 130 token_service_->RemoveObserver(this);
131 } 131 }
132 132
133 void SigninAccountIdHelper::GoogleSignedOut(const std::string& account_id, 133 void SigninAccountIdHelper::GoogleSignedOut(const std::string& account_id,
134 const std::string& username) { 134 const std::string& username) {
135 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUserAccountId); 135 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUserAccountId);
136 } 136 }
137 137
138 void SigninAccountIdHelper::OnRefreshTokenAvailable( 138 void SigninAccountIdHelper::OnRefreshTokenAvailable(
139 const std::string& account_id) { 139 const std::string& account_id) {
140 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 140 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
141 tracked_objects::ScopedProfile tracking_profile( 141 tracked_objects::ScopedTracker tracking_profile(
142 FROM_HERE_WITH_EXPLICIT_FUNCTION( 142 FROM_HERE_WITH_EXPLICIT_FUNCTION(
143 "422460 SigninAccountIdHelper::OnRefreshTokenAvailable")); 143 "422460 SigninAccountIdHelper::OnRefreshTokenAvailable"));
144 144
145 if (account_id == signin_manager_->GetAuthenticatedAccountId()) { 145 if (account_id == signin_manager_->GetAuthenticatedAccountId()) {
146 std::string current_gaia_id = 146 std::string current_gaia_id =
147 client_->GetPrefs()->GetString(prefs::kGoogleServicesUserAccountId); 147 client_->GetPrefs()->GetString(prefs::kGoogleServicesUserAccountId);
148 if (current_gaia_id.empty() && !disable_for_test_) { 148 if (current_gaia_id.empty() && !disable_for_test_) {
149 id_fetcher_.reset( 149 id_fetcher_.reset(
150 new GaiaIdFetcher(client_, token_service_, signin_manager_, this)); 150 new GaiaIdFetcher(client_, token_service_, signin_manager_, this));
151 } 151 }
152 } 152 }
153 } 153 }
154 154
155 void SigninAccountIdHelper::OnPrimaryAccountIdFetched( 155 void SigninAccountIdHelper::OnPrimaryAccountIdFetched(
156 const std::string& gaia_id) { 156 const std::string& gaia_id) {
157 if (!gaia_id.empty()) { 157 if (!gaia_id.empty()) {
158 client_->GetPrefs()->SetString(prefs::kGoogleServicesUserAccountId, 158 client_->GetPrefs()->SetString(prefs::kGoogleServicesUserAccountId,
159 gaia_id); 159 gaia_id);
160 } 160 }
161 } 161 }
162 162
163 // static 163 // static
164 bool SigninAccountIdHelper::disable_for_test_ = false; 164 bool SigninAccountIdHelper::disable_for_test_ = false;
165 165
166 // static 166 // static
167 void SigninAccountIdHelper::SetDisableForTest(bool disable_for_test) { 167 void SigninAccountIdHelper::SetDisableForTest(bool disable_for_test) {
168 disable_for_test_ = disable_for_test; 168 disable_for_test_ = disable_for_test;
169 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698