| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_EXTENSIONS_TOKEN_CACHE_TOKEN_CACHE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_TOKEN_CACHE_TOKEN_CACHE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_TOKEN_CACHE_TOKEN_CACHE_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_TOKEN_CACHE_TOKEN_CACHE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 14 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class NotificationSource; | 19 class NotificationSource; |
| 20 } | 20 } |
| 21 | 21 |
| 22 class Profile; | 22 class Profile; |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 | 25 |
| 26 // This class caches tokens for the current user. It will clear tokens out | 26 // This class caches tokens for the current user. It will clear tokens out |
| 27 // when the user logs out or after the specified timeout interval, or when | 27 // when the user logs out or after the specified timeout interval, or when |
| 28 // the instance of chrome shuts down. | 28 // the instance of chrome shuts down. |
| 29 class TokenCacheService : public ProfileKeyedService, | 29 class TokenCacheService : public BrowserContextKeyedService, |
| 30 public content::NotificationObserver { | 30 public content::NotificationObserver { |
| 31 public: | 31 public: |
| 32 explicit TokenCacheService(Profile* profile); | 32 explicit TokenCacheService(Profile* profile); |
| 33 virtual ~TokenCacheService(); | 33 virtual ~TokenCacheService(); |
| 34 | 34 |
| 35 // Store a token for the currently logged in user. We will look it up later by | 35 // Store a token for the currently logged in user. We will look it up later by |
| 36 // the name given here, and we will expire the token after the timeout. For a | 36 // the name given here, and we will expire the token after the timeout. For a |
| 37 // timeout of 0, we never expire the token. After time_to_live expires, the | 37 // timeout of 0, we never expire the token. After time_to_live expires, the |
| 38 // token will be expired. | 38 // token will be expired. |
| 39 void StoreToken(const std::string& token_name, const std::string& token_value, | 39 void StoreToken(const std::string& token_name, const std::string& token_value, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 std::map<std::string, TokenCacheData> token_cache_; | 60 std::map<std::string, TokenCacheData> token_cache_; |
| 61 content::NotificationRegistrar registrar_; | 61 content::NotificationRegistrar registrar_; |
| 62 const Profile* const profile_; | 62 const Profile* const profile_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(TokenCacheService); | 64 DISALLOW_COPY_AND_ASSIGN(TokenCacheService); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace extensions | 67 } // namespace extensions |
| 68 | 68 |
| 69 #endif // CHROME_BROWSER_EXTENSIONS_TOKEN_CACHE_TOKEN_CACHE_SERVICE_H_ | 69 #endif // CHROME_BROWSER_EXTENSIONS_TOKEN_CACHE_TOKEN_CACHE_SERVICE_H_ |
| OLD | NEW |