Chromium Code Reviews| Index: content/browser/geolocation/geolocation_service_context.h |
| diff --git a/content/browser/geolocation/geolocation_service_context.h b/content/browser/geolocation/geolocation_service_context.h |
| index 453c8b0dce2862ef600ea20b8ca4b1c3ecd0578c..15e7666d0f18d750e5b8b41881164266c626e098 100644 |
| --- a/content/browser/geolocation/geolocation_service_context.h |
| +++ b/content/browser/geolocation/geolocation_service_context.h |
| @@ -5,28 +5,29 @@ |
| #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ |
| #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ |
| -#include "base/memory/scoped_vector.h" |
| #include "content/browser/geolocation/geolocation_service_impl.h" |
| +#include "content/common/geolocation_service.mojom.h" |
| +#include "content/public/browser/web_contents_user_data.h" |
| +#include "mojo/common/service_set.h" |
| namespace content { |
| +struct Geoposition; |
| // Provides information to a set of GeolocationServiceImpl instances that are |
| // associated with a given context. Notably, allows pausing and resuming |
| // geolocation on these instances. |
| -class GeolocationServiceContext { |
| +class GeolocationServiceContext |
| + : public WebContentsUserData<GeolocationServiceContext> { |
| public: |
| - GeolocationServiceContext(); |
| - virtual ~GeolocationServiceContext(); |
| + explicit GeolocationServiceContext(WebContents* web_contents); |
|
Michael van Ouwerkerk
2015/11/11 11:20:56
The constructor and destructor should be private n
Sam McNally
2015/11/13 00:49:59
Done.
|
| + ~GeolocationServiceContext() override; |
| - // Creates a GeolocationServiceImpl that is weakly bound to |request|. |
| - // |update_callback| will be called when services send |
| - // location updates to their clients. |
| - void CreateService(const base::Closure& update_callback, |
| - mojo::InterfaceRequest<GeolocationService> request); |
| + static GeolocationServiceContext* GetOrCreateForWebContents( |
| + WebContents* web_contents); |
| - // Called when a service has a connection error. After this call, it is no |
| - // longer safe to access |service|. |
| - void ServiceHadConnectionError(GeolocationServiceImpl* service); |
| + // Creates a GeolocationServiceImpl that is bound to |request|. |
| + static void CreateService(RenderFrameHost* render_frame_host, |
| + mojo::InterfaceRequest<GeolocationService> request); |
| // Pauses and resumes geolocation. Resuming when nothing is paused is a |
| // no-op. If a service is added while geolocation is paused, that service |
| @@ -35,7 +36,14 @@ class GeolocationServiceContext { |
| void ResumeUpdates(); |
| // Returns whether geolocation updates are currently paused. |
| - bool paused() { return paused_; } |
| + bool paused() const { return paused_; } |
| + |
| + // Returns the current position override, or nullptr if there isn't one. |
| + const Geoposition* position_override() const { |
| + return geoposition_override_.get(); |
| + } |
| + |
| + void DestroyService(GeolocationServiceImpl* service); |
| // Enables geolocation override. This method can be used to trigger possible |
| // location-specific behavior in a particular context. |
| @@ -45,7 +53,10 @@ class GeolocationServiceContext { |
| void ClearOverride(); |
| private: |
| - ScopedVector<GeolocationServiceImpl> services_; |
| + void CreateServiceImpl(RenderFrameHost* render_frame_host, |
| + mojo::InterfaceRequest<GeolocationService> request); |
| + |
| + mojo::ServiceSet<GeolocationService, GeolocationServiceImpl> services_; |
| bool paused_; |
| scoped_ptr<Geoposition> geoposition_override_; |