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

Side by Side Diff: google_apis/gaia/oauth2_token_service.cc

Issue 1148283005: Add histograms to entire MergeSession flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jwd comments Created 5 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/oauth2_token_service.h" 5 #include "google_apis/gaia/oauth2_token_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram_macros.h"
12 #include "base/profiler/scoped_tracker.h" 13 #include "base/profiler/scoped_tracker.h"
13 #include "base/rand_util.h" 14 #include "base/rand_util.h"
14 #include "base/stl_util.h" 15 #include "base/stl_util.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
17 #include "google_apis/gaia/gaia_urls.h" 18 #include "google_apis/gaia/gaia_urls.h"
18 #include "google_apis/gaia/google_service_auth_error.h" 19 #include "google_apis/gaia/google_service_auth_error.h"
19 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h" 20 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
21 22
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 285 }
285 286
286 void OAuth2TokenService::Fetcher::OnGetTokenFailure( 287 void OAuth2TokenService::Fetcher::OnGetTokenFailure(
287 const GoogleServiceAuthError& error) { 288 const GoogleServiceAuthError& error) {
288 fetcher_.reset(); 289 fetcher_.reset();
289 290
290 if (ShouldRetry(error) && retry_number_ < max_fetch_retry_num_) { 291 if (ShouldRetry(error) && retry_number_ < max_fetch_retry_num_) {
291 base::TimeDelta backoff = base::TimeDelta::FromMilliseconds( 292 base::TimeDelta backoff = base::TimeDelta::FromMilliseconds(
292 ComputeExponentialBackOffMilliseconds(retry_number_)); 293 ComputeExponentialBackOffMilliseconds(retry_number_));
293 ++retry_number_; 294 ++retry_number_;
295 UMA_HISTOGRAM_ENUMERATION("Signin.OAuth2TokenGetRetry",
296 error.state(), GoogleServiceAuthError::NUM_STATES);
294 retry_timer_.Stop(); 297 retry_timer_.Stop();
295 retry_timer_.Start(FROM_HERE, 298 retry_timer_.Start(FROM_HERE,
296 backoff, 299 backoff,
297 this, 300 this,
298 &OAuth2TokenService::Fetcher::Start); 301 &OAuth2TokenService::Fetcher::Start);
299 return; 302 return;
300 } 303 }
301 304
305 UMA_HISTOGRAM_ENUMERATION("Signin.OAuth2TokenGetFailure",
306 error.state(), GoogleServiceAuthError::NUM_STATES);
302 error_ = error; 307 error_ = error;
303 InformWaitingRequestsAndDelete(); 308 InformWaitingRequestsAndDelete();
304 } 309 }
305 310
306 // Returns an exponential backoff in milliseconds including randomness less than 311 // Returns an exponential backoff in milliseconds including randomness less than
307 // 1000 ms when retrying fetching an OAuth2 access token. 312 // 1000 ms when retrying fetching an OAuth2 access token.
308 int64 OAuth2TokenService::Fetcher::ComputeExponentialBackOffMilliseconds( 313 int64 OAuth2TokenService::Fetcher::ComputeExponentialBackOffMilliseconds(
309 int retry_num) { 314 int retry_num) {
310 DCHECK(retry_num < max_fetch_retry_num_); 315 DCHECK(retry_num < max_fetch_retry_num_);
311 int64 exponential_backoff_in_seconds = 1 << retry_num; 316 int64 exponential_backoff_in_seconds = 1 << retry_num;
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 const std::string& account_id, 847 const std::string& account_id,
843 const ScopeSet& scopes) const { 848 const ScopeSet& scopes) const {
844 PendingFetcherMap::const_iterator iter = pending_fetchers_.find( 849 PendingFetcherMap::const_iterator iter = pending_fetchers_.find(
845 OAuth2TokenService::RequestParameters( 850 OAuth2TokenService::RequestParameters(
846 client_id, 851 client_id,
847 account_id, 852 account_id,
848 scopes)); 853 scopes));
849 return iter == pending_fetchers_.end() ? 854 return iter == pending_fetchers_.end() ?
850 0 : iter->second->GetWaitingRequestCount(); 855 0 : iter->second->GetWaitingRequestCount();
851 } 856 }
OLDNEW
« no previous file with comments | « components/signin/core/browser/gaia_cookie_manager_service_unittest.cc ('k') | google_apis/gaia/ubertoken_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698