Bug 1253159 - Remove locationUpdatePending and restore request timeout. r=jdm
authorDoug Turner <dougt@mozilla.com>
Wed, 02 Mar 2016 21:48:00 -0500
changeset 323212 698dde02eae20b3b2ec49e79bcbe299d3fe033d5
parent 323211 953741f757abdb9b12719aba565d82209a46ab7b
child 323213 9e99bde8d25469407cb1f86965ca7beacde95737
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs1253159
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1253159 - Remove locationUpdatePending and restore request timeout. r=jdm
dom/geolocation/nsGeolocation.cpp
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/mac/CoreLocationLocationProvider.mm
dom/system/windows/WindowsLocationProvider.cpp
xpcom/system/nsIGeolocationProvider.idl
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -402,31 +402,27 @@ nsGeolocationRequest::~nsGeolocationRequ
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGeolocationRequest)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentPermissionRequest)
   NS_INTERFACE_MAP_ENTRY(nsIContentPermissionRequest)
   NS_INTERFACE_MAP_ENTRY(nsIGeolocationUpdate)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGeolocationRequest)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGeolocationRequest)
-
 NS_IMPL_CYCLE_COLLECTION(nsGeolocationRequest, mCallback, mErrorCallback, mLocator)
-
 void
 nsGeolocationRequest::Notify()
 {
-  StopTimeoutTimer();
+  SetTimeoutTimer();
   NotifyErrorAndShutdown(nsIDOMGeoPositionError::TIMEOUT);
 }
-
 void
 nsGeolocationRequest::NotifyErrorAndShutdown(uint16_t aErrorCode)
 {
   MOZ_ASSERT(!mShutdown, "timeout after shutdown");
-
   if (!mIsWatchPositionRequest) {
     Shutdown();
     mLocator->RemoveRequest(this);
   }
 
   NotifyError(aErrorCode);
 }
 
@@ -713,26 +709,23 @@ nsGeolocationRequest::SendLocation(nsIDO
   nsAutoMicroTask mt;
   if (mCallback.HasWebIDLCallback()) {
     PositionCallback* callback = mCallback.GetWebIDLCallback();
 
     MOZ_ASSERT(callback);
     callback->Call(*wrapped);
   } else {
     nsIDOMGeoPositionCallback* callback = mCallback.GetXPCOMCallback();
-
     MOZ_ASSERT(callback);
     callback->HandleEvent(aPosition);
   }
-
-  StopTimeoutTimer();
+  SetTimeoutTimer();
   MOZ_ASSERT(mShutdown || mIsWatchPositionRequest,
              "non-shutdown getCurrentPosition request after callback!");
 }
-
 nsIPrincipal*
 nsGeolocationRequest::GetPrincipal()
 {
   if (!mLocator) {
     return nullptr;
   }
   return mLocator->GetPrincipal();
 }
@@ -740,32 +733,20 @@ nsGeolocationRequest::GetPrincipal()
 NS_IMETHODIMP
 nsGeolocationRequest::Update(nsIDOMGeoPosition* aPosition)
 {
   nsCOMPtr<nsIDOMGeoPosition> pos = AdjustedLocation(aPosition);
   nsCOMPtr<nsIRunnable> ev = new RequestSendLocationEvent(pos, this);
   NS_DispatchToMainThread(ev);
   return NS_OK;
 }
