Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/oauth2_token_service.h" | 5 #include "chrome/browser/signin/oauth2_token_service.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 return NULL; | 433 return NULL; |
| 434 } | 434 } |
| 435 return &token_iterator->second; | 435 return &token_iterator->second; |
| 436 } | 436 } |
| 437 | 437 |
| 438 bool OAuth2TokenService::RemoveCacheEntry( | 438 bool OAuth2TokenService::RemoveCacheEntry( |
| 439 const OAuth2TokenService::ScopeSet& scopes, | 439 const OAuth2TokenService::ScopeSet& scopes, |
| 440 const std::string& token_to_remove) { | 440 const std::string& token_to_remove) { |
| 441 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 441 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 442 TokenCache::iterator token_iterator = token_cache_.find(scopes); | 442 TokenCache::iterator token_iterator = token_cache_.find(scopes); |
| 443 if (token_iterator == token_cache_.end() && | 443 if (token_iterator != token_cache_.end() && |
|
tim (not reviewing)
2013/05/23 19:03:41
I guess this wasn't being used very commonly?
Andrew T Wilson (Slow)
2013/05/24 14:10:15
I guess not. It's mostly an optimization anyway (i
pavely
2013/05/30 07:42:12
If server returns AUTH_ERROR before token expires
Andrew T Wilson (Slow)
2013/05/31 12:57:28
Yes. Since every token in OAuth2TokenService has a
| |
| 444 token_iterator->second.access_token == token_to_remove) { | 444 token_iterator->second.access_token == token_to_remove) { |
| 445 token_cache_.erase(token_iterator); | 445 token_cache_.erase(token_iterator); |
| 446 return true; | 446 return true; |
| 447 } | 447 } |
| 448 return false; | 448 return false; |
| 449 } | 449 } |
| 450 | 450 |
| 451 void OAuth2TokenService::RegisterCacheEntry( | 451 void OAuth2TokenService::RegisterCacheEntry( |
| 452 const std::string& refresh_token, | 452 const std::string& refresh_token, |
| 453 const OAuth2TokenService::ScopeSet& scopes, | 453 const OAuth2TokenService::ScopeSet& scopes, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 465 } | 465 } |
| 466 | 466 |
| 467 void OAuth2TokenService::ClearCache() { | 467 void OAuth2TokenService::ClearCache() { |
| 468 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 468 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 469 token_cache_.clear(); | 469 token_cache_.clear(); |
| 470 } | 470 } |
| 471 | 471 |
| 472 int OAuth2TokenService::cache_size_for_testing() const { | 472 int OAuth2TokenService::cache_size_for_testing() const { |
| 473 return token_cache_.size(); | 473 return token_cache_.size(); |
| 474 } | 474 } |
| OLD | NEW |