Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / content / browser / geolocation / geolocation_service_context.h
blob453c8b0dce2862ef600ea20b8ca4b1c3ecd0578c
1 // Copyright 2014 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.
5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_
6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_
8 #include "base/memory/scoped_vector.h"
9 #include "content/browser/geolocation/geolocation_service_impl.h"
11 namespace content {
13 // Provides information to a set of GeolocationServiceImpl instances that are
14 // associated with a given context. Notably, allows pausing and resuming
15 // geolocation on these instances.
16 class GeolocationServiceContext {
17 public:
18 GeolocationServiceContext();
19 virtual ~GeolocationServiceContext();
21 // Creates a GeolocationServiceImpl that is weakly bound to |request|.
22 // |update_callback| will be called when services send
23 // location updates to their clients.
24 void CreateService(const base::Closure& update_callback,
25 mojo::InterfaceRequest<GeolocationService> request);
27 // Called when a service has a connection error. After this call, it is no
28 // longer safe to access |service|.
29 void ServiceHadConnectionError(GeolocationServiceImpl* service);
31 // Pauses and resumes geolocation. Resuming when nothing is paused is a
32 // no-op. If a service is added while geolocation is paused, that service
33 // will not get geolocation updates until geolocation is resumed.
34 void PauseUpdates();
35 void ResumeUpdates();
37 // Returns whether geolocation updates are currently paused.
38 bool paused() { return paused_; }
40 // Enables geolocation override. This method can be used to trigger possible
41 // location-specific behavior in a particular context.
42 void SetOverride(scoped_ptr<Geoposition> geoposition);
44 // Disables geolocation override.
45 void ClearOverride();
47 private:
48 ScopedVector<GeolocationServiceImpl> services_;
49 bool paused_;
51 scoped_ptr<Geoposition> geoposition_override_;
53 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceContext);
56 } // namespace content
58 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_