Bug 1240615 - Make PushService protocol init method return a Promise. r=kitcambridge

I'd like to make `PushService.init` fallible, but it's not obvious how
to act on failure.  This patch at least allows each service to block
_startService until service-specific work initialization is complete.

--HG--
extra : rebase_source : 641bb24429116b4a1db10343b04f83cc6331dc39
This commit is contained in:
Nick Alexander 2015-11-18 15:55:13 -08:00
parent 51ff161768
commit dcde606dc7
3 changed files with 10 additions and 4 deletions

View File

@ -513,7 +513,7 @@ this.PushService = {
console.debug("startService()");
if (this._state != PUSH_SERVICE_ACTIVATING) {
return;
return Promise.reject();
}
this._service = service;
@ -523,9 +523,11 @@ this.PushService = {
this._db = this._service.newPushDB();
}
this._service.init(options, this, serverURI);
this._startObservers();
return this._dropExpiredRegistrations();
return this._service.init(options, this, serverURI)
.then(() => {
this._startObservers();
return this._dropExpiredRegistrations();
});
},
/**

View File

@ -572,6 +572,8 @@ this.PushServiceHttp2 = {
console.debug("init()");
this._mainPushService = aMainPushService;
this._serverURI = aServerURL;
return Promise.resolve();
},
_retryAfterBackoff: function(aSubscriptionUri, retryAfter) {

View File

@ -299,6 +299,8 @@ this.PushServiceWebSocket = {
this._requestTimeout = prefs.get("requestTimeout");
this._adaptiveEnabled = prefs.get('adaptive.enabled');
this._upperLimit = prefs.get('adaptive.upperLimit');
return Promise.resolve();
},
_reconnect: function () {