blob: bd130144c6c41b7421ebdf16767fa99d03690783 [file] [log] [blame]
[email protected]f7867172012-07-11 07:04:071// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]8b96de122010-02-15 15:15:222// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]93526f92010-02-19 16:37:425// Defines the Geolocation access token store, and associated factory function.
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.
[email protected]e1d4edb2010-02-17 17:33:568// 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.
[email protected]93526f92010-02-19 16:37:4210// This API is provided as abstract base classes to allow mocking and testing
[email protected]e1d4edb2010-02-17 17:33:5611// of clients, without dependency on browser process singleton objects etc.
12
[email protected]c8c77182011-12-21 15:04:4713#ifndef CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_
14#define CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_
[email protected]8b96de122010-02-15 15:15:2215
[email protected]e1d4edb2010-02-17 17:33:5616#include <map>
17
[email protected]81b14e72011-10-07 21:18:3618#include "base/callback.h"
[email protected]3b63f8f42011-03-28 01:54:1519#include "base/memory/ref_counted.h"
[email protected]26dd01c2013-06-12 13:52:1320#include "base/strings/string16.h"
[email protected]8d128d62011-09-13 22:11:5721#include "content/common/content_export.h"
[email protected]707e1c42013-07-09 21:18:5822#include "url/gurl.h"
[email protected]8b96de122010-02-15 15:15:2223
24class GURL;
[email protected]8b96de122010-02-15 15:15:2225
[email protected]60349d92011-09-06 11:00:4126namespace net {
27class URLRequestContextGetter;
28}
29
[email protected]c8c77182011-12-21 15:04:4730namespace content {
31
[email protected]8b96de122010-02-15 15:15:2232// Provides storage for the access token used in the network request.
[email protected]0e034f72011-12-21 13:41:1933class AccessTokenStore : public base::RefCountedThreadSafe<AccessTokenStore> {
[email protected]8b96de122010-02-15 15:15:2234 public:
[email protected]93526f92010-02-19 16:37:4235 // Map of server URLs to associated access token.
[email protected]fcf75d42013-12-03 20:11:2636 typedef std::map<GURL, base::string16> AccessTokenSet;
[email protected]81b14e72011-10-07 21:18:3637 typedef base::Callback<void(AccessTokenSet, net::URLRequestContextGetter*)>
[email protected]60349d92011-09-06 11:00:4138 LoadAccessTokensCallbackType;
[email protected]81b14e72011-10-07 21:18:3639
[email protected]60349d92011-09-06 11:00:4140 // |callback| will be invoked once per LoadAccessTokens call, after existing
41 // access tokens have been loaded from persistent store. As a convenience the
42 // 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
44 // so it is efficient to piggyback it onto this request.
45 // Takes ownership of |callback|.
[email protected]f7f98192012-01-24 17:10:2646 virtual void LoadAccessTokens(
[email protected]0e034f72011-12-21 13:41:1947 const LoadAccessTokensCallbackType& callback) = 0;
[email protected]93526f92010-02-19 16:37:4248
49 virtual void SaveAccessToken(
[email protected]fcf75d42013-12-03 20:11:2650 const GURL& server_url, const base::string16& access_token) = 0;
[email protected]8b96de122010-02-15 15:15:2251
52 protected:
[email protected]e1d4edb2010-02-17 17:33:5653 friend class base::RefCountedThreadSafe<AccessTokenStore>;
[email protected]f7f98192012-01-24 17:10:2654 CONTENT_EXPORT AccessTokenStore() {}
55 CONTENT_EXPORT virtual ~AccessTokenStore() {}
[email protected]8b96de122010-02-15 15:15:2256};
57
[email protected]c8c77182011-12-21 15:04:4758} // namespace content
59
60#endif // CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_