OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/signin/profile_oauth2_token_service.h" | 5 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 void ProfileOAuth2TokenService::UpdateAuthError( | 140 void ProfileOAuth2TokenService::UpdateAuthError( |
141 const std::string& account_id, | 141 const std::string& account_id, |
142 const GoogleServiceAuthError& error) { | 142 const GoogleServiceAuthError& error) { |
143 // Do not report connection errors as these are not actually auth errors. | 143 // Do not report connection errors as these are not actually auth errors. |
144 // We also want to avoid masking a "real" auth error just because we | 144 // We also want to avoid masking a "real" auth error just because we |
145 // subsequently get a transient network error. | 145 // subsequently get a transient network error. |
146 if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED) | 146 if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED) |
147 return; | 147 return; |
148 | 148 |
149 DCHECK_GT(refresh_tokens_.count(account_id), 0u); | 149 if (refresh_tokens_.count(account_id) == 0) { |
| 150 // This could happen if the preferences have been corrupted (see |
| 151 // http://crbug.com/321370). In a Debug build that would be a bug, but in a |
| 152 // Release build we want to deal with it gracefully. |
| 153 NOTREACHED(); |
| 154 return; |
| 155 } |
150 refresh_tokens_[account_id]->SetLastAuthError(error); | 156 refresh_tokens_[account_id]->SetLastAuthError(error); |
151 } | 157 } |
152 | 158 |
153 void ProfileOAuth2TokenService::Observe( | 159 void ProfileOAuth2TokenService::Observe( |
154 int type, | 160 int type, |
155 const content::NotificationSource& source, | 161 const content::NotificationSource& source, |
156 const content::NotificationDetails& details) { | 162 const content::NotificationDetails& details) { |
157 const std::string& account_id = GetPrimaryAccountId(); | 163 const std::string& account_id = GetPrimaryAccountId(); |
158 switch (type) { | 164 switch (type) { |
159 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { | 165 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 374 } |
369 } | 375 } |
370 | 376 |
371 if (!old_login_token.empty() && | 377 if (!old_login_token.empty() && |
372 refresh_tokens_.count(GetPrimaryAccountId()) == 0) { | 378 refresh_tokens_.count(GetPrimaryAccountId()) == 0) { |
373 UpdateCredentials(GetPrimaryAccountId(), old_login_token); | 379 UpdateCredentials(GetPrimaryAccountId(), old_login_token); |
374 } | 380 } |
375 | 381 |
376 FireRefreshTokensLoaded(); | 382 FireRefreshTokensLoaded(); |
377 } | 383 } |
OLD | NEW |