Backed out changeset 3c7cff7fc71d
authorGhislain 'Aus' Lacroix <glacroix@mozilla.com>
Thu, 17 Jul 2014 05:34:33 -0700
changeset 216555 2419a4ce8088ef8022bfd325285d08187969f994
parent 216554 3c7cff7fc71d0cae98359d4e64e707e898b80f5f
child 216556 de58560fbb42877f5e995823cb4fe796d054df2a
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone33.0a1
backs out3c7cff7fc71d0cae98359d4e64e707e898b80f5f
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 3c7cff7fc71d
dom/system/NetworkGeolocationProvider.js
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -448,77 +448,65 @@ WifiGeoPositionProvider.prototype = {
 
     if (gCellScanningEnabled) {
       let cellData = this.getMobileInfo();
       if (cellData && cellData.length > 0) {
         data.cellTowers = cellData;
       }
     }
 
-    let l = this.listener;
     let useCached = isCachedRequestMoreAccurateThanServerRequest(data.cellTowers,
                                                                  data.wifiAccessPoints);
 
     LOG("Use request cache:" + useCached + " reason:" + gDebugCacheReasoning);
 
     if (useCached) {
       gCachedRequest.location.timestamp = Date.now();
-      this.notifyListener(l.update, [gCachedRequest.location]);
+      this.listener.update(gCachedRequest.location);
       return;
     }
 
     // From here on, do a network geolocation request //
     let url = Services.urlFormatter.formatURLPref("geo.wifi.uri");
+    let listener = this.listener;
     LOG("Sending request: " + url + "\n");
 
     let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
                         .createInstance(Ci.nsIXMLHttpRequest);
 
-    this.notifyListener(l.locationUpdatePending);
+    listener.locationUpdatePending();
 
     try {
       xhr.open("POST", url, true);
     } catch (e) {
-      this.notifyListener(l.notifyError,
-                          [POSITION_UNAVAILABLE]);
+      listener.notifyError(POSITION_UNAVAILABLE);
       return;
     }
     xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
     xhr.responseType = "json";
     xhr.mozBackgroundRequest = true;
     xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
-    xhr.onerror = (function() {
-      this.notifyListener(l.notifyError,
-                          [POSITION_UNAVAILABLE]);
-    }).bind(this);
-    xhr.onload = (function() {
+    xhr.onerror = function() {
+      listener.notifyError(POSITION_UNAVAILABLE);
+    };
+    xhr.onload = function() {
       LOG("gls returned status: " + xhr.status + " --> " +  JSON.stringify(xhr.response));
       if ((xhr.channel instanceof Ci.nsIHttpChannel && xhr.status != 200) ||
           !xhr.response || !xhr.response.location) {
-        this.notifyListener(l.notifyError,
-                            [POSITION_UNAVAILABLE]);
+        listener.notifyError(POSITION_UNAVAILABLE);
         return;
       }
 
       let newLocation = new WifiGeoPositionObject(xhr.response.location.lat,
                                                   xhr.response.location.lng,
                                                   xhr.response.accuracy);
 
-      this.notifyListener(l.update, [newLocation]);
+      listener.update(newLocation);
       gCachedRequest = new CachedRequest(newLocation, data.cellTowers, data.wifiAccessPoints);
-    }).bind(this);
+    };
 
     var requestData = JSON.stringify(data);
     LOG("sending " + requestData);
     xhr.send(requestData);
   },
-
-  notifyListener: function(listenerFunc, args) {
-    args = args || [];
-    try {
-      this.listener[listenerFunc].apply(this.listener, args);
-    } catch(e) {
-      Cu.reportError(e);
-    }
-  }
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiGeoPositionProvider]);