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

Side by Side 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 after jianli's patch made it 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 unified diff | Download patch
OLDNEW
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 "google_apis/gaia/fake_oauth2_token_service.h" 5 #include "google_apis/gaia/fake_oauth2_token_service.h"
6 6
7 FakeOAuth2TokenService::PendingRequest::PendingRequest() { 7 FakeOAuth2TokenService::PendingRequest::PendingRequest() {
8 } 8 }
9 9
10 FakeOAuth2TokenService::PendingRequest::~PendingRequest() { 10 FakeOAuth2TokenService::PendingRequest::~PendingRequest() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 void FakeOAuth2TokenService::RemoveAccount(const std::string& account_id) { 60 void FakeOAuth2TokenService::RemoveAccount(const std::string& account_id) {
61 account_ids_.erase(account_id); 61 account_ids_.erase(account_id);
62 FireRefreshTokenRevoked(account_id); 62 FireRefreshTokenRevoked(account_id);
63 } 63 }
64 64
65 void FakeOAuth2TokenService::IssueAllTokensForAccount( 65 void FakeOAuth2TokenService::IssueAllTokensForAccount(
66 const std::string& account_id, 66 const std::string& account_id,
67 const std::string& access_token, 67 const std::string& access_token,
68 const base::Time& expiration) { 68 const base::Time& expiration) {
69
70 // Walk the requests and notify the callbacks. 69 // Walk the requests and notify the callbacks.
71 for (std::vector<PendingRequest>::iterator it = pending_requests_.begin(); 70 std::vector<PendingRequest> pending_requests_copy = pending_requests_;
72 it != pending_requests_.end(); ++it) { 71 for (std::vector<PendingRequest>::iterator it = pending_requests_copy.begin();
72 it != pending_requests_copy.end();
73 ++it) {
73 if (it->request && (account_id == it->account_id)) { 74 if (it->request && (account_id == it->account_id)) {
74 it->request->InformConsumer( 75 it->request->InformConsumer(
75 GoogleServiceAuthError::AuthErrorNone(), access_token, expiration); 76 GoogleServiceAuthError::AuthErrorNone(), access_token, expiration);
76 } 77 }
77 } 78 }
78 } 79 }
79 80
80 void FakeOAuth2TokenService::IssueErrorForAllPendingRequestsForAccount( 81 void FakeOAuth2TokenService::IssueErrorForAllPendingRequestsForAccount(
81 const std::string& account_id, 82 const std::string& account_id,
82 const GoogleServiceAuthError& auth_error) { 83 const GoogleServiceAuthError& auth_error) {
83 // Walk the requests and notify the callbacks. 84 // Walk the requests and notify the callbacks.
84 for (std::vector<PendingRequest>::iterator it = pending_requests_.begin(); 85 // Using a copy to make sure retyring a request does not cause a stack when
Nicolas Zea 2014/10/08 00:36:35 nit: retyring -> retrying cause a stack -> cause a
fgorski 2014/10/08 18:04:28 Done.
85 it != pending_requests_.end(); 86 // incrementing the iterator.
87 std::vector<PendingRequest> pending_requests_copy = pending_requests_;
88 for (std::vector<PendingRequest>::iterator it = pending_requests_copy.begin();
89 it != pending_requests_copy.end();
86 ++it) { 90 ++it) {
87 if (it->request && (account_id == it->account_id)) { 91 if (it->request && (account_id == it->account_id)) {
88 it->request->InformConsumer(auth_error, std::string(), base::Time()); 92 it->request->InformConsumer(auth_error, std::string(), base::Time());
89 } 93 }
90 } 94 }
91 } 95 }
92 96
93 OAuth2AccessTokenFetcher* FakeOAuth2TokenService::CreateAccessTokenFetcher( 97 OAuth2AccessTokenFetcher* FakeOAuth2TokenService::CreateAccessTokenFetcher(
94 const std::string& account_id, 98 const std::string& account_id,
95 net::URLRequestContextGetter* getter, 99 net::URLRequestContextGetter* getter,
96 OAuth2AccessTokenConsumer* consumer) { 100 OAuth2AccessTokenConsumer* consumer) {
97 // |FakeOAuth2TokenService| overrides |FetchOAuth2Token| and thus 101 // |FakeOAuth2TokenService| overrides |FetchOAuth2Token| and thus
98 // |CreateAccessTokenFetcher| should never be called. 102 // |CreateAccessTokenFetcher| should never be called.
99 NOTREACHED(); 103 NOTREACHED();
100 return NULL; 104 return NULL;
101 } 105 }
OLDNEW
« components/gcm_driver/gcm_account_mapper.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