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_; |