Bug 917051 - SimplePush: Clean up unregister related code. r=dougt
--- a/dom/push/src/PushService.jsm
+++ b/dom/push/src/PushService.jsm
@@ -822,38 +822,16 @@ this.PushService = {
} else {
tmp.deferred.reject(reply);
}
},
/**
* Protocol handler invoked by server message.
*/
- _handleUnregisterReply: function(reply) {
- debug("handleUnregisterReply()");
- if (typeof reply.channelID !== "string" ||
- typeof this._pendingRequests[reply.channelID] !== "object")
- return;
-
- let tmp = this._pendingRequests[reply.channelID];
- delete this._pendingRequests[reply.channelID];
- if (Object.keys(this._pendingRequests).length == 0 &&
- this._requestTimeoutTimer)
- this._requestTimeoutTimer.cancel();
-
- if (reply.status == 200) {
- tmp.deferred.resolve(reply);
- } else {
- tmp.deferred.reject(reply);
- }
- },
-
- /**
- * Protocol handler invoked by server message.
- */
_handleNotificationReply: function(reply) {
debug("handleNotificationReply()");
if (typeof reply.updates !== 'object') {
debug("No 'updates' field in response. Type = " + typeof reply.updates);
return;
}
debug("Reply updates: " + reply.updates.length);
@@ -1152,17 +1130,17 @@ this.PushService = {
this._updatePushRecord(record)
.then(
function() {
message["pushEndpoint"] = data.pushEndpoint;
deferred.resolve(message);
},
function(error) {
// Unable to save.
- this._sendRequest("unregister", {channelID: record.channelID});
+ this._send("unregister", {channelID: record.channelID});
message["error"] = error;
deferred.reject(message);
}
);
return deferred.promise;
},
@@ -1367,17 +1345,17 @@ this.PushService = {
if (typeof reply.messageType != "string") {
debug("messageType not a string " + reply.messageType);
return;
}
// A whitelist of protocol handlers. Add to these if new messages are added
// in the protocol.
- let handlers = ["Hello", "Register", "Unregister", "Notification"];
+ let handlers = ["Hello", "Register", "Notification"];
// Build up the handler name to call from messageType.
// e.g. messageType == "register" -> _handleRegisterReply.
let handlerName = reply.messageType[0].toUpperCase() +
reply.messageType.slice(1).toLowerCase();
if (handlers.indexOf(handlerName) == -1) {
debug("No whitelisted handler " + handlerName + ". messageType: " +