Bug 917051 - SimplePush: Clean up unregister related code. r=dougt
authorNikhil Marathe <nsm.nikhil@gmail.com>
Mon, 16 Sep 2013 23:47:47 -0700
changeset 156054 104e23b7018783aabca4f2d1fd5364fedeb0ab0b
parent 156053 a0ec683fa04256139c86232d67ec8bab019ad4a2
child 156055 b9121c28d2d3c35d5e494a1e050405e4b94aeeb4
push idunknown
push userunknown
push dateunknown
reviewersdougt
bugs917051
milestone26.0a1
Bug 917051 - SimplePush: Clean up unregister related code. r=dougt
dom/push/src/PushService.jsm
--- 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: " +