Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/browser/geolocation/location_provider.h

Issue 603040: Add support for top level geolocation arbitrator, and access token persistenc... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // A location provider provides position information from a particular source 5 // A location provider provides position information from a particular source
6 // (GPS, network etc). The GearsGeolocation object uses a set of location 6 // (GPS, network etc). The GearsGeolocation object uses a set of location
7 // providers to obtain a position fix. 7 // providers to obtain a position fix.
8 // 8 //
9 // This file declares a base class to be used by all location providers. 9 // This file declares a base class to be used by all location providers.
10 // Primarily, this class declares interface methods to be implemented by derived 10 // Primarily, this class declares interface methods to be implemented by derived
11 // classes. 11 // classes.
12 12
13 #ifndef CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ 13 #ifndef CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_
14 #define CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ 14 #define CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_
15 15
16 #include <map> 16 #include <map>
17 #include "base/non_thread_safe.h" 17 #include "base/non_thread_safe.h"
18 #include "base/string16.h" 18 #include "base/string16.h"
19 19
20 class AccessTokenStore;
20 class GURL; 21 class GURL;
22 class URLRequestContextGetter;
21 struct Position; 23 struct Position;
22 class URLRequestContextGetter;
23 24
24 // The base class used by all location providers. 25 // The base class used by all location providers.
25 class LocationProviderBase : public NonThreadSafe { 26 class LocationProviderBase : public NonThreadSafe {
26 public: 27 public:
27 // Provides storage for the access token used in the network request.
28 // Normally the client (i.e. geolocation controller) implements this, but
29 // also allows mocking for testing.
30 class AccessTokenStore {
31 public:
32 virtual bool SetAccessToken(const GURL& url,
33 const string16& access_token) = 0;
34 virtual bool GetAccessToken(const GURL& url, string16* access_token) = 0;
35
36 protected:
37 virtual ~AccessTokenStore() {}
38 };
39
40 // Clients of the location provider must implement this interface. All call- 28 // Clients of the location provider must implement this interface. All call-
41 // backs to this interface will happen in the context of the thread on which 29 // backs to this interface will happen in the context of the thread on which
42 // the location provider was created. 30 // the location provider was created.
43 class ListenerInterface { 31 class ListenerInterface {
44 public: 32 public:
45 // Used to inform listener that a new position fix is available or that a 33 // Used to inform listener that a new position fix is available or that a
46 // fatal error has occurred. Providers should call this for new listeners 34 // fatal error has occurred. Providers should call this for new listeners
47 // as soon as a position is available. 35 // as soon as a position is available.
48 virtual void LocationUpdateAvailable(LocationProviderBase* provider) = 0; 36 virtual void LocationUpdateAvailable(LocationProviderBase* provider) = 0;
49 // Used to inform listener that movement has been detected. If obtaining the 37 // Used to inform listener that movement has been detected. If obtaining the
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // ref count. 85 // ref count.
98 typedef std::map<ListenerInterface*, int> ListenerMap; 86 typedef std::map<ListenerInterface*, int> ListenerMap;
99 ListenerMap listeners_; 87 ListenerMap listeners_;
100 }; 88 };
101 89
102 // Factory functions for the various types of location provider to abstract over 90 // Factory functions for the various types of location provider to abstract over
103 // the platform-dependent implementations. 91 // the platform-dependent implementations.
104 LocationProviderBase* NewMockLocationProvider(); 92 LocationProviderBase* NewMockLocationProvider();
105 LocationProviderBase* NewGpsLocationProvider(); 93 LocationProviderBase* NewGpsLocationProvider();
106 LocationProviderBase* NewNetworkLocationProvider( 94 LocationProviderBase* NewNetworkLocationProvider(
107 LocationProviderBase::AccessTokenStore* access_token_store, 95 AccessTokenStore* access_token_store,
108 URLRequestContextGetter* context, 96 URLRequestContextGetter* context,
109 const GURL& url, 97 const GURL& url,
110 const string16& host_name); 98 const string16& host_name);
111 99
112 #endif // CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ 100 #endif // CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/location_arbitrator.cc ('k') | chrome/browser/geolocation/network_location_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698