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 "chrome/browser/services/gcm/gcm_account_tracker.h" | 5 #include "chrome/browser/services/gcm/gcm_account_tracker.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 DCHECK(!callback_.is_null()); | 145 DCHECK(!callback_.is_null()); |
146 // Wait for gaia::AccountTracker to be done with fetching the user info, as | 146 // Wait for gaia::AccountTracker to be done with fetching the user info, as |
147 // well as all of the pending token requests from GCMAccountTracker to be done | 147 // well as all of the pending token requests from GCMAccountTracker to be done |
148 // before you report the results. | 148 // before you report the results. |
149 if (!account_tracker_->IsAllUserInfoFetched() || | 149 if (!account_tracker_->IsAllUserInfoFetched() || |
150 !pending_token_requests_.empty()) { | 150 !pending_token_requests_.empty()) { |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 bool account_removed = false; | 154 bool account_removed = false; |
155 std::map<std::string, std::string> account_tokens; | 155 std::vector<GCMClient::AccountTokenInfo> account_tokens; |
156 for (AccountInfos::iterator iter = account_infos_.begin(); | 156 for (AccountInfos::iterator iter = account_infos_.begin(); |
157 iter != account_infos_.end();) { | 157 iter != account_infos_.end();) { |
158 switch (iter->second.state) { | 158 switch (iter->second.state) { |
159 case ACCOUNT_REMOVED: | 159 case ACCOUNT_REMOVED: |
160 // We only mark accounts as removed when there was an account that was | 160 // We only mark accounts as removed when there was an account that was |
161 // explicitly signed out. | 161 // explicitly signed out. |
162 account_removed = true; | 162 account_removed = true; |
163 // We also stop tracking the account, now that it will be reported as | 163 // We also stop tracking the account, now that it will be reported as |
164 // removed. | 164 // removed. |
165 account_infos_.erase(iter++); | 165 account_infos_.erase(iter++); |
166 break; | 166 break; |
167 | 167 |
168 case TOKEN_PRESENT: | 168 case TOKEN_PRESENT: { |
169 account_tokens[iter->second.email] = iter->second.access_token; | 169 GCMClient::AccountTokenInfo token_info; |
| 170 token_info.account_id = iter->first; |
| 171 token_info.email = iter->second.email; |
| 172 token_info.access_token = iter->second.access_token; |
| 173 account_tokens.push_back(token_info); |
170 ++iter; | 174 ++iter; |
171 break; | 175 break; |
| 176 } |
172 | 177 |
173 case GETTING_TOKEN: | 178 case GETTING_TOKEN: |
174 // This should not happen, as we are making a check that there are no | 179 // This should not happen, as we are making a check that there are no |
175 // pending requests above. | 180 // pending requests above. |
176 NOTREACHED(); | 181 NOTREACHED(); |
177 ++iter; | 182 ++iter; |
178 break; | 183 break; |
179 | 184 |
180 case TOKEN_NEEDED: | 185 case TOKEN_NEEDED: |
181 // We failed to fetch an access token for the account, but it has not | 186 // We failed to fetch an access token for the account, but it has not |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 iter->second.state = ACCOUNT_REMOVED; | 255 iter->second.state = ACCOUNT_REMOVED; |
251 CompleteCollectingTokens(); | 256 CompleteCollectingTokens(); |
252 } | 257 } |
253 | 258 |
254 OAuth2TokenService* GCMAccountTracker::GetTokenService() { | 259 OAuth2TokenService* GCMAccountTracker::GetTokenService() { |
255 DCHECK(account_tracker_->identity_provider()); | 260 DCHECK(account_tracker_->identity_provider()); |
256 return account_tracker_->identity_provider()->GetTokenService(); | 261 return account_tracker_->identity_provider()->GetTokenService(); |
257 } | 262 } |
258 | 263 |
259 } // namespace gcm | 264 } // namespace gcm |
OLD | NEW |