Bug 1216683 - For the WebSocket version unregister should return true even if we are offline. r=kitcambridge
authorDragana Damjanovic <dd.mozilla@gmail.com>
Tue, 27 Oct 2015 09:13:00 +0100
changeset 270006 b6cf4c726f704d1e923e63ae93f9dc281db215bd
parent 270005 29c9e01ef7a297e35d42ea127e76f6b79377af59
child 270007 40b23b4f5267c26478bc834a9dfafee84392f65b
push id29596
push userkwierso@gmail.com
push dateThu, 29 Oct 2015 00:00:32 +0000
treeherdermozilla-central@1e700005a0dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskitcambridge
bugs1216683
milestone44.0a1
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
Bug 1216683 - For the WebSocket version unregister should return true even if we are offline. r=kitcambridge
dom/push/PushService.jsm
dom/push/PushServiceHttp2.jsm
dom/push/PushServiceWebSocket.jsm
--- a/dom/push/PushService.jsm
+++ b/dom/push/PushService.jsm
@@ -920,16 +920,19 @@ this.PushService = {
   getAllUnexpired: function() {
     return this._db.getAllUnexpired();
   },
 
   _sendRequest: function(action, aRecord) {
     if (this._state == PUSH_SERVICE_CONNECTION_DISABLE) {
       return Promise.reject({state: 0, error: "Service not active"});
     } else if (this._state == PUSH_SERVICE_ACTIVE_OFFLINE) {
+      if (this._service.serviceType() == "WebSocket" && action == "unregister") {
+        return Promise.resolve();
+      }
       return Promise.reject({state: 0, error: "NetworkError"});
     }
     return this._service.request(action, aRecord);
   },
 
   /**
    * Called on message from the child process. aPageRecord is an object sent by
    * navigator.push, identifying the sending page and other fields.
--- a/dom/push/PushServiceHttp2.jsm
+++ b/dom/push/PushServiceHttp2.jsm
@@ -436,16 +436,20 @@ this.PushServiceHttp2 = {
   newPushDB: function() {
     return new PushDB(kPUSHHTTP2DB_DB_NAME,
                       kPUSHHTTP2DB_DB_VERSION,
                       kPUSHHTTP2DB_STORE_NAME,
                       "subscriptionUri",
                       PushRecordHttp2);
   },
 
+  serviceType: function() {
+    return "http2";
+  },
+
   hasmainPushService: function() {
     return this._mainPushService !== null;
   },
 
   checkServerURI: function(serverURL) {
     if (!serverURL) {
       debug("No dom.push.serverURL found!");
       return;
--- a/dom/push/PushServiceWebSocket.jsm
+++ b/dom/push/PushServiceWebSocket.jsm
@@ -152,16 +152,20 @@ this.PushServiceWebSocket = {
   newPushDB: function() {
     return new PushDB(kPUSHWSDB_DB_NAME,
                       kPUSHWSDB_DB_VERSION,
                       kPUSHWSDB_STORE_NAME,
                       "channelID",
                       PushRecordWebSocket);
   },
 
+  serviceType: function() {
+    return "WebSocket";
+  },
+
   disconnect: function() {
     this._shutdownWS();
   },
 
   observe: function(aSubject, aTopic, aData) {
 
     switch (aTopic) {
     case "nsPref:changed":