-
-NS_IMETHODIMP
-nsGeolocationRequest::LocationUpdatePending()
-{
-  if (!mTimeoutTimer) {
-    SetTimeoutTimer();
-  }
-
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 nsGeolocationRequest::NotifyError(uint16_t aErrorCode)
 {
   MOZ_ASSERT(NS_IsMainThread());
-
   RefPtr<PositionError> positionError = new PositionError(mLocator, aErrorCode);
   positionError->NotifyCallback(mErrorCallback);
   return NS_OK;
 }
 
 void
 nsGeolocationRequest::Shutdown()
 {
@@ -1025,40 +1006,27 @@ nsGeolocationService::Observe(nsISupport
 }
 
 NS_IMETHODIMP
 nsGeolocationService::Update(nsIDOMGeoPosition *aSomewhere)
 {
   if (aSomewhere) {
     SetCachedPosition(aSomewhere);
   }
-
   for (uint32_t i = 0; i< mGeolocators.Length(); i++) {
     mGeolocators[i]->Update(aSomewhere);
   }
   return NS_OK;
 }
-
-NS_IMETHODIMP
-nsGeolocationService::LocationUpdatePending()
-{
-  for (uint32_t i = 0; i< mGeolocators.Length(); i++) {
-    mGeolocators[i]->LocationUpdatePending();
-  }
-
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 nsGeolocationService::NotifyError(uint16_t aErrorCode)
 {
   for (uint32_t i = 0; i < mGeolocators.Length(); i++) {
     mGeolocators[i]->NotifyError(aErrorCode);
   }
-
   return NS_OK;
 }
 
 void
 nsGeolocationService::SetCachedPosition(nsIDOMGeoPosition* aPosition)
 {
   mLastPosition.position = aPosition;
   mLastPosition.isHighAccuracy = mHigherAccuracy;
@@ -1471,39 +1439,25 @@ Geolocation::Update(nsIDOMGeoPosition *a
     mPendingCallbacks[i-1]->Update(aSomewhere);
     RemoveRequest(mPendingCallbacks[i-1]);
   }
 
   // notify everyone that is watching
   for (uint32_t i = 0; i < mWatchingCallbacks.Length(); i++) {
     mWatchingCallbacks[i]->Update(aSomewhere);
   }
-
   return NS_OK;
 }
-
-NS_IMETHODIMP
-Geolocation::LocationUpdatePending()
-{
-  // this event is only really interesting for watch callbacks
-  for (uint32_t i = 0; i < mWatchingCallbacks.Length(); i++) {
-    mWatchingCallbacks[i]->LocationUpdatePending();
-  }
-
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 Geolocation::NotifyError(uint16_t aErrorCode)
 {
   if (!WindowOwnerStillExists()) {
     Shutdown();
     return NS_OK;
   }
-
   mozilla::Telemetry::Accumulate(mozilla::Telemetry::GEOLOCATION_ERROR, true);
 
   for (uint32_t i = mPendingCallbacks.Length(); i > 0; i--) {
     mPendingCallbacks[i-1]->NotifyErrorAndShutdown(aErrorCode);
     //NotifyErrorAndShutdown() removes the request from the array
   }
 
   // notify everyone that is watching
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -959,33 +959,24 @@ GonkGPSGeolocationProvider::NetworkLocat
       }
 
       // This is a fallback case so that the GPS provider responds with its last
       // location rather than waiting for a more recent GPS or network location.
       // The service decides if the location is too old, not the provider.
       provider->mLocationCallback->Update(provider->mLastGPSPosition);
     }
   }
-
   provider->InjectLocation(lat, lon, acc);
   return NS_OK;
 }
-
-NS_IMETHODIMP
-GonkGPSGeolocationProvider::NetworkLocationUpdate::LocationUpdatePending()
-{
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::NetworkLocationUpdate::NotifyError(uint16_t error)
 {
   return NS_OK;
 }
-
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::Startup()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mStarted) {
     return NS_OK;
   }
--- a/dom/system/mac/CoreLocationLocationProvider.mm
+++ b/dom/system/mac/CoreLocationLocationProvider.mm
@@ -120,35 +120,26 @@ CoreLocationLocationProvider::MLSUpdate:
 NS_IMETHODIMP
 CoreLocationLocationProvider::MLSUpdate::Update(nsIDOMGeoPosition *position)
 {
   nsCOMPtr<nsIDOMGeoPositionCoords> coords;
   position->GetCoords(getter_AddRefs(coords));
   if (!coords) {
     return NS_ERROR_FAILURE;
   }
-
   mParentLocationProvider.Update(position);
   Telemetry::Accumulate(Telemetry::GEOLOCATION_OSX_SOURCE_IS_MLS, true);
   return NS_OK;
 }
-
-NS_IMETHODIMP
-CoreLocationLocationProvider::MLSUpdate::LocationUpdatePending()
-{
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 CoreLocationLocationProvider::MLSUpdate::NotifyError(uint16_t error)
 {
   mParentLocationProvider.NotifyError(error);
   return NS_OK;
 }
-
 class CoreLocationObjects {
 public:
   NS_METHOD Init(CoreLocationLocationProvider* aProvider) {
     mLocationManager = [[CLLocationManager alloc] init];
     NS_ENSURE_TRUE(mLocationManager, NS_ERROR_NOT_AVAILABLE);
 
     mLocationDelegate = [[LocationDelegate alloc] init:aProvider];
     NS_ENSURE_TRUE(mLocationDelegate, NS_ERROR_NOT_AVAILABLE);
--- a/dom/system/windows/WindowsLocationProvider.cpp
+++ b/dom/system/windows/WindowsLocationProvider.cpp
@@ -29,38 +29,28 @@ WindowsLocationProvider::MLSUpdate::Upda
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIDOMGeoPositionCoords> coords;
   aPosition->GetCoords(getter_AddRefs(coords));
   if (!coords) {
     return NS_ERROR_FAILURE;
   }
-
   Telemetry::Accumulate(Telemetry::GEOLOCATION_WIN8_SOURCE_IS_MLS, true);
-
   return mCallback->Update(aPosition);
 }
-
-NS_IMETHODIMP
-WindowsLocationProvider::MLSUpdate::LocationUpdatePending()
-{
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 WindowsLocationProvider::MLSUpdate::NotifyError(uint16_t aError)
 {
   if (!mCallback) {
     return NS_ERROR_FAILURE;
   }
   return mCallback->NotifyError(aError);
 }
 
-
 class LocationEvent final : public ILocationEvents
 {
 public:
   LocationEvent(nsIGeolocationUpdate* aCallback, WindowsLocationProvider *aProvider)
     : mCallback(aCallback), mProvider(aProvider), mCount(0) {
   }
 
   // IUnknown interface
--- a/xpcom/system/nsIGeolocationProvider.idl
+++ b/xpcom/system/nsIGeolocationProvider.idl
@@ -21,24 +21,16 @@ interface nsIGeolocationPrompt;
 interface nsIGeolocationUpdate : nsISupports {
 
   /**
    * Notify the geolocation service that a new geolocation
    * has been discovered.
    * This must be called on the main thread
    */
   void update(in nsIDOMGeoPosition position);
-
-  /**
-   * Notify the geolocation service that the location has
-   * potentially changed, and thus a new position is in the
-   * process of being acquired.
-   */
-  void locationUpdatePending();
-
   /**
    * Notify the geolocation service of an error.
    * This must be called on the main thread.
    * The parameter refers to one of the constants in the
    * nsIDOMGeoPositionError interface.
    * Use this to report spurious errors coming from the
    * provider; for errors occurring inside the methods in
    * the nsIGeolocationProvider interface, just use the return
@@ -78,14 +70,14 @@ interface nsIGeolocationProvider : nsISu
   /**
    * hint to provide to use any amount of power to provide a better result
    */
   void setHighAccuracy(in boolean enable);
 
 };
 
 %{C++
-/*  
+/*
     This must be implemented by geolocation providers.  It
     must support nsIGeolocationProvider.
 */
 #define NS_GEOLOCATION_PROVIDER_CONTRACTID "@mozilla.org/geolocation/provider;1"
 %}