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

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

Issue 6597044: Revert 76228 - Move core pieces of geolocation from chrome to content.This is... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_
6 #define CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_
7 #pragma once
8
9 #include "base/string16.h"
10 #include "base/scoped_vector.h"
11 #include "base/time.h"
12 #include "chrome/common/geoposition.h"
13 #include "chrome/common/net/url_request_context_getter.h"
14 #include "content/browser/geolocation/access_token_store.h"
15 #include "content/browser/geolocation/location_provider.h"
16 #include "content/browser/geolocation/geolocation_observer.h"
17 #include "googleurl/src/gurl.h"
18
19 class AccessTokenStore;
20 class GeolocationArbitratorDependencyFactory;
21 class GURL;
22 class LocationProviderBase;
23 class URLRequestContextGetter;
24 struct Geoposition;
25
26 // 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 // moment.
29 class GeolocationArbitrator : public LocationProviderBase::ListenerInterface {
30 public:
31 // Number of milliseconds newer a location provider has to be that it's worth
32 // switching to this location provider on the basis of it being fresher
33 // (regardles of relative accuracy). Public for tests.
34 static const int64 kFixStaleTimeoutMilliseconds;
35
36 // Defines a function that returns the current time.
37 typedef base::Time (*GetTimeNow)();
38
39 ~GeolocationArbitrator();
40
41 static GeolocationArbitrator* Create(GeolocationObserver* observer);
42
43 // See more details in geolocation_provider.
44 void StartProviders(const GeolocationObserverOptions& options);
45 void StopProviders();
46
47 // Called everytime permission is granted to a page for using geolocation.
48 // This may either be through explicit user action (e.g. responding to the
49 // infobar prompt) or inferred from a persisted site permission.
50 // The arbitrator will inform all providers of this, which may in turn use
51 // this information to modify their internal policy.
52 void OnPermissionGranted(const GURL& requesting_frame);
53
54 // Returns true if this arbitrator has received at least one call to
55 // OnPermissionGranted().
56 bool HasPermissionBeenGranted() const;
57
58 // Call this function every time you need to create an specially parameterised
59 // arbitrator.
60 static void SetDependencyFactoryForTest(
61 GeolocationArbitratorDependencyFactory* factory);
62
63 // ListenerInterface
64 virtual void LocationUpdateAvailable(LocationProviderBase* provider);
65
66 private:
67 GeolocationArbitrator(
68 GeolocationArbitratorDependencyFactory* dependency_factory,
69 GeolocationObserver* observer);
70 // Takes ownership of |provider| on entry; it will either be added to
71 // |providers_| or deleted on error (e.g. it fails to start).
72 void RegisterProvider(LocationProviderBase* provider);
73 void OnAccessTokenStoresLoaded(
74 AccessTokenStore::AccessTokenSet access_token_store);
75 void StartProviders();
76 // Returns true if |new_position| is an improvement over |old_position|.
77 // Set |from_same_provider| to true if both the positions came from the same
78 // provider.
79 bool IsNewPositionBetter(const Geoposition& old_position,
80 const Geoposition& new_position,
81 bool from_same_provider) const;
82
83 scoped_refptr<GeolocationArbitratorDependencyFactory> dependency_factory_;
84 scoped_refptr<AccessTokenStore> access_token_store_;
85 scoped_refptr<URLRequestContextGetter> context_getter_;
86 GetTimeNow get_time_now_;
87 GeolocationObserver* observer_;
88 ScopedVector<LocationProviderBase> providers_;
89 GeolocationObserverOptions current_provider_options_;
90 // The provider which supplied the current |position_|
91 const LocationProviderBase* position_provider_;
92 GURL most_recent_authorized_frame_;
93 CancelableRequestConsumer request_consumer_;
94 // The current best estimate of our position.
95 Geoposition position_;
96
97 DISALLOW_COPY_AND_ASSIGN(GeolocationArbitrator);
98 };
99
100 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_
OLDNEW
« no previous file with comments | « content/browser/geolocation/libgps_wrapper_linux.cc ('k') | content/browser/geolocation/location_arbitrator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698