| 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 // Defines the Geolocation access token store, and associated factory function. |   5 // Defines the Geolocation access token store, and associated factory function. | 
|   6 // An access token store is responsible for providing the API to persist |   6 // An access token store is responsible for providing the API to persist | 
|   7 // access tokens, one at a time, and to load them back on mass. |   7 // access tokens, one at a time, and to load them back on mass. | 
|   8 // The API is a little more complex than one might wish, due to the need for |   8 // The API is a little more complex than one might wish, due to the need for | 
|   9 // prefs access to happen asynchronously on the UI thread. |   9 // prefs access to happen asynchronously on the UI thread. | 
|  10 // This API is provided as abstract base classes to allow mocking and testing |  10 // This API is provided as abstract base classes to allow mocking and testing | 
|  11 // of clients, without dependency on browser process singleton objects etc. |  11 // of clients, without dependency on browser process singleton objects etc. | 
|  12  |  12  | 
|  13 #ifndef CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_ |  13 #ifndef CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_ | 
|  14 #define CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_ |  14 #define CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_ | 
|  15  |  15  | 
|  16 #include <map> |  16 #include <map> | 
|  17  |  17  | 
|  18 #include "base/callback.h" |  18 #include "base/callback.h" | 
|  19 #include "base/memory/ref_counted.h" |  19 #include "base/memory/ref_counted.h" | 
|  20 #include "base/strings/string16.h" |  20 #include "base/strings/string16.h" | 
|  21 #include "content/common/content_export.h" |  21 #include "content/common/content_export.h" | 
 |  22 #include "net/url_request/url_request_context_getter.h" | 
|  22 #include "url/gurl.h" |  23 #include "url/gurl.h" | 
|  23  |  24  | 
|  24 class GURL; |  25 class GURL; | 
|  25  |  26  | 
|  26 namespace net { |  | 
|  27 class URLRequestContextGetter; |  | 
|  28 } |  | 
|  29  |  | 
|  30 namespace content { |  27 namespace content { | 
|  31  |  28  | 
|  32 // Provides storage for the access token used in the network request. |  29 // Provides storage for the access token used in the network request. | 
|  33 class AccessTokenStore : public base::RefCountedThreadSafe<AccessTokenStore> { |  30 class AccessTokenStore : public base::RefCountedThreadSafe<AccessTokenStore> { | 
|  34  public: |  31  public: | 
|  35   // Map of server URLs to associated access token. |  32   // Map of server URLs to associated access token. | 
|  36   typedef std::map<GURL, base::string16> AccessTokenMap; |  33   typedef std::map<GURL, base::string16> AccessTokenMap; | 
|  37   typedef base::Callback<void(AccessTokenMap, net::URLRequestContextGetter*)> |  34   typedef base::Callback< | 
 |  35       void(AccessTokenMap, const scoped_refptr<net::URLRequestContextGetter>&)> | 
|  38       LoadAccessTokensCallback; |  36       LoadAccessTokensCallback; | 
|  39  |  37  | 
|  40   // |callback| will be invoked once per LoadAccessTokens call, after existing |  38   // |callback| will be invoked once per LoadAccessTokens call, after existing | 
|  41   // access tokens have been loaded from persistent store. As a convenience the |  39   // access tokens have been loaded from persistent store. As a convenience the | 
|  42   // URLRequestContextGetter is also supplied as an argument in |callback|, as |  40   // URLRequestContextGetter is also supplied as an argument in |callback|, as | 
|  43   // in Chrome the call to obtain this must also be performed on the UI thread |  41   // in Chrome the call to obtain this must also be performed on the UI thread | 
|  44   // so it is efficient to piggyback it onto this request. |  42   // so it is efficient to piggyback it onto this request. | 
|  45   virtual void LoadAccessTokens(const LoadAccessTokensCallback& callback) = 0; |  43   virtual void LoadAccessTokens(const LoadAccessTokensCallback& callback) = 0; | 
|  46  |  44  | 
|  47   virtual void SaveAccessToken( |  45   virtual void SaveAccessToken( | 
|  48       const GURL& server_url, const base::string16& access_token) = 0; |  46       const GURL& server_url, const base::string16& access_token) = 0; | 
|  49  |  47  | 
|  50  protected: |  48  protected: | 
|  51   friend class base::RefCountedThreadSafe<AccessTokenStore>; |  49   friend class base::RefCountedThreadSafe<AccessTokenStore>; | 
|  52   CONTENT_EXPORT AccessTokenStore() {} |  50   CONTENT_EXPORT AccessTokenStore() {} | 
|  53   CONTENT_EXPORT virtual ~AccessTokenStore() {} |  51   CONTENT_EXPORT virtual ~AccessTokenStore() {} | 
|  54 }; |  52 }; | 
|  55  |  53  | 
|  56 }  // namespace content |  54 }  // namespace content | 
|  57  |  55  | 
|  58 #endif  // CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_ |  56 #endif  // CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_ | 
| OLD | NEW |