mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 04:58:00 +00:00
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:
parent
51ff161768
commit
dcde606dc7
@ -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();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -572,6 +572,8 @@ this.PushServiceHttp2 = {
|
||||
console.debug("init()");
|
||||
this._mainPushService = aMainPushService;
|
||||
this._serverURI = aServerURL;
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
_retryAfterBackoff: function(aSubscriptionUri, retryAfter) {
|
||||
|
@ -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 () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user