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

Side by Side Diff: content/browser/geolocation/location_arbitrator_impl.h

Issue 11412194: Cleanup: MockGeolocationArbitrator for GeolocationProvider tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make suggested changes. Created 8 years 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) 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 #ifndef CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_ 5 #ifndef CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_
6 #define CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_ 6 #define CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_
7 7
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "content/browser/geolocation/geolocation_observer.h"
12 #include "content/browser/geolocation/location_arbitrator.h"
11 #include "content/browser/geolocation/location_provider.h" 13 #include "content/browser/geolocation/location_provider.h"
12 #include "content/browser/geolocation/geolocation_observer.h"
13 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
14 #include "content/public/browser/access_token_store.h" 15 #include "content/public/browser/access_token_store.h"
15 #include "content/public/common/geoposition.h" 16 #include "content/public/common/geoposition.h"
16 #include "net/url_request/url_request_context_getter.h" 17 #include "net/url_request/url_request_context_getter.h"
17 18
18 namespace net { 19 namespace net {
19 class URLRequestContextGetter; 20 class URLRequestContextGetter;
20 } 21 }
21 22
22 namespace content { 23 namespace content {
23 class AccessTokenStore; 24 class AccessTokenStore;
24 class LocationProviderBase; 25 class LocationProviderBase;
25 26
26 // This class is responsible for handling updates from multiple underlying 27 // This class is responsible for handling updates from multiple underlying
27 // providers and resolving them to a single 'best' location fix at any given 28 // providers and resolving them to a single 'best' location fix at any given
28 // moment. 29 // moment.
29 class CONTENT_EXPORT GeolocationArbitrator 30 class CONTENT_EXPORT GeolocationArbitratorImpl
30 : public LocationProviderBase::ListenerInterface { 31 : public GeolocationArbitrator,
32 public LocationProviderBase::ListenerInterface {
31 public: 33 public:
32 // Number of milliseconds newer a location provider has to be that it's worth 34 // Number of milliseconds newer a location provider has to be that it's worth
33 // switching to this location provider on the basis of it being fresher 35 // switching to this location provider on the basis of it being fresher
34 // (regardles of relative accuracy). Public for tests. 36 // (regardles of relative accuracy). Public for tests.
35 static const int64 kFixStaleTimeoutMilliseconds; 37 static const int64 kFixStaleTimeoutMilliseconds;
36 38
37 explicit GeolocationArbitrator(GeolocationObserver* observer); 39 explicit GeolocationArbitratorImpl(GeolocationObserver* observer);
38 virtual ~GeolocationArbitrator(); 40 virtual ~GeolocationArbitratorImpl();
39 41
40 static GURL DefaultNetworkProviderURL(); 42 static GURL DefaultNetworkProviderURL();
41 43
42 // See more details in geolocation_provider. 44 // GeolocationArbitrator
43 void StartProviders(const GeolocationObserverOptions& options); 45 virtual void StartProviders(const GeolocationObserverOptions& options)
44 void StopProviders(); 46 OVERRIDE;
45 47 virtual void StopProviders() OVERRIDE;
46 // Called everytime permission is granted to a page for using geolocation. 48 virtual void OnPermissionGranted() OVERRIDE;
47 // This may either be through explicit user action (e.g. responding to the 49 virtual bool HasPermissionBeenGranted() const OVERRIDE;
48 // infobar prompt) or inferred from a persisted site permission.
49 // The arbitrator will inform all providers of this, which may in turn use
50 // this information to modify their internal policy.
51 void OnPermissionGranted();
52
53 // Returns true if this arbitrator has received at least one call to
54 // OnPermissionGranted().
55 bool HasPermissionBeenGranted() const;
56 50
57 // ListenerInterface 51 // ListenerInterface
58 virtual void LocationUpdateAvailable(LocationProviderBase* provider) OVERRIDE; 52 virtual void LocationUpdateAvailable(LocationProviderBase* provider) OVERRIDE;
59 53
60 protected: 54 protected:
61 55
62 AccessTokenStore* GetAccessTokenStore(); 56 AccessTokenStore* GetAccessTokenStore();
63 57
64 // These functions are useful for injection of dependencies in derived 58 // These functions are useful for injection of dependencies in derived
65 // testing classes. 59 // testing classes.
(...skipping 24 matching lines...) Expand all
90 scoped_refptr<AccessTokenStore> access_token_store_; 84 scoped_refptr<AccessTokenStore> access_token_store_;
91 GeolocationObserver* observer_; 85 GeolocationObserver* observer_;
92 ScopedVector<LocationProviderBase> providers_; 86 ScopedVector<LocationProviderBase> providers_;
93 GeolocationObserverOptions current_provider_options_; 87 GeolocationObserverOptions current_provider_options_;
94 // The provider which supplied the current |position_| 88 // The provider which supplied the current |position_|
95 const LocationProviderBase* position_provider_; 89 const LocationProviderBase* position_provider_;
96 bool is_permission_granted_; 90 bool is_permission_granted_;
97 // The current best estimate of our position. 91 // The current best estimate of our position.
98 Geoposition position_; 92 Geoposition position_;
99 93
100 DISALLOW_COPY_AND_ASSIGN(GeolocationArbitrator); 94 DISALLOW_COPY_AND_ASSIGN(GeolocationArbitratorImpl);
101 }; 95 };
102 96
103 } // namespace content 97 } // namespace content
104 98
105 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_ 99 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/geolocation/location_arbitrator.cc ('k') | content/browser/geolocation/location_arbitrator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698