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

Unified Diff: google_apis/gaia/fake_oauth2_token_service.cc

Issue 618003002: [GCM] Handling connection events in GCMAccountTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to Jian Li's patch and addressing unit tests failures Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: google_apis/gaia/fake_oauth2_token_service.cc
diff --git a/google_apis/gaia/fake_oauth2_token_service.cc b/google_apis/gaia/fake_oauth2_token_service.cc
index 44722dd2dd3618ec9c22f3422c3d6abe01ef31cd..bd53cddad6eb9a4c26828bfc201c76aab4bd5c34 100644
--- a/google_apis/gaia/fake_oauth2_token_service.cc
+++ b/google_apis/gaia/fake_oauth2_token_service.cc
@@ -66,10 +66,11 @@ void FakeOAuth2TokenService::IssueAllTokensForAccount(
const std::string& account_id,
const std::string& access_token,
const base::Time& expiration) {
-
// Walk the requests and notify the callbacks.
- for (std::vector<PendingRequest>::iterator it = pending_requests_.begin();
- it != pending_requests_.end(); ++it) {
+ std::vector<PendingRequest> pending_requests_copy = pending_requests_;
+ for (std::vector<PendingRequest>::iterator it = pending_requests_copy.begin();
+ it != pending_requests_copy.end();
+ ++it) {
if (it->request && (account_id == it->account_id)) {
it->request->InformConsumer(
GoogleServiceAuthError::AuthErrorNone(), access_token, expiration);
@@ -81,8 +82,11 @@ void FakeOAuth2TokenService::IssueErrorForAllPendingRequestsForAccount(
const std::string& account_id,
const GoogleServiceAuthError& auth_error) {
// Walk the requests and notify the callbacks.
- for (std::vector<PendingRequest>::iterator it = pending_requests_.begin();
- it != pending_requests_.end();
+ // Using a copy to make sure retyring a request does not cause a stack when
+ // incrementing the iterator.
+ std::vector<PendingRequest> pending_requests_copy = pending_requests_;
+ for (std::vector<PendingRequest>::iterator it = pending_requests_copy.begin();
+ it != pending_requests_copy.end();
++it) {
if (it->request && (account_id == it->account_id)) {
it->request->InformConsumer(auth_error, std::string(), base::Time());
« components/gcm_driver/gcm_driver.cc ('K') | « components/gcm_driver/gcm_driver_desktop.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698