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 <queue> | 7 #include <queue> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 // Start a fetcher for each connection URL that needs to be checked. | 170 // Start a fetcher for each connection URL that needs to be checked. |
171 for (size_t i = 0; i < list->GetSize(); ++i) { | 171 for (size_t i = 0; i < list->GetSize(); ++i) { |
172 const base::DictionaryValue* dict; | 172 const base::DictionaryValue* dict; |
173 if (list->GetDictionary(i, &dict)) { | 173 if (list->GetDictionary(i, &dict)) { |
174 std::string token; | 174 std::string token; |
175 std::string url; | 175 std::string url; |
176 if (dict->GetString("carryBackToken", &token) && | 176 if (dict->GetString("carryBackToken", &token) && |
177 dict->GetString("url", &url)) { | 177 dict->GetString("url", &url)) { |
178 results_[token] = "null"; | 178 results_[token] = "null"; |
179 net::URLFetcher* fetcher = CreateFetcher(GURL(url)); | 179 net::URLFetcher* fetcher = CreateFetcher(GURL(url)).release(); |
180 fetchers_[fetcher->GetOriginalURL()] = std::make_pair(token, fetcher); | 180 fetchers_[fetcher->GetOriginalURL()] = std::make_pair(token, fetcher); |
181 fetcher->Start(); | 181 fetcher->Start(); |
182 } | 182 } |
183 } | 183 } |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 void GaiaCookieManagerService::ExternalCcResultFetcher:: | 187 void GaiaCookieManagerService::ExternalCcResultFetcher:: |
188 OnGetCheckConnectionInfoError(const GoogleServiceAuthError& error) { | 188 OnGetCheckConnectionInfoError(const GoogleServiceAuthError& error) { |
189 if (++helper_->fetcher_retries_ < kMaxFetcherRetries && | 189 if (++helper_->fetcher_retries_ < kMaxFetcherRetries && |
190 IsTransientError(error)) { | 190 IsTransientError(error)) { |
191 helper_->fetcher_backoff_.InformOfRequest(false); | 191 helper_->fetcher_backoff_.InformOfRequest(false); |
192 gaia_auth_fetcher_timer_.Start( | 192 gaia_auth_fetcher_timer_.Start( |
193 FROM_HERE, helper_->fetcher_backoff_.GetTimeUntilRelease(), | 193 FROM_HERE, helper_->fetcher_backoff_.GetTimeUntilRelease(), |
194 this, &GaiaCookieManagerService::ExternalCcResultFetcher::Start); | 194 this, &GaiaCookieManagerService::ExternalCcResultFetcher::Start); |
195 return; | 195 return; |
196 } | 196 } |
197 | 197 |
198 CleanupTransientState(); | 198 CleanupTransientState(); |
199 GetCheckConnectionInfoCompleted(false); | 199 GetCheckConnectionInfoCompleted(false); |
200 } | 200 } |
201 | 201 |
202 net::URLFetcher* | 202 scoped_ptr<net::URLFetcher> |
203 GaiaCookieManagerService::ExternalCcResultFetcher::CreateFetcher( | 203 GaiaCookieManagerService::ExternalCcResultFetcher::CreateFetcher( |
204 const GURL& url) { | 204 const GURL& url) { |
205 net::URLFetcher* fetcher = | 205 scoped_ptr<net::URLFetcher> fetcher = |
206 net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); | 206 net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); |
207 fetcher->SetRequestContext(helper_->request_context()); | 207 fetcher->SetRequestContext(helper_->request_context()); |
208 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 208 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
209 net::LOAD_DO_NOT_SAVE_COOKIES); | 209 net::LOAD_DO_NOT_SAVE_COOKIES); |
210 | 210 |
211 // Fetchers are sometimes cancelled because a network change was detected, | 211 // Fetchers are sometimes cancelled because a network change was detected, |
212 // especially at startup and after sign-in on ChromeOS. | 212 // especially at startup and after sign-in on ChromeOS. |
213 fetcher->SetAutomaticallyRetryOnNetworkChanges(1); | 213 fetcher->SetAutomaticallyRetryOnNetworkChanges(1); |
214 return fetcher; | 214 return fetcher; |
215 } | 215 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // be the last call in any other method. | 450 // be the last call in any other method. |
451 FOR_EACH_OBSERVER(Observer, observer_list_, | 451 FOR_EACH_OBSERVER(Observer, observer_list_, |
452 OnAddAccountToCookieCompleted(account_id, error)); | 452 OnAddAccountToCookieCompleted(account_id, error)); |
453 } | 453 } |
454 | 454 |
455 void GaiaCookieManagerService::StartLogOutUrlFetch() { | 455 void GaiaCookieManagerService::StartLogOutUrlFetch() { |
456 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); | 456 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); |
457 VLOG(1) << "GaiaCookieManagerService::StartLogOutUrlFetch"; | 457 VLOG(1) << "GaiaCookieManagerService::StartLogOutUrlFetch"; |
458 GURL logout_url(GaiaUrls::GetInstance()->service_logout_url().Resolve( | 458 GURL logout_url(GaiaUrls::GetInstance()->service_logout_url().Resolve( |
459 base::StringPrintf("?source=%s", source_.c_str()))); | 459 base::StringPrintf("?source=%s", source_.c_str()))); |
460 logout_url_request_.reset( | 460 logout_url_request_ = |
461 net::URLFetcher::Create(logout_url, net::URLFetcher::GET, this)); | 461 net::URLFetcher::Create(logout_url, net::URLFetcher::GET, this); |
462 logout_url_request_->SetRequestContext( | 462 logout_url_request_->SetRequestContext( |
463 signin_client_->GetURLRequestContext()); | 463 signin_client_->GetURLRequestContext()); |
464 logout_url_request_->Start(); | 464 logout_url_request_->Start(); |
465 } | 465 } |
466 | 466 |
467 void GaiaCookieManagerService::OnUbertokenSuccess( | 467 void GaiaCookieManagerService::OnUbertokenSuccess( |
468 const std::string& uber_token) { | 468 const std::string& uber_token) { |
469 DCHECK(requests_.front().request_type() == | 469 DCHECK(requests_.front().request_type() == |
470 GaiaCookieRequestType::ADD_ACCOUNT); | 470 GaiaCookieRequestType::ADD_ACCOUNT); |
471 VLOG(1) << "GaiaCookieManagerService::OnUbertokenSuccess" | 471 VLOG(1) << "GaiaCookieManagerService::OnUbertokenSuccess" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 case GaiaCookieRequestType::LOG_OUT: | 640 case GaiaCookieRequestType::LOG_OUT: |
641 StartLogOutUrlFetch(); | 641 StartLogOutUrlFetch(); |
642 break; | 642 break; |
643 case GaiaCookieRequestType::LIST_ACCOUNTS: | 643 case GaiaCookieRequestType::LIST_ACCOUNTS: |
644 uber_token_fetcher_.reset(); | 644 uber_token_fetcher_.reset(); |
645 StartFetchingListAccounts(); | 645 StartFetchingListAccounts(); |
646 break; | 646 break; |
647 }; | 647 }; |
648 } | 648 } |
649 } | 649 } |
OLD | NEW |