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

Side by Side Diff: google_apis/gaia/account_tracker.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 "google_apis/gaia/account_tracker.h" 5 #include "google_apis/gaia/account_tracker.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/profiler/scoped_profile.h" 9 #include "base/profiler/scoped_tracker.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "net/url_request/url_request_context_getter.h" 11 #include "net/url_request/url_request_context_getter.h"
12 12
13 namespace gaia { 13 namespace gaia {
14 14
15 AccountTracker::AccountTracker( 15 AccountTracker::AccountTracker(
16 IdentityProvider* identity_provider, 16 IdentityProvider* identity_provider,
17 net::URLRequestContextGetter* request_context_getter) 17 net::URLRequestContextGetter* request_context_getter)
18 : identity_provider_(identity_provider), 18 : identity_provider_(identity_provider),
19 request_context_getter_(request_context_getter), 19 request_context_getter_(request_context_getter),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 const AccountState& state = it->second; 78 const AccountState& state = it->second;
79 if (state.ids.gaia == gaia_id) { 79 if (state.ids.gaia == gaia_id) {
80 return state.ids; 80 return state.ids;
81 } 81 }
82 } 82 }
83 83
84 return AccountIds(); 84 return AccountIds();
85 } 85 }
86 86
87 void AccountTracker::OnRefreshTokenAvailable(const std::string& account_id) { 87 void AccountTracker::OnRefreshTokenAvailable(const std::string& account_id) {
88 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 88 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
89 tracked_objects::ScopedProfile tracking_profile( 89 tracked_objects::ScopedTracker tracking_profile(
90 FROM_HERE_WITH_EXPLICIT_FUNCTION( 90 FROM_HERE_WITH_EXPLICIT_FUNCTION(
91 "422460 AccountTracker::OnRefreshTokenAvailable")); 91 "422460 AccountTracker::OnRefreshTokenAvailable"));
92 92
93 TRACE_EVENT1("identity", 93 TRACE_EVENT1("identity",
94 "AccountTracker::OnRefreshTokenAvailable", 94 "AccountTracker::OnRefreshTokenAvailable",
95 "account_key", 95 "account_key",
96 account_id); 96 account_id);
97 97
98 // Ignore refresh tokens if there is no active account ID at all. 98 // Ignore refresh tokens if there is no active account ID at all.
99 if (identity_provider_->GetActiveAccountId().empty()) 99 if (identity_provider_->GetActiveAccountId().empty())
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 Observer, observer_list_, OnAccountAdded(account.ids)); 157 Observer, observer_list_, OnAccountAdded(account.ids));
158 } 158 }
159 159
160 void AccountTracker::NotifyAccountRemoved(const AccountState& account) { 160 void AccountTracker::NotifyAccountRemoved(const AccountState& account) {
161 DCHECK(!account.ids.gaia.empty()); 161 DCHECK(!account.ids.gaia.empty());
162 FOR_EACH_OBSERVER( 162 FOR_EACH_OBSERVER(
163 Observer, observer_list_, OnAccountRemoved(account.ids)); 163 Observer, observer_list_, OnAccountRemoved(account.ids));
164 } 164 }
165 165
166 void AccountTracker::NotifySignInChanged(const AccountState& account) { 166 void AccountTracker::NotifySignInChanged(const AccountState& account) {
167 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 167 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
168 tracked_objects::ScopedProfile tracking_profile( 168 tracked_objects::ScopedTracker tracking_profile(
169 FROM_HERE_WITH_EXPLICIT_FUNCTION( 169 FROM_HERE_WITH_EXPLICIT_FUNCTION(
170 "422460 AccountTracker::NotifySignInChanged")); 170 "422460 AccountTracker::NotifySignInChanged"));
171 171
172 DCHECK(!account.ids.gaia.empty()); 172 DCHECK(!account.ids.gaia.empty());
173 FOR_EACH_OBSERVER(Observer, 173 FOR_EACH_OBSERVER(Observer,
174 observer_list_, 174 observer_list_,
175 OnAccountSignInChanged(account.ids, account.is_signed_in)); 175 OnAccountSignInChanged(account.ids, account.is_signed_in));
176 } 176 }
177 177
178 void AccountTracker::UpdateSignInState(const std::string account_key, 178 void AccountTracker::UpdateSignInState(const std::string account_key,
179 bool is_signed_in) { 179 bool is_signed_in) {
180 tracked_objects::ScopedProfile tracking_profile( 180 tracked_objects::ScopedTracker tracking_profile(
181 FROM_HERE_WITH_EXPLICIT_FUNCTION( 181 FROM_HERE_WITH_EXPLICIT_FUNCTION(
182 "422460 AccountTracker::UpdateSignInState")); 182 "422460 AccountTracker::UpdateSignInState"));
183 183
184 StartTrackingAccount(account_key); 184 StartTrackingAccount(account_key);
185 AccountState& account = accounts_[account_key]; 185 AccountState& account = accounts_[account_key];
186 bool needs_gaia_id = account.ids.gaia.empty(); 186 bool needs_gaia_id = account.ids.gaia.empty();
187 bool was_signed_in = account.is_signed_in; 187 bool was_signed_in = account.is_signed_in;
188 account.is_signed_in = is_signed_in; 188 account.is_signed_in = is_signed_in;
189 189
190 if (needs_gaia_id && is_signed_in) 190 if (needs_gaia_id && is_signed_in)
191 StartFetchingUserInfo(account_key); 191 StartFetchingUserInfo(account_key);
192 192
193 if (!needs_gaia_id && (was_signed_in != is_signed_in)) 193 if (!needs_gaia_id && (was_signed_in != is_signed_in))
194 NotifySignInChanged(account); 194 NotifySignInChanged(account);
195 } 195 }
196 196
197 void AccountTracker::StartTrackingAccount(const std::string account_key) { 197 void AccountTracker::StartTrackingAccount(const std::string account_key) {
198 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 198 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
199 tracked_objects::ScopedProfile tracking_profile( 199 tracked_objects::ScopedTracker tracking_profile(
200 FROM_HERE_WITH_EXPLICIT_FUNCTION( 200 FROM_HERE_WITH_EXPLICIT_FUNCTION(
201 "422460 AccountTracker::StartTrackingAccount")); 201 "422460 AccountTracker::StartTrackingAccount"));
202 202
203 if (!ContainsKey(accounts_, account_key)) { 203 if (!ContainsKey(accounts_, account_key)) {
204 DVLOG(1) << "StartTracking " << account_key; 204 DVLOG(1) << "StartTracking " << account_key;
205 AccountState account_state; 205 AccountState account_state;
206 account_state.ids.account_key = account_key; 206 account_state.ids.account_key = account_key;
207 account_state.ids.email = account_key; 207 account_state.ids.email = account_key;
208 account_state.is_signed_in = false; 208 account_state.is_signed_in = false;
209 accounts_.insert(make_pair(account_key, account_state)); 209 accounts_.insert(make_pair(account_key, account_state));
(...skipping 14 matching lines...) Expand all
224 if (ContainsKey(user_info_requests_, account_key)) 224 if (ContainsKey(user_info_requests_, account_key))
225 DeleteFetcher(user_info_requests_[account_key]); 225 DeleteFetcher(user_info_requests_[account_key]);
226 } 226 }
227 227
228 void AccountTracker::StopTrackingAllAccounts() { 228 void AccountTracker::StopTrackingAllAccounts() {
229 while (!accounts_.empty()) 229 while (!accounts_.empty())
230 StopTrackingAccount(accounts_.begin()->first); 230 StopTrackingAccount(accounts_.begin()->first);
231 } 231 }
232 232
233 void AccountTracker::StartFetchingUserInfo(const std::string account_key) { 233 void AccountTracker::StartFetchingUserInfo(const std::string account_key) {
234 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 234 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
235 tracked_objects::ScopedProfile tracking_profile( 235 tracked_objects::ScopedTracker tracking_profile(
236 FROM_HERE_WITH_EXPLICIT_FUNCTION( 236 FROM_HERE_WITH_EXPLICIT_FUNCTION(
237 "422460 AccountTracker::StartFetchingUserInfo")); 237 "422460 AccountTracker::StartFetchingUserInfo"));
238 238
239 if (ContainsKey(user_info_requests_, account_key)) 239 if (ContainsKey(user_info_requests_, account_key))
240 DeleteFetcher(user_info_requests_[account_key]); 240 DeleteFetcher(user_info_requests_[account_key]);
241 241
242 DVLOG(1) << "StartFetching " << account_key; 242 DVLOG(1) << "StartFetching " << account_key;
243 AccountIdFetcher* fetcher = 243 AccountIdFetcher* fetcher =
244 new AccountIdFetcher(identity_provider_->GetTokenService(), 244 new AccountIdFetcher(identity_provider_->GetTokenService(),
245 request_context_getter_.get(), 245 request_context_getter_.get(),
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 "AccountIdFetcher", 355 "AccountIdFetcher",
356 this, 356 this,
357 "OnNetworkError", 357 "OnNetworkError",
358 "response_code", 358 "response_code",
359 response_code); 359 response_code);
360 LOG(ERROR) << "OnNetworkError " << response_code; 360 LOG(ERROR) << "OnNetworkError " << response_code;
361 tracker_->OnUserInfoFetchFailure(this); 361 tracker_->OnUserInfoFetchFailure(this);
362 } 362 }
363 363
364 } // namespace gaia 364 } // namespace gaia
OLDNEW
« no previous file with comments | « extensions/browser/updater/extension_downloader.cc ('k') | google_apis/gaia/gaia_auth_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698