Bug 1150683 - Add XPCOM interfaces for push notifications. r=dougt
authorKit Cambridge <github@kitcambridge.be>
Tue, 21 Apr 2015 20:10:50 +0200
changeset 271749 fb6500be1479efa1d1f837d805cf4d8efe88dcf0
parent 271748 1023edc0a85ee890f2297ec232d49845056676b6
child 271750 f6c0ba775c8a245df6cfd79c1ba93edda548a108
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs1150683, 100644
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 1150683 - Add XPCOM interfaces for push notifications. r=dougt --- b2g/installer/package-manifest.in | 1 + browser/installer/package-manifest.in | 1 + dom/interfaces/push/moz.build | 12 ++++++ dom/interfaces/push/nsIPushNotificationService.idl | 49 ++++++++++++++++++++++ .../push/nsIPushObserverNotification.idl | 30 +++++++++++++ dom/moz.build | 1 + 6 files changed, 94 insertions(+) create mode 100644 dom/interfaces/push/moz.build create mode 100644 dom/interfaces/push/nsIPushNotificationService.idl create mode 100644 dom/interfaces/push/nsIPushObserverNotification.idl
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
dom/interfaces/push/moz.build
dom/interfaces/push/nsIPushNotificationService.idl
dom/interfaces/push/nsIPushObserverNotification.idl
dom/moz.build
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -204,16 +204,17 @@
 #endif
 @RESPATH@/components/dom_notification.xpt
 @RESPATH@/components/dom_html.xpt
 @RESPATH@/components/dom_offline.xpt
 @RESPATH@/components/dom_payment.xpt
 @RESPATH@/components/dom_json.xpt
 @RESPATH@/components/dom_messages.xpt
 @RESPATH@/components/dom_power.xpt
+@RESPATH@/components/dom_push.xpt
 @RESPATH@/components/dom_quota.xpt
 @RESPATH@/components/dom_range.xpt
 @RESPATH@/components/dom_security.xpt
 @RESPATH@/components/dom_settings.xpt
 @RESPATH@/components/dom_permissionsettings.xpt
 @RESPATH@/components/dom_sidebar.xpt
 @RESPATH@/components/dom_cellbroadcast.xpt
 @RESPATH@/components/dom_icc.xpt
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -213,16 +213,17 @@
 @RESPATH@/components/dom_media.xpt
 @RESPATH@/components/dom_network.xpt
 @RESPATH@/components/dom_notification.xpt
 @RESPATH@/components/dom_html.xpt
 @RESPATH@/components/dom_icc.xpt
 @RESPATH@/components/dom_offline.xpt
 @RESPATH@/components/dom_json.xpt
 @RESPATH@/components/dom_power.xpt
+@RESPATH@/components/dom_push.xpt
 @RESPATH@/components/dom_quota.xpt
 @RESPATH@/components/dom_range.xpt
 @RESPATH@/components/dom_security.xpt
 @RESPATH@/components/dom_settings.xpt
 @RESPATH@/components/dom_permissionsettings.xpt
 @RESPATH@/components/dom_sidebar.xpt
 @RESPATH@/components/dom_cellbroadcast.xpt
 @RESPATH@/components/dom_mobilemessage.xpt
new file mode 100644
--- /dev/null
+++ b/dom/interfaces/push/moz.build
@@ -0,0 +1,12 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+XPIDL_SOURCES += [
+    'nsIPushNotificationService.idl',
+    'nsIPushObserverNotification.idl',
+]
+
+XPIDL_MODULE = 'dom_push'
new file mode 100644
--- /dev/null
+++ b/dom/interfaces/push/nsIPushNotificationService.idl
@@ -0,0 +1,49 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+/**
+ * A service for components to subscribe and receive push messages from web
+ * services. This functionality is exposed to content via the Push API, which
+ * uses service workers to notify applications. This interface exists to allow
+ * privileged code to receive messages without migrating to service workers.
+ */
+[scriptable, uuid(32028e38-903b-4a64-a180-5857eb4cb3dd)]
+interface nsIPushNotificationService : nsISupports
+{
+  /**
+   * Creates a push subscription for the given |scope| URL and |pageURL|.
+   * Returns a promise for the new subscription record, or the existing
+   * record if this |scope| already has a subscription.
+   *
+   * The |pushEndpoint| property of the subscription record is a URL string
+   * that can be used to send push messages to subscribers. For details,
+   * please see the Simple Push protocol docs.
+   *
+   * Each incoming message fires a `push-notification` observer
+   * notification, with an `nsIPushObserverNotification` as the subject and
+   * the |scope| as the data.
+   *
+   * If the server drops a subscription, a `push-subscription-change` observer
+   * will be fired, with the subject set to `null` and the data set to |scope|.
+   * Servers may drop subscriptions at any time, so callers should recreate
+   * subscriptions if desired.
+   */
+  jsval register(in string scope, [optional] in string pageURL);
+
+  /**
+   * Revokes a push subscription for the given |scope|. Returns a promise
+   * for the revoked subscription record, or `null` if the |scope| is not
+   * subscribed to receive notifications.
+   */
+  jsval unregister(in string scope);
+
+  /**
+   * Returns a promise for the subscription record associated with the
+   * given |scope|, or `null` if the |scope| does not have a subscription.
+   */
+  jsval registration(in string scope);
+};
new file mode 100644
--- /dev/null
+++ b/dom/interfaces/push/nsIPushObserverNotification.idl
@@ -0,0 +1,30 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+/**
+ * A push message received by an `nsIPushNotificationService`, used as the
+ * subject of a `push-notification` observer notification.
+ */
+[scriptable, uuid(66a87970-6dc9-46e0-ac61-adb4a13791de)]
+interface nsIPushObserverNotification : nsISupports
+{
+  /* The URL that receives push messages from an application server. */
+  attribute string pushEndpoint;
+
+  /**
+   * The notification version sent by the application server. This is a
+   * monotonically increasing number.
+   */
+  attribute long long version;
+
+  /**
+   * The notification payload. Delivery is not guaranteed; if the browser is
+   * offline when the application server sends the push message, the payload
+   * may be discarded.
+   */
+  attribute string data;
+};
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -21,16 +21,17 @@ interfaces = [
     'range',
     'xbl',
     'xpath',
     'xul',
     'security',
     'storage',
     'json',
     'offline',
+    'push',
     'geolocation',
     'notification',
     'permission',
     'svg',
     'smil',
     'apps',
     'gamepad',
 ]