Bug 1354721 - Cleanup network geo provider: removed unneeded
listener function wrapper and the call to non-existent
listener.locationUpdatePending()
MozReview-Commit-ID: 2HqXKy52xEW
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -361,75 +361,64 @@ WifiGeoPositionProvider.prototype = {
let useCached = isCachedRequestMoreAccurateThanServerRequest(data.cellTowers,
data.wifiAccessPoints);
LOG("Use request cache:" + useCached + " reason:" + gDebugCacheReasoning);
if (useCached) {
gCachedRequest.location.timestamp = Date.now();
- this.notifyListener("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");
LOG("Sending request");
let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Ci.nsIXMLHttpRequest);
- this.notifyListener("locationUpdatePending");
-
try {
xhr.open("POST", url, true);
xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
} catch (e) {
- this.notifyListener("notifyError",
- [POSITION_UNAVAILABLE]);
+ this.listener.notifyError(POSITION_UNAVAILABLE);
return;
}
xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
xhr.responseType = "json";
xhr.mozBackgroundRequest = true;
xhr.timeout = Services.prefs.getIntPref("geo.wifi.xhr.timeout");
xhr.ontimeout = (function() {
LOG("Location request XHR timed out.")
- this.notifyListener("notifyError",
- [POSITION_UNAVAILABLE]);
+ this.listener.notifyError(POSITION_UNAVAILABLE);
}).bind(this);
xhr.onerror = (function() {
- this.notifyListener("notifyError",
- [POSITION_UNAVAILABLE]);
+ this.listener.notifyError(POSITION_UNAVAILABLE);
}).bind(this);
+
xhr.onload = (function() {
LOG("server returned status: " + xhr.status + " --> " + JSON.stringify(xhr.response));
if ((xhr.channel instanceof Ci.nsIHttpChannel && xhr.status != 200) ||
!xhr.response || !xhr.response.location) {
- this.notifyListener("notifyError",
- [POSITION_UNAVAILABLE]);
+ this.listener.notifyError(POSITION_UNAVAILABLE);
return;
}
let newLocation = new WifiGeoPositionObject(xhr.response.location.lat,
xhr.response.location.lng,
xhr.response.accuracy);
- this.notifyListener("update", [newLocation]);
+ this.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);
- }
+ enableLoggingToListener: function(isEnabled) {
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiGeoPositionProvider]);