Bug 868257 - watchPosition only sends one location r=stuart a=blocking-b2g18
authorDoug Turner <doug.turner@gmail.com>
Thu, 02 May 2013 23:06:34 -0700
changeset 119259 8becaf2a0bc72d813c2924d3b15a244c947efa2d
parent 119258 95df5fa8fd47a413560b3cee95fca2641b0614a9
child 119260 deb3ead2379df1bec11e370e793576c6afe3fbfe
push id757
push userdougt@mozilla.com
push dateFri, 03 May 2013 06:06:43 +0000
reviewersstuart, blocking-b2g18
bugs868257
milestone18.0
Bug 868257 - watchPosition only sends one location r=stuart a=blocking-b2g18
dom/src/geolocation/nsGeolocation.cpp
dom/src/geolocation/nsGeolocation.h
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -285,17 +285,16 @@ nsDOMGeoPositionError::NotifyCallback(ns
 nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator,
                                            nsIDOMGeoPositionCallback* aCallback,
                                            nsIDOMGeoPositionErrorCallback* aErrorCallback,
                                            mozilla::dom::GeoPositionOptions* aOptions,
                                            bool aWatchPositionRequest,
                                            int32_t aWatchId)
   : mAllowed(false),
     mCleared(false),
-    mIsFirstUpdate(true),
     mIsWatchPositionRequest(aWatchPositionRequest),
     mCallback(aCallback),
     mErrorCallback(aErrorCallback),
     mOptions(aOptions),
     mLocator(aLocator),
     mWatchId(aWatchId)
 {
 }
@@ -561,32 +560,20 @@ nsGeolocationRequest::GetPrincipal()
 }
 
 bool
 nsGeolocationRequest::Update(nsIDOMGeoPosition* aPosition)
 {
   if (!mAllowed) {
     return false;
   }
-  // Only dispatch callbacks if this is the first position for this request, or
-  // if the accuracy is as good or improving.
-  //
-  // This ensures that all listeners get at least one position callback, particularly
-  // in the case when newly detected positions are all less accurate than the cached one.
-  //
-  // Fixes bug 596481
-  nsCOMPtr<nsIRunnable> ev;
-  if (mIsFirstUpdate) {
-    mIsFirstUpdate = PR_FALSE;
-    ev  = new RequestSendLocationEvent(aPosition,
-                                       this,
-                                       mIsWatchPositionRequest ? nullptr : mLocator);
-  } else {
-    ev = new RequestRestartTimerEvent(this);
-  }
+
+  nsCOMPtr<nsIRunnable> ev  = new RequestSendLocationEvent(aPosition,
+                                                           this,
+                                                           mIsWatchPositionRequest ? nullptr : mLocator);
   NS_DispatchToMainThread(ev);
   return true;
 }
 
 void
 nsGeolocationRequest::Shutdown()
 {
   if (mTimeoutTimer) {
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -75,17 +75,16 @@ class nsGeolocationRequest
   void IPDLRelease() { Release(); }
 
   int32_t WatchId() { return mWatchId; }
  private:
 
   void NotifyError(int16_t errorCode);
   bool mAllowed;
   bool mCleared;
-  bool mIsFirstUpdate;
   bool mIsWatchPositionRequest;
 
   nsCOMPtr<nsITimer> mTimeoutTimer;
   nsCOMPtr<nsIDOMGeoPositionCallback> mCallback;
   nsCOMPtr<nsIDOMGeoPositionErrorCallback> mErrorCallback;
   nsAutoPtr<mozilla::dom::GeoPositionOptions> mOptions;
 
   nsRefPtr<nsGeolocation> mLocator;