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

Side by Side Diff: chrome/browser/geolocation/location_arbitrator.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
Property Changes:
Added: svn:eol-style
+ LF
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 CHROME_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_
6 #define CHROME_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_
7
8 class AccessTokenStore;
9 class URLRequestContextGetter;
10 struct Position;
11
12 // This is the main API to the geolocaiton subsystem. Typically the application
13 // will hold a single instance of this class, and can register multiple
14 // observers which will be notified of location updates. Underlying location
15 // provider(s) will only be enabled whilst there is at least one observer
16 // registered.
17 // This class is responsible for handling updates from multiple underlying
18 // providers and resolving them to a single 'best' location fix at any given
19 // moment.
20 class GeolocationArbitrator {
21 public:
22 // Creates and returns a new instance of the location arbitrator.
23 static GeolocationArbitrator* New(AccessTokenStore* access_token_store,
24 URLRequestContextGetter* context_getter);
25
26 class Delegate {
27 public:
28 // This will be called whenever the 'best available' location is updated,
29 // or when an error is encountered meaning no location data will be
30 // available in the forseeable future.
31 virtual void OnLocationUpdate(const Position& position) = 0;
32
33 protected:
34 virtual ~Delegate() {}
35 };
36 struct UpdateOptions {
37 UpdateOptions() : use_high_accuracy(false) {}
38 bool use_high_accuracy;
39 };
40
41 virtual ~GeolocationArbitrator();
42
43 // Must be called from the same thread as the arbitrator was created on.
44 // The update options passed are used as a 'hint' for the provider preferences
45 // for this particular observer, however the delegate could receive callbacks
46 // for best available locations from any active provider whilst it is
47 // registerd.
48 // If an existing delegate is added a second time it's options are updated
49 // but only a single call to RemoveObserver() is required to remove it.
50 virtual void AddObserver(Delegate* delegate,
51 const UpdateOptions& update_options) = 0;
52 // Remove a previously registered observer. No-op if not previously registered
53 // via AddObserver()
54 virtual void RemoveObserver(Delegate* delegate) = 0;
55
56 // TODO(joth): This is a stop-gap for testing; once we have decoupled
57 // provider factory we should extract mock creation from the arbitrator.
58 virtual void SetUseMockProvider(bool use_mock) = 0;
59 };
60
61 #endif // CHROME_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/geoposition.h ('k') | chrome/browser/geolocation/location_arbitrator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698