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

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

Issue 1411063007: Add mojo::StrongBindingSet and use it in GeolocationServiceContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_GEOLOCATION_SERVICE_CONTEXT_H_ 5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_
6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_
7 7
8 #include "base/memory/scoped_vector.h"
9 #include "content/browser/geolocation/geolocation_service_impl.h" 8 #include "content/browser/geolocation/geolocation_service_impl.h"
9 #include "content/common/geolocation_service.mojom.h"
10 #include "content/public/browser/web_contents_user_data.h"
11 #include "mojo/common/service_set.h"
10 12
11 namespace content { 13 namespace content {
14 struct Geoposition;
12 15
13 // Provides information to a set of GeolocationServiceImpl instances that are 16 // Provides information to a set of GeolocationServiceImpl instances that are
14 // associated with a given context. Notably, allows pausing and resuming 17 // associated with a given context. Notably, allows pausing and resuming
15 // geolocation on these instances. 18 // geolocation on these instances.
16 class GeolocationServiceContext { 19 class GeolocationServiceContext
20 : public WebContentsUserData<GeolocationServiceContext> {
17 public: 21 public:
18 GeolocationServiceContext(); 22 explicit GeolocationServiceContext(WebContents* web_contents);
19 virtual ~GeolocationServiceContext(); 23 ~GeolocationServiceContext() override;
24
25 static GeolocationServiceContext* GetOrCreateForWebContents(
26 WebContents* web_contents);
20 27
21 // Creates a GeolocationServiceImpl that is weakly bound to |request|. 28 // Creates a GeolocationServiceImpl that is weakly bound to |request|.
22 // |update_callback| will be called when services send 29 // |update_callback| will be called when services send
Anand Mistry (off Chromium) 2015/11/10 04:53:39 update comment
Sam McNally 2015/11/11 07:04:02 Done.
23 // location updates to their clients. 30 // location updates to their clients.
24 void CreateService(const base::Closure& update_callback, 31 static void CreateService(RenderFrameHost* render_frame_host,
25 mojo::InterfaceRequest<GeolocationService> request); 32 mojo::InterfaceRequest<GeolocationService> request);
26
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);
30 33
31 // Pauses and resumes geolocation. Resuming when nothing is paused is a 34 // 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 35 // no-op. If a service is added while geolocation is paused, that service
33 // will not get geolocation updates until geolocation is resumed. 36 // will not get geolocation updates until geolocation is resumed.
34 void PauseUpdates(); 37 void PauseUpdates();
35 void ResumeUpdates(); 38 void ResumeUpdates();
36 39
37 // Returns whether geolocation updates are currently paused. 40 // Returns whether geolocation updates are currently paused.
38 bool paused() { return paused_; } 41 bool paused() { return paused_; }
39 42
40 // Enables geolocation override. This method can be used to trigger possible 43 // Enables geolocation override. This method can be used to trigger possible
41 // location-specific behavior in a particular context. 44 // location-specific behavior in a particular context.
42 void SetOverride(scoped_ptr<Geoposition> geoposition); 45 void SetOverride(scoped_ptr<Geoposition> geoposition);
43 46
44 // Disables geolocation override. 47 // Disables geolocation override.
45 void ClearOverride(); 48 void ClearOverride();
46 49
47 private: 50 private:
48 ScopedVector<GeolocationServiceImpl> services_; 51 friend class GeolocationServiceImpl;
52
53 void CreateServiceImpl(RenderFrameHost* render_frame_host,
54 mojo::InterfaceRequest<GeolocationService> request);
55
56 mojo::ServiceSet<GeolocationService, GeolocationServiceImpl> services_;
49 bool paused_; 57 bool paused_;
50 58
51 scoped_ptr<Geoposition> geoposition_override_; 59 scoped_ptr<Geoposition> geoposition_override_;
52 60
53 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceContext); 61 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceContext);
54 }; 62 };
55 63
56 } // namespace content 64 } // namespace content
57 65
58 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ 66 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698