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 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 DCHECK(!helper_->external_cc_result_fetched_); | |
| 133 m_external_cc_result_start_time_ = base::Time::Now(); | 134 m_external_cc_result_start_time_ = base::Time::Now(); |
| 134 | 135 |
| 135 CleanupTransientState(); | 136 CleanupTransientState(); |
| 136 results_.clear(); | 137 results_.clear(); |
| 137 helper_->gaia_auth_fetcher_.reset( | 138 helper_->gaia_auth_fetcher_.reset( |
| 138 helper_->signin_client_->CreateGaiaAuthFetcher( | 139 helper_->signin_client_->CreateGaiaAuthFetcher( |
| 139 this, helper_->GetDefaultSourceForRequest(), | 140 this, helper_->GetDefaultSourceForRequest(), |
| 140 helper_->request_context())); | 141 helper_->request_context())); |
| 141 helper_->gaia_auth_fetcher_->StartGetCheckConnectionInfo(); | 142 helper_->gaia_auth_fetcher_->StartGetCheckConnectionInfo(); |
| 142 | 143 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 net::URLFetcher* fetcher = CreateFetcher(GURL(url)).release(); | 189 net::URLFetcher* fetcher = CreateFetcher(GURL(url)).release(); |
| 189 fetchers_[fetcher->GetOriginalURL()] = std::make_pair(token, fetcher); | 190 fetchers_[fetcher->GetOriginalURL()] = std::make_pair(token, fetcher); |
| 190 fetcher->Start(); | 191 fetcher->Start(); |
| 191 } | 192 } |
| 192 } | 193 } |
| 193 } | 194 } |
| 194 } | 195 } |
| 195 | 196 |
| 196 void GaiaCookieManagerService::ExternalCcResultFetcher:: | 197 void GaiaCookieManagerService::ExternalCcResultFetcher:: |
| 197 OnGetCheckConnectionInfoError(const GoogleServiceAuthError& error) { | 198 OnGetCheckConnectionInfoError(const GoogleServiceAuthError& error) { |
| 199 CleanupTransientState(); | |
| 200 | |
|
Roger Tawa OOO till Jul 10th
2017/02/24 17:20:15
I would leave the call to CleanupTransientState()
msarda
2017/03/03 14:25:00
I guess it all depends on what we want the behavio
| |
| 198 if (++helper_->fetcher_retries_ < kMaxFetcherRetries && | 201 if (++helper_->fetcher_retries_ < kMaxFetcherRetries && |
| 199 error.IsTransientError()) { | 202 error.IsTransientError()) { |
| 200 helper_->fetcher_backoff_.InformOfRequest(false); | 203 helper_->fetcher_backoff_.InformOfRequest(false); |
| 201 gaia_auth_fetcher_timer_.Start( | 204 gaia_auth_fetcher_timer_.Start( |
| 202 FROM_HERE, helper_->fetcher_backoff_.GetTimeUntilRelease(), | 205 FROM_HERE, helper_->fetcher_backoff_.GetTimeUntilRelease(), |
| 203 this, &GaiaCookieManagerService::ExternalCcResultFetcher::Start); | 206 this, &GaiaCookieManagerService::ExternalCcResultFetcher::Start); |
| 204 return; | 207 return; |
| 205 } | 208 } |
| 206 | 209 |
| 207 CleanupTransientState(); | |
| 208 GetCheckConnectionInfoCompleted(false); | 210 GetCheckConnectionInfoCompleted(false); |
| 209 } | 211 } |
| 210 | 212 |
| 211 std::unique_ptr<net::URLFetcher> | 213 std::unique_ptr<net::URLFetcher> |
| 212 GaiaCookieManagerService::ExternalCcResultFetcher::CreateFetcher( | 214 GaiaCookieManagerService::ExternalCcResultFetcher::CreateFetcher( |
| 213 const GURL& url) { | 215 const GURL& url) { |
| 214 std::unique_ptr<net::URLFetcher> fetcher = | 216 std::unique_ptr<net::URLFetcher> fetcher = |
| 215 net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); | 217 net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); |
| 216 fetcher->SetRequestContext(helper_->request_context()); | 218 fetcher->SetRequestContext(helper_->request_context()); |
| 217 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 219 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 } | 258 } |
| 257 | 259 |
| 258 void GaiaCookieManagerService::ExternalCcResultFetcher::Timeout() { | 260 void GaiaCookieManagerService::ExternalCcResultFetcher::Timeout() { |
| 259 CleanupTransientState(); | 261 CleanupTransientState(); |
| 260 GetCheckConnectionInfoCompleted(false); | 262 GetCheckConnectionInfoCompleted(false); |
| 261 } | 263 } |
| 262 | 264 |
| 263 void GaiaCookieManagerService::ExternalCcResultFetcher:: | 265 void GaiaCookieManagerService::ExternalCcResultFetcher:: |
| 264 CleanupTransientState() { | 266 CleanupTransientState() { |
| 265 timer_.Stop(); | 267 timer_.Stop(); |
| 266 helper_->gaia_auth_fetcher_.reset(); | 268 helper_->gaia_auth_fetcher_.reset(); |
|
Roger Tawa OOO till Jul 10th
2017/02/24 17:20:15
Also stop |gaia_auth_fetcher_timer_|.
msarda
2017/03/03 14:25:00
Done.
| |
| 267 | 269 |
| 268 for (URLToTokenAndFetcher::const_iterator it = fetchers_.begin(); | 270 for (URLToTokenAndFetcher::const_iterator it = fetchers_.begin(); |
| 269 it != fetchers_.end(); ++it) { | 271 it != fetchers_.end(); ++it) { |
| 270 delete it->second.second; | 272 delete it->second.second; |
| 271 } | 273 } |
| 272 fetchers_.clear(); | 274 fetchers_.clear(); |
| 273 } | 275 } |
| 274 | 276 |
| 275 void GaiaCookieManagerService::ExternalCcResultFetcher:: | 277 void GaiaCookieManagerService::ExternalCcResultFetcher:: |
| 276 GetCheckConnectionInfoCompleted(bool succeeded) { | 278 GetCheckConnectionInfoCompleted(bool succeeded) { |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 794 break; | 796 break; |
| 795 case GaiaCookieRequestType::LIST_ACCOUNTS: | 797 case GaiaCookieRequestType::LIST_ACCOUNTS: |
| 796 uber_token_fetcher_.reset(); | 798 uber_token_fetcher_.reset(); |
| 797 signin_client_->DelayNetworkCall( | 799 signin_client_->DelayNetworkCall( |
| 798 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, | 800 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, |
| 799 base::Unretained(this))); | 801 base::Unretained(this))); |
| 800 break; | 802 break; |
| 801 } | 803 } |
| 802 } | 804 } |
| 803 } | 805 } |
| OLD | NEW |