Backed out changeset 403bbc5e127f (bug 914888) for intermittent xpcshell failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 16 Oct 2013 16:19:48 -0400
changeset 164890 1850054aca10e97833160551b7c5726609c20262
parent 164889 6eec00ce41937887b891932b2008b8ada65d6f1f
child 164891 e41c12eedc22bf947a2c247ec2779cf577c756b9
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs914888
milestone27.0a1
backs out403bbc5e127fe42d7dbd1bfdf8a897df66862480
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
Backed out changeset 403bbc5e127f (bug 914888) for intermittent xpcshell failures.
dom/src/geolocation/nsGeolocation.cpp
dom/src/geolocation/nsGeolocation.h
dom/system/NetworkGeolocationProvider.js
dom/tests/unit/test_geolocation_reset_accuracy.js
dom/tests/unit/test_geolocation_reset_accuracy_wrap.js
dom/tests/unit/xpcshell.ini
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -72,17 +72,17 @@ class nsGeolocationRequest
                        const GeoPositionCallback& aCallback,
                        const GeoPositionErrorCallback& aErrorCallback,
                        PositionOptions* aOptions,
                        bool aWatchPositionRequest = false,
                        int32_t aWatchId = 0);
   void Shutdown();
 
   void SendLocation(nsIDOMGeoPosition* location);
-  bool WantsHighAccuracy() {return !mShutdown && mOptions && mOptions->mEnableHighAccuracy;}
+  bool WantsHighAccuracy() {return mOptions && mOptions->mEnableHighAccuracy;}
   void SetTimeoutTimer();
   nsIPrincipal* GetPrincipal();
 
   ~nsGeolocationRequest();
 
   virtual bool Recv__delete__(const bool& allow) MOZ_OVERRIDE;
   virtual void IPDLRelease() MOZ_OVERRIDE { Release(); }
 
@@ -440,17 +440,17 @@ nsGeolocationRequest::Allow()
   // if the user has specified a maximumAge, return a cached value.
 
   uint32_t maximumAge = 0;
   if (mOptions) {
     if (mOptions->mMaximumAge > 0) {
       maximumAge = mOptions->mMaximumAge;
     }
   }
-  gs->UpdateAccuracy(WantsHighAccuracy());
+  gs->SetHigherAccuracy(mOptions && mOptions->mEnableHighAccuracy);
 
   bool canUseCache = lastPosition && maximumAge > 0 &&
     (PRTime(PR_Now() / PR_USEC_PER_MSEC) - maximumAge <=
     PRTime(cachedPositionTime));
 
   if (canUseCache) {
     // okay, we can return a cached position
     // getCurrentPosition requests serviced by the cache
@@ -580,22 +580,22 @@ nsGeolocationRequest::Shutdown()
   MOZ_ASSERT(!mShutdown, "request shutdown twice");
   mShutdown = true;
 
   if (mTimeoutTimer) {
     mTimeoutTimer->Cancel();
     mTimeoutTimer = nullptr;
   }
 
-  // If there are no other high accuracy requests, the geolocation service will
-  // notify the provider to switch to the default accuracy.
+  // This should happen last, to ensure that this request isn't taken into consideration
+  // when deciding whether existing requests still require high accuracy.
   if (mOptions && mOptions->mEnableHighAccuracy) {
     nsRefPtr<nsGeolocationService> gs = nsGeolocationService::GetGeolocationService();
     if (gs) {
-      gs->UpdateAccuracy();
+      gs->SetHigherAccuracy(false);
     }
   }
 }
 
 bool nsGeolocationRequest::Recv__delete__(const bool& allow)
 {
   if (allow) {
     (void) Allow();
@@ -896,19 +896,19 @@ nsGeolocationService::HighAccuracyReques
     if (mGeolocators[i]->HighAccuracyRequested()) {
       return true;
     }
   }
   return false;
 }
 
 void
