Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/gaia_cookie_manager_service.h" | 5 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| 11 #include "base/format_macros.h" | |
| 11 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 12 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "components/data_use_measurement/core/data_use_user_data.h" | 19 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 19 #include "components/signin/core/browser/account_tracker_service.h" | 20 #include "components/signin/core/browser/account_tracker_service.h" |
| 20 #include "components/signin/core/browser/signin_metrics.h" | 21 #include "components/signin/core/browser/signin_metrics.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 OAuth2TokenService* token_service, | 292 OAuth2TokenService* token_service, |
| 292 const std::string& source, | 293 const std::string& source, |
| 293 SigninClient* signin_client) | 294 SigninClient* signin_client) |
| 294 : token_service_(token_service), | 295 : token_service_(token_service), |
| 295 signin_client_(signin_client), | 296 signin_client_(signin_client), |
| 296 external_cc_result_fetcher_(this), | 297 external_cc_result_fetcher_(this), |
| 297 fetcher_backoff_(&kBackoffPolicy), | 298 fetcher_backoff_(&kBackoffPolicy), |
| 298 fetcher_retries_(0), | 299 fetcher_retries_(0), |
| 299 source_(source), | 300 source_(source), |
| 300 external_cc_result_fetched_(false), | 301 external_cc_result_fetched_(false), |
| 301 list_accounts_stale_(true) { | 302 list_accounts_stale_(true), |
| 303 // |GaiaCookieManagerService| is created as soon as the profle is | |
| 304 // initialized so it is acceptable to use of this | |
| 305 // |GaiaCookieManagerService| as the time when the profile is loaded. | |
| 306 profile_load_time_(base::Time::Now()) { | |
| 302 DCHECK(!source_.empty()); | 307 DCHECK(!source_.empty()); |
| 303 } | 308 } |
| 304 | 309 |
| 305 GaiaCookieManagerService::~GaiaCookieManagerService() { | 310 GaiaCookieManagerService::~GaiaCookieManagerService() { |
| 306 CancelAll(); | 311 CancelAll(); |
| 307 DCHECK(requests_.empty()); | 312 DCHECK(requests_.empty()); |
| 308 } | 313 } |
| 309 | 314 |
| 310 void GaiaCookieManagerService::Init() { | 315 void GaiaCookieManagerService::Init() { |
| 311 cookie_changed_subscription_ = signin_client_->AddCookieChangedCallback( | 316 cookie_changed_subscription_ = signin_client_->AddCookieChangedCallback( |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); | 752 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); |
| 748 VLOG(1) << "GaiaCookieManagerService::StartFetchingLogOut"; | 753 VLOG(1) << "GaiaCookieManagerService::StartFetchingLogOut"; |
| 749 gaia_auth_fetcher_.reset(signin_client_->CreateGaiaAuthFetcher( | 754 gaia_auth_fetcher_.reset(signin_client_->CreateGaiaAuthFetcher( |
| 750 this, GetSourceForRequest(requests_.front()), | 755 this, GetSourceForRequest(requests_.front()), |
| 751 signin_client_->GetURLRequestContext())); | 756 signin_client_->GetURLRequestContext())); |
| 752 gaia_auth_fetcher_->StartLogOut(); | 757 gaia_auth_fetcher_->StartLogOut(); |
| 753 } | 758 } |
| 754 | 759 |
| 755 void GaiaCookieManagerService::StartFetchingListAccounts() { | 760 void GaiaCookieManagerService::StartFetchingListAccounts() { |
| 756 VLOG(1) << "GaiaCookieManagerService::ListAccounts"; | 761 VLOG(1) << "GaiaCookieManagerService::ListAccounts"; |
| 762 | |
| 763 // Report the time since the profile was loaded and the number of this request | |
| 764 // in order to debug channel ID issues observed on Gaia. | |
| 765 static int32_t list_accounts_request_counter = 0; | |
|
Roger Tawa OOO till Jul 10th
2017/03/01 13:42:37
Should make this a member of the class. If you ha
msarda
2017/03/01 14:35:24
Done.
| |
| 766 std::string request_source = GetSourceForRequest(requests_.front()); | |
| 767 std::string source_with_debug_info = base::StringPrintf( | |
| 768 "%s,counter:%" PRId32 ",load_time_ms:%" PRId64, request_source.c_str(), | |
| 769 list_accounts_request_counter++, | |
| 770 (base::Time::Now() - profile_load_time_).InMilliseconds()); | |
| 771 | |
| 757 gaia_auth_fetcher_.reset(signin_client_->CreateGaiaAuthFetcher( | 772 gaia_auth_fetcher_.reset(signin_client_->CreateGaiaAuthFetcher( |
| 758 this, GetSourceForRequest(requests_.front()), | 773 this, source_with_debug_info, signin_client_->GetURLRequestContext())); |
| 759 signin_client_->GetURLRequestContext())); | |
| 760 gaia_auth_fetcher_->StartListAccounts(); | 774 gaia_auth_fetcher_->StartListAccounts(); |
| 761 } | 775 } |
| 762 | 776 |
| 763 void GaiaCookieManagerService::HandleNextRequest() { | 777 void GaiaCookieManagerService::HandleNextRequest() { |
| 764 VLOG(1) << "GaiaCookieManagerService::HandleNextRequest"; | 778 VLOG(1) << "GaiaCookieManagerService::HandleNextRequest"; |
| 765 if (requests_.front().request_type() == | 779 if (requests_.front().request_type() == |
| 766 GaiaCookieRequestType::LIST_ACCOUNTS) { | 780 GaiaCookieRequestType::LIST_ACCOUNTS) { |
| 767 // This and any directly subsequent list accounts would return the same. | 781 // This and any directly subsequent list accounts would return the same. |
| 768 while (!requests_.empty() && requests_.front().request_type() == | 782 while (!requests_.empty() && requests_.front().request_type() == |
| 769 GaiaCookieRequestType::LIST_ACCOUNTS) { | 783 GaiaCookieRequestType::LIST_ACCOUNTS) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 794 break; | 808 break; |
| 795 case GaiaCookieRequestType::LIST_ACCOUNTS: | 809 case GaiaCookieRequestType::LIST_ACCOUNTS: |
| 796 uber_token_fetcher_.reset(); | 810 uber_token_fetcher_.reset(); |
| 797 signin_client_->DelayNetworkCall( | 811 signin_client_->DelayNetworkCall( |
| 798 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, | 812 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, |
| 799 base::Unretained(this))); | 813 base::Unretained(this))); |
| 800 break; | 814 break; |
| 801 } | 815 } |
| 802 } | 816 } |
| 803 } | 817 } |
| OLD | NEW |