Bug 1159310 - Remember the push count and last push time for push events. r=kit

--HG--
extra : rebase_source : 58b5f6f1b0e98e201f77b4ec3feabce6c8ef5394
This commit is contained in:
Doug Turner 2015-04-28 09:44:00 -04:00
Родитель c8e40d05a1
Коммит 9bf4add3ed
2 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -9,7 +9,7 @@
* A push message received by an `nsIPushNotificationService`, used as the
* subject of a `push-notification` observer notification.
*/
[scriptable, uuid(66a87970-6dc9-46e0-ac61-adb4a13791de)]
[scriptable, uuid(56f57607-28b6-44b0-aa56-3d4d3c88be15)]
interface nsIPushObserverNotification : nsISupports
{
/* The URL that receives push messages from an application server. */
@ -27,4 +27,14 @@ interface nsIPushObserverNotification : nsISupports
* may be discarded.
*/
attribute string data;
/**
* How many times has a push event occured against this pushEndpoint
*/
attribute long long pushCount;
/**
* The last time a push occured against this this pushEndpoint
*/
attribute long long lastPush;
};

Просмотреть файл

@ -1334,6 +1334,8 @@ this.PushService = {
aPushRecord.version < aLatestVersion) {
debug("Version changed, notifying app and updating DB");
aPushRecord.version = aLatestVersion;
aPushRecord.pushCount = aPushRecord.pushCount + 1;
aPushRecord.lastPush = new Date().getTime();
this._notifyApp(aPushRecord);
this._updatePushRecord(aPushRecord)
.then(
@ -1398,6 +1400,9 @@ this.PushService = {
notification.pushEndpoint = aPushRecord.pushEndpoint;
notification.version = aPushRecord.version;
notification.data = "";
notification.lastPush = aPushRecord.lastPush;
notification.pushCount = aPushRecord.pushCount;
Services.obs.notifyObservers(
notification,
"push-notification",
@ -1538,6 +1543,8 @@ this.PushService = {
pushEndpoint: data.pushEndpoint,
pageURL: aPageRecord.pageURL,
scope: aPageRecord.scope,
pushCount: 0,
lastPush: 0,
version: null
};
@ -1666,7 +1673,9 @@ this.PushService = {
if (pushRecord) {
registration = {
pushEndpoint: pushRecord.pushEndpoint,
version: pushRecord.version
version: pushRecord.version,
lastPush: pushRecord.lastPush,
pushCount: pushRecord.pushCount
};
}
resolve(registration);