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

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

Issue 2704403002: Avoid re-starting a ExternalCCResultFetcher if a previous has finished or timed out. (Closed)
Patch Set: Do not start the externalt CC result fetcher if it already finished. Created 3 years, 10 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
« no previous file with comments | « no previous file | ios/chrome/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 GaiaCookieManagerService::ExternalCcResultFetcher::GetExternalCcResult() { 123 GaiaCookieManagerService::ExternalCcResultFetcher::GetExternalCcResult() {
124 std::vector<std::string> results; 124 std::vector<std::string> results;
125 for (ResultMap::const_iterator it = results_.begin(); it != results_.end(); 125 for (ResultMap::const_iterator it = results_.begin(); it != results_.end();
126 ++it) { 126 ++it) {
127 results.push_back(it->first + ":" + it->second); 127 results.push_back(it->first + ":" + it->second);
128 } 128 }
129 return base::JoinString(results, ","); 129 return base::JoinString(results, ",");
130 } 130 }
131 131
132 void GaiaCookieManagerService::ExternalCcResultFetcher::Start() { 132 void GaiaCookieManagerService::ExternalCcResultFetcher::Start() {
133 if (helper_->external_cc_result_fetched_) {
134 // Avoid starting a net fetcher if the the external CC result was already
135 // marked as fetched.
136 // This matches the case when |timer_| has already fired and the external CC
137 // result was already marked as fetched.
138 return;
139 }
140
Roger Tawa OOO till Jul 10th 2017/02/23 19:00:00 This method is only called at one place, line 568
msarda 2017/02/24 12:53:40 I've added this DCHECK and it fires. Here is the l
133 m_external_cc_result_start_time_ = base::Time::Now(); 141 m_external_cc_result_start_time_ = base::Time::Now();
134 142
135 CleanupTransientState(); 143 CleanupTransientState();
136 results_.clear(); 144 results_.clear();
137 helper_->gaia_auth_fetcher_.reset( 145 helper_->gaia_auth_fetcher_.reset(
138 helper_->signin_client_->CreateGaiaAuthFetcher( 146 helper_->signin_client_->CreateGaiaAuthFetcher(
139 this, helper_->GetDefaultSourceForRequest(), 147 this, helper_->GetDefaultSourceForRequest(),
140 helper_->request_context())); 148 helper_->request_context()));
141 helper_->gaia_auth_fetcher_->StartGetCheckConnectionInfo(); 149 helper_->gaia_auth_fetcher_->StartGetCheckConnectionInfo();
142 150
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 net::URLFetcher* fetcher = CreateFetcher(GURL(url)).release(); 196 net::URLFetcher* fetcher = CreateFetcher(GURL(url)).release();
189 fetchers_[fetcher->GetOriginalURL()] = std::make_pair(token, fetcher); 197 fetchers_[fetcher->GetOriginalURL()] = std::make_pair(token, fetcher);
190 fetcher->Start(); 198 fetcher->Start();
191 } 199 }
192 } 200 }
193 } 201 }
194 } 202 }
195 203
196 void GaiaCookieManagerService::ExternalCcResultFetcher:: 204 void GaiaCookieManagerService::ExternalCcResultFetcher::
197 OnGetCheckConnectionInfoError(const GoogleServiceAuthError& error) { 205 OnGetCheckConnectionInfoError(const GoogleServiceAuthError& error) {
206 if (helper_->external_cc_result_fetched_) {
207 // Nothing else to do if the timer has already fired and the external CC
208 // result was already marked as fetched.
209 return;
210 }
211
Roger Tawa OOO till Jul 10th 2017/02/23 19:00:00 If the timer already fired, CleanupTransientState(
msarda 2017/02/24 12:53:40 See comment above.
198 if (++helper_->fetcher_retries_ < kMaxFetcherRetries && 212 if (++helper_->fetcher_retries_ < kMaxFetcherRetries &&
199 error.IsTransientError()) { 213 error.IsTransientError()) {
200 helper_->fetcher_backoff_.InformOfRequest(false); 214 helper_->fetcher_backoff_.InformOfRequest(false);
201 gaia_auth_fetcher_timer_.Start( 215 gaia_auth_fetcher_timer_.Start(
202 FROM_HERE, helper_->fetcher_backoff_.GetTimeUntilRelease(), 216 FROM_HERE, helper_->fetcher_backoff_.GetTimeUntilRelease(),
203 this, &GaiaCookieManagerService::ExternalCcResultFetcher::Start); 217 this, &GaiaCookieManagerService::ExternalCcResultFetcher::Start);
204 return; 218 return;
205 } 219 }
206 220
207 CleanupTransientState(); 221 CleanupTransientState();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 287 }
274 288
275 void GaiaCookieManagerService::ExternalCcResultFetcher:: 289 void GaiaCookieManagerService::ExternalCcResultFetcher::
276 GetCheckConnectionInfoCompleted(bool succeeded) { 290 GetCheckConnectionInfoCompleted(bool succeeded) {
277 base::TimeDelta time_to_check_connections = 291 base::TimeDelta time_to_check_connections =
278 base::Time::Now() - m_external_cc_result_start_time_; 292 base::Time::Now() - m_external_cc_result_start_time_;
279 signin_metrics::LogExternalCcResultFetches(succeeded, 293 signin_metrics::LogExternalCcResultFetches(succeeded,
280 time_to_check_connections); 294 time_to_check_connections);
281 295
282 helper_->external_cc_result_fetched_ = true; 296 helper_->external_cc_result_fetched_ = true;
283 // Since the ExternalCCResultFetcher is only Started in place of calling
284 // StartFetchingMergeSession, we can assume we need to call
285 // StartFetchingMergeSession. If this assumption becomes invalid, a Callback
286 // will need to be passed to Start() and Run() here.
Roger Tawa OOO till Jul 10th 2017/02/23 19:00:00 I think this comment is still valid. Is there a r
msarda 2017/02/24 12:53:40 Fixed.
287 helper_->StartFetchingMergeSession(); 297 helper_->StartFetchingMergeSession();
288 } 298 }
289 299
290 GaiaCookieManagerService::GaiaCookieManagerService( 300 GaiaCookieManagerService::GaiaCookieManagerService(
291 OAuth2TokenService* token_service, 301 OAuth2TokenService* token_service,
292 const std::string& source, 302 const std::string& source,
293 SigninClient* signin_client) 303 SigninClient* signin_client)
294 : token_service_(token_service), 304 : token_service_(token_service),
295 signin_client_(signin_client), 305 signin_client_(signin_client),
296 external_cc_result_fetcher_(this), 306 external_cc_result_fetcher_(this),
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 break; 804 break;
795 case GaiaCookieRequestType::LIST_ACCOUNTS: 805 case GaiaCookieRequestType::LIST_ACCOUNTS:
796 uber_token_fetcher_.reset(); 806 uber_token_fetcher_.reset();
797 signin_client_->DelayNetworkCall( 807 signin_client_->DelayNetworkCall(
798 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, 808 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts,
799 base::Unretained(this))); 809 base::Unretained(this)));
800 break; 810 break;
801 } 811 }
802 } 812 }
803 } 813 }
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698