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 439 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 net::URLFetcher* fetcher = | 460 logout_url_request_.reset( |
461 net::URLFetcher::Create(logout_url, net::URLFetcher::GET, this); | 461 net::URLFetcher::Create(logout_url, net::URLFetcher::GET, this)); |
462 fetcher->SetRequestContext(signin_client_->GetURLRequestContext()); | 462 logout_url_request_->SetRequestContext( |
463 fetcher->Start(); | 463 signin_client_->GetURLRequestContext()); |
| 464 logout_url_request_->Start(); |
464 } | 465 } |
465 | 466 |
466 void GaiaCookieManagerService::OnUbertokenSuccess( | 467 void GaiaCookieManagerService::OnUbertokenSuccess( |
467 const std::string& uber_token) { | 468 const std::string& uber_token) { |
468 DCHECK(requests_.front().request_type() == | 469 DCHECK(requests_.front().request_type() == |
469 GaiaCookieRequestType::ADD_ACCOUNT); | 470 GaiaCookieRequestType::ADD_ACCOUNT); |
470 VLOG(1) << "GaiaCookieManagerService::OnUbertokenSuccess" | 471 VLOG(1) << "GaiaCookieManagerService::OnUbertokenSuccess" |
471 << " account=" << requests_.front().account_id(); | 472 << " account=" << requests_.front().account_id(); |
472 fetcher_retries_ = 0; | 473 fetcher_retries_ = 0; |
473 uber_token_ = uber_token; | 474 uber_token_ = uber_token; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 gaia_auth_fetcher_.reset( | 590 gaia_auth_fetcher_.reset( |
590 new GaiaAuthFetcher(this, source_, | 591 new GaiaAuthFetcher(this, source_, |
591 signin_client_->GetURLRequestContext())); | 592 signin_client_->GetURLRequestContext())); |
592 gaia_auth_fetcher_->StartListAccounts(); | 593 gaia_auth_fetcher_->StartListAccounts(); |
593 } | 594 } |
594 | 595 |
595 void GaiaCookieManagerService::OnURLFetchComplete( | 596 void GaiaCookieManagerService::OnURLFetchComplete( |
596 const net::URLFetcher* source) { | 597 const net::URLFetcher* source) { |
597 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); | 598 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); |
598 VLOG(1) << "GaiaCookieManagerService::OnURLFetchComplete"; | 599 VLOG(1) << "GaiaCookieManagerService::OnURLFetchComplete"; |
| 600 scoped_ptr<net::URLFetcher> logout_url_request(logout_url_request_.Pass()); |
599 | 601 |
600 if ((!source->GetStatus().is_success() || | 602 if ((!source->GetStatus().is_success() || |
601 source->GetResponseCode() != net::HTTP_OK) && | 603 source->GetResponseCode() != net::HTTP_OK) && |
602 ++fetcher_retries_ < kMaxFetcherRetries) { | 604 ++fetcher_retries_ < kMaxFetcherRetries) { |
603 fetcher_backoff_.InformOfRequest(false); | 605 fetcher_backoff_.InformOfRequest(false); |
604 fetcher_timer_.Start( | 606 fetcher_timer_.Start( |
605 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), this, | 607 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), this, |
606 &GaiaCookieManagerService::StartLogOutUrlFetch); | 608 &GaiaCookieManagerService::StartLogOutUrlFetch); |
607 return; | 609 return; |
608 } | 610 } |
(...skipping 29 matching lines...) Expand all Loading... |
638 case GaiaCookieRequestType::LOG_OUT: | 640 case GaiaCookieRequestType::LOG_OUT: |
639 StartLogOutUrlFetch(); | 641 StartLogOutUrlFetch(); |
640 break; | 642 break; |
641 case GaiaCookieRequestType::LIST_ACCOUNTS: | 643 case GaiaCookieRequestType::LIST_ACCOUNTS: |
642 uber_token_fetcher_.reset(); | 644 uber_token_fetcher_.reset(); |
643 StartFetchingListAccounts(); | 645 StartFetchingListAccounts(); |
644 break; | 646 break; |
645 }; | 647 }; |
646 } | 648 } |
647 } | 649 } |
OLD | NEW |