blob: 1dfaabfe9a7f81b347bfa1ec7a65ecd5b0c3ca27 [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 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]32b76ef2010-07-26 23:08:2415#pragma once
[email protected]8b96de122010-02-15 15:15:2216
[email protected]e1d4edb2010-02-17 17:33:5617#include <map>
18
[email protected]81b14e72011-10-07 21:18:3619#include "base/callback.h"
[email protected]3b63f8f42011-03-28 01:54:1520#include "base/memory/ref_counted.h"
[email protected]8b96de122010-02-15 15:15:2221#include "base/string16.h"
[email protected]8d128d62011-09-13 22:11:5722#include "content/common/content_export.h"
[email protected]e1d4edb2010-02-17 17:33:5623#include "googleurl/src/gurl.h"
[email protected]8b96de122010-02-15 15:15:2224
25class GURL;
[email protected]8b96de122010-02-15 15:15:2226
[email protected]60349d92011-09-06 11:00:4127namespace net {
28class URLRequestContextGetter;
29}
30
[email protected]c8c77182011-12-21 15:04:4731namespace content {
32
[email protected]8b96de122010-02-15 15:15:2233// Provides storage for the access token used in the network request.
[email protected]0e034f72011-12-21 13:41:1934class AccessTokenStore : public base::RefCountedThreadSafe<AccessTokenStore> {
[email protected]8b96de122010-02-15 15:15:2235 public:
[email protected]93526f92010-02-19 16:37:4236 // Map of server URLs to associated access token.
37 typedef std::map<GURL, string16> AccessTokenSet;
[email protected]81b14e72011-10-07 21:18:3638 typedef base::Callback<void(AccessTokenSet, net::URLRequestContextGetter*)>
[email protected]60349d92011-09-06 11:00:4139 LoadAccessTokensCallbackType;
[email protected]81b14e72011-10-07 21:18:3640
[email protected]60349d92011-09-06 11:00:4141 // |callback| will be invoked once per LoadAccessTokens call, after existing
42 // access tokens have been loaded from persistent store. As a convenience the
43 // URLRequestContextGetter is also supplied as an argument in |callback|, as
44 // in Chrome the call to obtain this must also be performed on the UI thread
45 // so it is efficient to piggyback it onto this request.
46 // Takes ownership of |callback|.
[email protected]0e034f72011-12-21 13:41:1947 CONTENT_EXPORT virtual void LoadAccessTokens(
48 const LoadAccessTokensCallbackType& callback) = 0;
[email protected]93526f92010-02-19 16:37:4249
50 virtual void SaveAccessToken(
51 const GURL& server_url, const string16& access_token) = 0;
[email protected]8b96de122010-02-15 15:15:2252
53 protected:
[email protected]e1d4edb2010-02-17 17:33:5654 friend class base::RefCountedThreadSafe<AccessTokenStore>;
[email protected]8d128d62011-09-13 22:11:5755 CONTENT_EXPORT AccessTokenStore();
56 CONTENT_EXPORT virtual ~AccessTokenStore();
[email protected]e1d4edb2010-02-17 17:33:5657
[email protected]e1d4edb2010-02-17 17:33:5658 private:
[email protected]93526f92010-02-19 16:37:4259 DISALLOW_COPY_AND_ASSIGN(AccessTokenStore);
[email protected]8b96de122010-02-15 15:15:2260};
61
[email protected]c8c77182011-12-21 15:04:4762} // namespace content
63
64#endif // CONTENT_PUBLIC_BROWSER_ACCESS_TOKEN_STORE_H_