Merge latest green inbound changeset and mozilla-central
authorEd Morley <emorley@mozilla.com>
Fri, 03 May 2013 13:31:39 +0100
changeset 130737 5c240ee646fb83fda6f8e3ac54633f8e6a39f24c
parent 130736 1998eb59e36988949ad9bcb4c8ddfa21c7e4dd65 (current diff)
parent 130686 b35170667a2ff693493cc61732a90be6b9a21cf3 (diff)
child 130739 eb04c9a69ac912cd0511ca79cf98fd0f805cf6a0
child 130788 306ebf764a1c3fddf3f3267c856856e19f6fe60c
child 155251 a9d0ef8b4113bccbf077fd1e60ce04ec2f57e034
push id1579
push userphilringnalda@gmail.com
push dateSat, 04 May 2013 04:38:04 +0000
treeherderfx-team@a56432a42a41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone23.0a1
Merge latest green inbound changeset and mozilla-central
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -182,40 +182,36 @@ private:
 
 class RequestSendLocationEvent : public nsRunnable
 {
 public:
   // a bit funky.  if locator is passed, that means this
   // event should remove the request from it.  If we ever
   // have to do more, then we can change this around.
   RequestSendLocationEvent(nsIDOMGeoPosition* aPosition,
-                           bool aCachePosition,
                            nsGeolocationRequest* aRequest,
                            Geolocation* aLocator)
     : mPosition(aPosition),
-      mCachePosition(aCachePosition),
       mRequest(aRequest),
       mLocator(aLocator)
   {
   }
 
   NS_IMETHOD Run() {
-    mRequest->SendLocation(mPosition, mCachePosition);
+    mRequest->SendLocation(mPosition);
     if (mLocator) {
       mLocator->RemoveRequest(mRequest);
     }
     return NS_OK;
   }
 
 private:
   nsCOMPtr<nsIDOMGeoPosition> mPosition;
-  bool mCachePosition;
   nsRefPtr<nsGeolocationRequest> mRequest;
-
-  nsRefPtr<Geolocation>        mLocator;
+  nsRefPtr<Geolocation> mLocator;
 };
 
 class RequestRestartTimerEvent : public nsRunnable
 {
 public:
   RequestRestartTimerEvent(nsGeolocationRequest* aRequest)
     : mRequest(aRequest)
   {
@@ -303,17 +299,16 @@ PositionError::NotifyCallback(const GeoP
 nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator,
                                            const GeoPositionCallback& aCallback,
                                            const GeoPositionErrorCallback& aErrorCallback,
                                            mozilla::idl::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)
 {
 }
@@ -467,17 +462,17 @@ nsGeolocationRequest::Allow()
   if (lastPosition && maximumAge > 0 &&
       ( PRTime(PR_Now() / PR_USEC_PER_MSEC) - maximumAge <=
         PRTime(cachedPositionTime) )) {
     // okay, we can return a cached position
     mAllowed = true;
 
     nsCOMPtr<nsIRunnable> ev =
       new RequestSendLocationEvent(
-        lastPosition, true, this, mIsWatchPositionRequest ? nullptr : mLocator);
+        lastPosition, this, mIsWatchPositionRequest ? nullptr : mLocator);
 
     NS_DispatchToMainThread(ev);
   }
 
   SetTimeoutTimer();
 
   mAllowed = true;
   return NS_OK;
@@ -511,17 +506,17 @@ nsGeolocationRequest::MarkCleared()
   if (mTimeoutTimer) {
     mTimeoutTimer->Cancel();
     mTimeoutTimer = nullptr;
   }
   mCleared = true;
 }
 
 void
-nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition, bool aCachePosition)
+nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition)
 {
   if (mCleared || !mAllowed) {
     return;
   }
 
   if (mTimeoutTimer) {
     mTimeoutTimer->Cancel();
     mTimeoutTimer = nullptr;
@@ -538,19 +533,17 @@ nsGeolocationRequest::SendLocation(nsIDO
     }
   }
 
   if (!wrapped) {
     NotifyError(nsIDOMGeoPositionError::POSITION_UNAVAILABLE);
     return;
   }
 
-  if (aCachePosition) {
-    mLocator->SetCachedPosition(wrapped);
-  }
+  mLocator->SetCachedPosition(wrapped);
 
   // Ensure that the proper context is on the stack (bug 452762)
   nsCxPusher pusher;
   pusher.PushNull();
   nsAutoMicroTask mt;
   if (mCallback.HasWebIDLCallback()) {
     ErrorResult err;
     PositionCallback* callback = mCallback.GetWebIDLCallback();
@@ -579,33 +572,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 = false;
-    ev  = new RequestSendLocationEvent(aPosition,
-                                       true,
-                                       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
@@ -68,17 +68,17 @@ class nsGeolocationRequest
                        mozilla::idl::GeoPositionOptions* aOptions,
                        bool watchPositionRequest = false,
                        int32_t watchId = 0);
   void Shutdown();
 
   // Called by the geolocation device to notify that a location has changed.
   bool Update(nsIDOMGeoPosition* aPosition);
 
-  void SendLocation(nsIDOMGeoPosition* location, bool aCachePosition);
+  void SendLocation(nsIDOMGeoPosition* location);
   void MarkCleared();
   bool WantsHighAccuracy() {return mOptions && mOptions->enableHighAccuracy;}
   bool IsActive() {return !mCleared;}
   bool Allowed() {return mAllowed;}
   void SetTimeoutTimer();
   nsIPrincipal* GetPrincipal();
 
   ~nsGeolocationRequest();
@@ -87,17 +87,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;
   mozilla::dom::GeoPositionCallback mCallback;
   mozilla::dom::GeoPositionErrorCallback mErrorCallback;
   nsAutoPtr<mozilla::idl::GeoPositionOptions> mOptions;
 
   nsRefPtr<mozilla::dom::Geolocation> mLocator;