OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/token_service.h" | 5 #include "chrome/browser/signin/token_service.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 | 202 |
203 bool TokenService::AreCredentialsValid() const { | 203 bool TokenService::AreCredentialsValid() const { |
204 return !credentials_.lsid.empty() && !credentials_.sid.empty(); | 204 return !credentials_.lsid.empty() && !credentials_.sid.empty(); |
205 } | 205 } |
206 | 206 |
207 void TokenService::StartFetchingTokens() { | 207 void TokenService::StartFetchingTokens() { |
208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
209 DCHECK(AreCredentialsValid()); | 209 DCHECK(AreCredentialsValid()); |
210 for (size_t i = 0; i < arraysize(kServices); i++) { | 210 for (size_t i = 0; i < arraysize(kServices); i++) { |
211 fetchers_[i].reset(new GaiaAuthFetcher(this, source_, getter_)); | 211 fetchers_[i].reset(new GaiaAuthFetcher(this, source_, getter_.get())); |
212 fetchers_[i]->StartIssueAuthToken(credentials_.sid, | 212 fetchers_[i]->StartIssueAuthToken(credentials_.sid, |
213 credentials_.lsid, | 213 credentials_.lsid, |
214 kServices[i]); | 214 kServices[i]); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 // Services dependent on a token will check if a token is available. | 218 // Services dependent on a token will check if a token is available. |
219 // If it isn't, they'll go to sleep until they get a token event. | 219 // If it isn't, they'll go to sleep until they get a token event. |
220 bool TokenService::HasTokenForService(const char* service) const { | 220 bool TokenService::HasTokenForService(const char* service) const { |
221 return token_map_.count(service) > 0; | 221 return token_map_.count(service) > 0; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 if (!in_memory_tokens->count(service) && db_tokens.count(service)) { | 427 if (!in_memory_tokens->count(service) && db_tokens.count(service)) { |
428 std::string db_token = db_tokens.find(service)->second; | 428 std::string db_token = db_tokens.find(service)->second; |
429 if (!db_token.empty()) { | 429 if (!db_token.empty()) { |
430 VLOG(1) << "Loading " << service << " token from DB: " << db_token; | 430 VLOG(1) << "Loading " << service << " token from DB: " << db_token; |
431 (*in_memory_tokens)[service] = db_token; | 431 (*in_memory_tokens)[service] = db_token; |
432 FireTokenAvailableNotification(service, db_token); | 432 FireTokenAvailableNotification(service, db_token); |
433 // Failures are only for network errors. | 433 // Failures are only for network errors. |
434 } | 434 } |
435 } | 435 } |
436 } | 436 } |
OLD | NEW |