-nsGeolocationService::UpdateAccuracy(bool aForceHigh)
+nsGeolocationService::SetHigherAccuracy(bool aEnable)
 {
-  bool highRequired = aForceHigh || HighAccuracyRequested();
+  bool highRequired = aEnable || HighAccuracyRequested();
 
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     ContentChild* cpc = ContentChild::GetSingleton();
     cpc->SendSetGeolocationHigherAccuracy(highRequired);
     return;
   }
 
   if (!mHigherAccuracy && highRequired) {
@@ -1056,17 +1056,16 @@ void
 Geolocation::Shutdown()
 {
   // Release all callbacks
   mPendingCallbacks.Clear();
   mWatchingCallbacks.Clear();
 
   if (mService) {
     mService->RemoveLocator(this);
-    mService->UpdateAccuracy();
   }
 
   mService = nullptr;
   mPrincipal = nullptr;
 }
 
 nsIDOMWindow*
 Geolocation::GetParentObject() const {
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -80,18 +80,18 @@ public:
   nsresult StartDevice(nsIPrincipal* aPrincipal);
 
   // Stop the started geolocation device (gps, nmea, etc.)
   void     StopDevice();
 
   // create, or reinitalize the callback timer
   void     SetDisconnectTimer();
 
-  // Update the accuracy and notify the provider if changed
-  void     UpdateAccuracy(bool aForceHigh = false);
+  // request higher accuracy, if possible
+  void     SetHigherAccuracy(bool aEnable);
   bool     HighAccuracyRequested();
 
 private:
 
   ~nsGeolocationService();
 
   // Disconnect timer.  When this timer expires, it clears all pending callbacks
   // and closes down the provider, unless we are watching a point, and in that
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -68,19 +68,16 @@ function WifiGeoPositionProvider() {
   try {
     gUseScanning = Services.prefs.getBoolPref("geo.wifi.scan");
   } catch (e) {}
 
   this.wifiService = null;
   this.timer = null;
   this.hasSeenWiFi = false;
   this.started = false;
-  // this is only used when logging is enabled, to debug interactions with the
-  // geolocation service
-  this.highAccuracy = false;
 }
 
 WifiGeoPositionProvider.prototype = {
   classID:          Components.ID("{77DA64D3-7458-4920-9491-86CC9914F904}"),
   QueryInterface:   XPCOMUtils.generateQI([Ci.nsIGeolocationProvider,
                                            Ci.nsIWifiListener,
                                            Ci.nsITimerCallback]),
   startup:  function() {
@@ -130,22 +127,20 @@ WifiGeoPositionProvider.prototype = {
       this.timer.cancel();
       this.timer = null;
     }
 
     this.started = false;
   },
 
   setHighAccuracy: function(enable) {
-    this.highAccuracy = enable;
-    LOG("setting highAccuracy to " + (this.highAccuracy?"TRUE":"FALSE"));
   },
 
   onChange: function(accessPoints) {
-    LOG("onChange called, highAccuracy = " + (this.highAccuracy?"TRUE":"FALSE"));
+    LOG("onChange called");
     this.hasSeenWiFi = true;
 
     let url = Services.urlFormatter.formatURLPref("geo.wifi.uri");
 
     function isPublic(ap) {
         let mask = "_nomap"
         let result = ap.ssid.indexOf(mask, ap.ssid.length - mask.length) == -1;
         if (result != -1) {
deleted file mode 100644
--- a/dom/tests/unit/test_geolocation_reset_accuracy.js
+++ /dev/null
@@ -1,104 +0,0 @@
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-const providerCID = Components.ID("{14aa4b81-e266-45cb-88f8-89595dece114}");
-const providerContract = "@mozilla.org/geolocation/provider;1";
-
-const categoryName = "geolocation-provider";
-
-var provider = {
-  QueryInterface: function eventsink_qi(iid) {
-    if (iid.equals(Components.interfaces.nsISupports) ||
-        iid.equals(Components.interfaces.nsIFactory) ||
-        iid.equals(Components.interfaces.nsIGeolocationProvider))
-      return this;
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-  },
-  createInstance: function eventsink_ci(outer, iid) {
-    if (outer)
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-    return this.QueryInterface(iid);
-  },
-  lockFactory: function eventsink_lockf(lock) {
-    throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-  },
-  startup: function() {
-  },
-  watch: function() {
-  },
-  shutdown: function() {
-  },
-  setHighAccuracy: function(enable) {
-    this._isHigh = enable;
-    if (enable) {
-      this._seenHigh = true;
-    }
-  },
-  _isHigh: false,
-  _seenHigh: false
-};
-
-let runningInParent = true;
-try {
-  runningInParent = Components.classes["@mozilla.org/xre/runtime;1"].
-                    getService(Components.interfaces.nsIXULRuntime).processType
-                    == Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
-}
-catch (e) { }
-
-function successCallback()
-{
-  do_check_true(false);
-  do_test_finished();
-}
-
-function errorCallback()
-{
-  do_check_true(false);
-  do_test_finished();
-}
-
-function run_test()
-{
-  if (runningInParent) {
-    // XPCShell does not get a profile by default. The geolocation service
-    // depends on the settings service which uses IndexedDB and IndexedDB
-    // needs a place where it can store databases.
-    do_get_profile();
-
-    Components.manager.nsIComponentRegistrar.registerFactory(providerCID,
-      "Unit test geo provider", providerContract, provider);
-    var catMan = Components.classes["@mozilla.org/categorymanager;1"]
-                           .getService(Components.interfaces.nsICategoryManager);
-    catMan.nsICategoryManager.addCategoryEntry(categoryName, "unit test",
-                                               providerContract, false, true);
-
-    var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-    prefs.setBoolPref("geo.testing.ignore_ipc_principal", true);
-    prefs.setBoolPref("geo.wifi.scan", false);
-  }
-
-  let geolocation = Cc["@mozilla.org/geolocation;1"].createInstance(Ci.nsISupports);
-
-  do_test_pending();
-
-  let watchID1 = geolocation.watchPosition(successCallback, errorCallback);
-  let watchID2 = geolocation.watchPosition(successCallback, errorCallback,
-                                           {enableHighAccuracy: true});
-
-  do_timeout(1000, function() {
-    geolocation.clearWatch(watchID2);
-    do_timeout(1000, check_results);
-  });
-}
-
-function check_results()
-{
-  if (runningInParent) {
-    // check the provider was set to high accuracy during the test
-    do_check_true(provider._seenHigh);
-    // check the provider is not currently set to high accuracy
-    do_check_false(provider._isHigh);
-  }
-  do_test_finished();
-}
deleted file mode 100644
--- a/dom/tests/unit/test_geolocation_reset_accuracy_wrap.js
+++ /dev/null
@@ -1,70 +0,0 @@
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-const providerCID = Components.ID("{14aa4b81-e266-45cb-88f8-89595dece114}");
-const providerContract = "@mozilla.org/geolocation/provider;1";
-
-const categoryName = "geolocation-provider";
-
-var provider = {
-  QueryInterface: function eventsink_qi(iid) {
-    if (iid.equals(Components.interfaces.nsISupports) ||
-        iid.equals(Components.interfaces.nsIFactory) ||
-        iid.equals(Components.interfaces.nsIGeolocationProvider))
-      return this;
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-  },
-  createInstance: function eventsink_ci(outer, iid) {
-    if (outer)
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-    return this.QueryInterface(iid);
-  },
-  lockFactory: function eventsink_lockf(lock) {
-    throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-  },
-  startup: function() {
-  },
-  watch: function() {
-  },
-  shutdown: function() {
-  },
-  setHighAccuracy: function(enable) {
-    this._isHigh = enable;
-    if (enable) {
-      this._seenHigh = true;
-    }
-  },
-  _isHigh: false,
-  _seenHigh: false
-};
-
-function run_test()
-{
-  // XPCShell does not get a profile by default. The geolocation service
-  // depends on the settings service which uses IndexedDB and IndexedDB
-  // needs a place where it can store databases.
-  do_get_profile();
-
-  Components.manager.nsIComponentRegistrar.registerFactory(providerCID,
-    "Unit test geo provider", providerContract, provider);
-  var catMan = Components.classes["@mozilla.org/categorymanager;1"]
-                         .getService(Components.interfaces.nsICategoryManager);
-  catMan.nsICategoryManager.addCategoryEntry(categoryName, "unit test",
-                                             providerContract, false, true);
-
-  var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-  prefs.setBoolPref("geo.testing.ignore_ipc_principal", true);
-  prefs.setBoolPref("geo.wifi.scan", false);
-
-  run_test_in_child("test_geolocation_reset_accuracy.js", check_results);
-}
-
-function check_results()
-{
-  // check the provider was set to high accuracy during the test
-  do_check_true(provider._seenHigh);
-  // check the provider is not currently set to high accuracy
-  do_check_false(provider._isHigh);
-
-  do_test_finished();
-}
--- a/dom/tests/unit/xpcshell.ini
+++ b/dom/tests/unit/xpcshell.ini
@@ -7,13 +7,8 @@ tail =
 [test_geolocation_provider.js]
 # Bug 684962: test hangs consistently on Android
 skip-if = os == "android"
 [test_geolocation_timeout.js]
 # Bug 919946: test hangs consistently on Android
 skip-if = os == "android"
 [test_geolocation_timeout_wrap.js]
 skip-if = os == "mac" || os == "android"
-[test_geolocation_reset_accuracy.js]
-# Bug 919946: test hangs consistently on Android
-skip-if = os == "android"
-[test_geolocation_reset_accuracy_wrap.js]
-skip-if = os == "mac" || os == "android"