Bug 1144495 - Enable deleting notifications from notificationStorage when the app is been killed. r=mhenretty, r=gerard-majax
authorKuoE0 <kuoe0@mozilla.com>
Mon, 06 Apr 2015 09:44:00 -0400
changeset 237962 319487767756b110a21948b338745aa9c0f5c71a
parent 237961 0addaa4d5c19d9b4085f7a6f709ab383afc6f188
child 237963 f47633f4ded27aa31dea24fdea310f667a1532c9
push id58080
push userryanvm@gmail.com
push dateTue, 07 Apr 2015 20:23:52 +0000
treeherdermozilla-inbound@105106bde936 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhenretty, gerard-majax
bugs1144495
milestone40.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 1144495 - Enable deleting notifications from notificationStorage when the app is been killed. r=mhenretty, r=gerard-majax Remove parameter dbId from message to send to system messager and add parity to use detail.type to determine event type.
b2g/components/AlertsHelper.jsm
b2g/components/AlertsService.js
--- a/b2g/components/AlertsHelper.jsm
+++ b/b2g/components/AlertsHelper.jsm
@@ -20,16 +20,20 @@ XPCOMUtils.defineLazyServiceGetter(this,
 
 XPCOMUtils.defineLazyServiceGetter(this, "appsService",
                                    "@mozilla.org/AppsService;1",
                                    "nsIAppsService");
 
 XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
                                   "resource://gre/modules/SystemAppProxy.jsm");
 
+XPCOMUtils.defineLazyServiceGetter(this, "notificationStorage",
+                                   "@mozilla.org/notificationStorage;1",
+                                   "nsINotificationStorage");
+
 XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
   return Cc["@mozilla.org/parentprocessmessagemanager;1"]
          .getService(Ci.nsIMessageListenerManager);
 });
 
 function debug(str) {
   //dump("=*= AlertsHelper.jsm : " + str + "\n");
 }
@@ -152,20 +156,23 @@ let AlertsHelper = {
               timestamp: listener.timestamp,
               data: listener.dataObj
             },
             Services.io.newURI(listener.target, null, null),
             Services.io.newURI(listener.manifestURL, null, null)
           );
         }
       }
+      if (detail.type === kDesktopNotificationClose && listener.dbId) {
+        notificationStorage.delete(listener.manifestURL, listener.dbId);
+      }
     }
 
     // we"re done with this notification
-    if (topic === kTopicAlertFinished) {
+    if (detail.type === kDesktopNotificationClose) {
       delete this._listeners[uid];
     }
   },
 
   registerListener: function(alertId, cookie, alertListener) {
     this._listeners[alertId] = { observer: alertListener, cookie: cookie };
   },
 
@@ -280,16 +287,17 @@ let AlertsHelper = {
     let listener = {
       mm: aMessage.target,
       title: data.title,
       text: data.text,
       manifestURL: details.manifestURL,
       imageURL: data.imageURL,
       lang: details.lang || undefined,
       id: details.id || undefined,
+      dbId: details.dbId || undefined,
       dir: details.dir || undefined,
       tag: details.tag || undefined,
       timestamp: details.timestamp || undefined,
       dataObj: dataObject || undefined
     };
     this.registerAppListener(data.uid, listener);
     this.showNotification(data.imageURL, data.title, data.text,
                           details.textClickable, null, data.uid, details.dir,
--- a/b2g/components/AlertsService.js
+++ b/b2g/components/AlertsService.js
@@ -149,17 +149,16 @@ AlertsService.prototype = {
               clicked: (topic === kTopicAlertClickCallback),
               title: listener.title,
               body: listener.text,
               imageURL: listener.imageURL,
               lang: listener.lang,
               dir: listener.dir,
               id: listener.id,
               tag: listener.tag,
-              dbId: listener.dbId,
               timestamp: listener.timestamp,
               data: listener.dataObj || undefined,
             },
             Services.io.newURI(data.target, null, null),
             Services.io.newURI(listener.manifestURL, null, null)
           );
         }
       }