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

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

Issue 273523007: Dispatch geolocation IPCs on the UI thread. Aside from simplifying the code to avoid a lot of threa… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 7 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_impl.h
===================================================================
--- content/browser/geolocation/geolocation_provider_impl.h (revision 269778)
+++ content/browser/geolocation/geolocation_provider_impl.h (working copy)
@@ -21,34 +21,17 @@
namespace content {
class LocationArbitrator;
-// This is the main API to the geolocation subsystem. The application will hold
-// a single instance of this class and can register multiple clients to be
-// notified of location changes:
-// * Callbacks are registered by AddLocationUpdateCallback() and will keep
-// receiving updates until unregistered by RemoveLocationUpdateCallback().
-// 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 registered observer or pending callback. The arbitrator and the
-// location providers it uses run on a separate Geolocation thread.
class CONTENT_EXPORT GeolocationProviderImpl
: public NON_EXPORTED_BASE(GeolocationProvider),
public base::Thread {
public:
// GeolocationProvider implementation:
- virtual void AddLocationUpdateCallback(const LocationUpdateCallback& callback,
- bool use_high_accuracy) OVERRIDE;
- virtual bool RemoveLocationUpdateCallback(
- const LocationUpdateCallback& callback) OVERRIDE;
+ virtual scoped_ptr<GeolocationProvider::Subscription>
+ AddLocationUpdateCallback(const LocationUpdateCallback& callback,
+ bool use_high_accuracy) OVERRIDE;
virtual void UserDidOptIntoLocationServices() OVERRIDE;
+ virtual void OverrideLocationForTesting(const Geoposition& position) OVERRIDE;
- bool LocationServicesOptedIn() const;
-
- // Overrides the location for automation/testing. Suppresses any further
- // updates from the actual providers and sends an update with the overridden
- // position to all registered clients.
- void OverrideLocationForTesting(const Geoposition& override_position);
-
// Callback from the LocationArbitrator. Public for testing.
void OnLocationUpdate(const Geoposition& position);
@@ -58,6 +41,10 @@
// instantiated on the same thread. Ownership is NOT returned.
static GeolocationProviderImpl* GetInstance();
+ bool user_did_opt_into_location_services_for_testing() {
+ return user_did_opt_into_location_services_;
+ }
+
protected:
friend struct DefaultSingletonTraits<GeolocationProviderImpl>;
GeolocationProviderImpl();
@@ -67,9 +54,6 @@
virtual LocationArbitrator* CreateArbitrator();
private:
- typedef std::pair<LocationUpdateCallback, bool> LocationUpdateInfo;
- typedef std::list<LocationUpdateInfo> CallbackList;
-
bool OnGeolocationThread() const;
// Start and stop providers as needed when clients are added or removed.
@@ -94,8 +78,9 @@
virtual void Init() OVERRIDE;
virtual void CleanUp() OVERRIDE;
- // Only used on the IO thread
- CallbackList callbacks_;
+ base::CallbackList<void(const Geoposition&)> high_accuracy_callbacks_;
+ base::CallbackList<void(const Geoposition&)> low_accuracy_callbacks_;
+
bool user_did_opt_into_location_services_;
Geoposition position_;
« no previous file with comments | « content/browser/geolocation/geolocation_dispatcher_host.cc ('k') | content/browser/geolocation/geolocation_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698