Index: components/signin/core/browser/gaia_cookie_manager_service.cc |
diff --git a/components/signin/core/browser/gaia_cookie_manager_service.cc b/components/signin/core/browser/gaia_cookie_manager_service.cc |
index dcc74aefbeeb8347f378533f0793128ffcecea8d..b0b86971cc64cf709d525fe5246c644ac034d088 100644 |
--- a/components/signin/core/browser/gaia_cookie_manager_service.cc |
+++ b/components/signin/core/browser/gaia_cookie_manager_service.cc |
@@ -427,40 +427,22 @@ void GaiaCookieManagerService::CancelAll() { |
fetcher_timer_.Stop(); |
} |
-// It is unknown if the cookie was changed because of processing initiated by |
-// this class or other (such as the user clearing all cookies or a cookie being |
-// evicted). |
void GaiaCookieManagerService::OnCookieChanged( |
const net::CanonicalCookie& cookie, |
bool removed) { |
DCHECK_EQ("APISID", cookie.Name()); |
DCHECK_EQ(GaiaUrls::GetInstance()->google_url().host(), cookie.Domain()); |
+ // Ignore changes to the cookie while requests are pending. These changes |
+ // are caused by the service itself as it adds accounts. A side effects is |
+ // that any changes to the gaia cookie outside of this class, while requests |
+ // are pending, will be lost. However, trying to process these changes could |
+ // cause an endless loop (see crbug.com/516070). |
if (requests_.empty()) { |
requests_.push_back(GaiaCookieRequest::CreateListAccountsRequest()); |
fetcher_retries_ = 0; |
signin_client_->DelayNetworkCall( |
base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, |
base::Unretained(this))); |
- } else { |
- // Remove all pending ListAccount calls; for efficiency, only call |
- // after all pending requests are processed. |
- // Track requests to keep; all other unstarted requests will be removed. |
- std::vector<GaiaCookieRequest> requests_to_keep; |
- |
- // Check all pending, non-executing requests. |
- for (auto it = requests_.begin() + 1; it != requests_.end(); ++it) { |
- // Keep all requests except for LIST_ACCOUNTS. |
- if (it->request_type() != GaiaCookieRequestType::LIST_ACCOUNTS) |
- requests_to_keep.push_back(*it); |
- } |
- |
- // Remove all but the executing request. Re-add all requests being kept. |
- if (requests_.size() > 1) { |
- requests_.erase(requests_.begin() + 1, requests_.end()); |
- requests_.insert( |
- requests_.end(), requests_to_keep.begin(), requests_to_keep.end()); |
- } |
- requests_.push_back(GaiaCookieRequest::CreateListAccountsRequest()); |
} |
} |