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

Unified Diff: content/browser/geolocation/geolocation_provider.h

Issue 10103029: Add device location reporting (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed. Also added lots of includes to IWYU. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/geolocation/geolocation_provider.h
diff --git a/content/browser/geolocation/geolocation_provider.h b/content/browser/geolocation/geolocation_provider.h
index a45a365f23066aa71491b65ce8aa07e7f05cb629..4286c11cf56a2a2b287ac3480209ad15196ca059 100644
--- a/content/browser/geolocation/geolocation_provider.h
+++ b/content/browser/geolocation/geolocation_provider.h
@@ -18,22 +18,22 @@ class GeolocationArbitrator;
template<typename Type>
struct DefaultSingletonTraits;
-// This is the main API to the geolocation subsystem. The application
-// will hold a single instance of this class, and can register multiple
-// observers which will be notified of location updates. Underlying location
-// arbitrator will only be enabled whilst there is at least one observer
-// registered.
+// This is the main API to the geolocation subsystem. The application will hold
+// a single instance of this class and can register multiple observers which
+// will be notified of location updates. The application must instantiate the
+// GeolocationProvider on the IO thread and must communicate with it on the same
+// thread.
+// The underlying location arbitrator will only be enabled whilst there is at
+// least one observer registered. The arbitrator and the location providers it
+// uses run on a separate Geolocation thread.
class CONTENT_EXPORT GeolocationProvider
: public base::Thread, public GeolocationObserver {
public:
- GeolocationProvider();
-
- // Must be called from the same thread as the GeolocationProvider was created
- // on. The GeolocationObserverOptions passed are used as a 'hint' for the
- // provider preferences for this particular observer, however the observer
- // could receive callbacks for best available locations from any active
- // provider whilst it is registered.
- // If an existing observer is added a second time it's options are updated
+ // The GeolocationObserverOptions passed are used as a 'hint' for the provider
+ // preferences for this particular observer, however the observer could
+ // receive callbacks for best available locations from any active provider
+ // whilst it is registered.
+ // If an existing observer is added a second time, its options are updated
// but only a single call to RemoveObserver() is required to remove it.
void AddObserver(GeolocationObserver* delegate,
const GeolocationObserverOptions& update_options);
@@ -49,18 +49,21 @@ class CONTENT_EXPORT GeolocationProvider
virtual void OnLocationUpdate(const Geoposition& position) OVERRIDE;
// Gets a pointer to the singleton instance of the location relayer, which
- // is in turn bound to the browser's global context objects. Ownership is NOT
- // returned.
+ // is in turn bound to the browser's global context objects. This must only be
+ // called on the IO thread so that the GeolocationProvider is always
joth 2012/04/23 10:05:14 add a DCHECK for this?
bartfab (slow) 2012/04/23 12:21:28 There is a DCHECK in GetInstance() already. I put
+ // instantiated on the same thread. Ownership is NOT returned.
static GeolocationProvider* GetInstance();
typedef std::map<GeolocationObserver*, GeolocationObserverOptions>
ObserverMap;
- private:
+ protected:
friend struct DefaultSingletonTraits<GeolocationProvider>;
+ GeolocationProvider();
virtual ~GeolocationProvider();
- bool OnClientThread() const;
+ private:
+ static bool OnIOThread();
bool OnGeolocationThread() const;
// When the observer list changes, we may start the thread and the required
@@ -85,9 +88,7 @@ class CONTENT_EXPORT GeolocationProvider
virtual void Init() OVERRIDE;
virtual void CleanUp() OVERRIDE;
- scoped_refptr<base::MessageLoopProxy> client_loop_;
-
- // Only used on client thread
+ // Only used on the IO thread
ObserverMap observers_;
bool is_permission_granted_;
Geoposition position_;

Powered by Google App Engine
This is Rietveld 408576698