Bug 1232910 - Use channel.asyncOpen2 within dom/push/PushServiceHttp2.jsm. r=sicking r=dragana

This commit is contained in:
Christoph Kerschbaumer 2016-01-19 20:00:18 -08:00
parent 57d9b3671d
commit cfdd9a36ce

View File

@ -14,6 +14,7 @@ const {PushDB} = Cu.import("resource://gre/modules/PushDB.jsm");
const {PushRecord} = Cu.import("resource://gre/modules/PushRecord.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
Cu.import("resource://gre/modules/Timer.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
@ -103,7 +104,7 @@ PushSubscriptionListener.prototype = {
onPush: function(associatedChannel, pushChannel) {
console.debug("PushSubscriptionListener: onPush()");
var pushChannelListener = new PushChannelListener(this);
pushChannel.asyncOpen(pushChannelListener, pushChannel);
pushChannel.asyncOpen2(pushChannelListener);
},
disconnect: function() {
@ -434,19 +435,8 @@ this.PushServiceHttp2 = {
},
_makeChannel: function(aUri) {
var ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var chan = ios.newChannel2(aUri,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER)
.QueryInterface(Ci.nsIHttpChannel);
var chan = NetUtil.newChannel({uri: aUri, loadUsingSystemPrincipal: true})
.QueryInterface(Ci.nsIHttpChannel);
var loadGroup = Cc["@mozilla.org/network/load-group;1"]
.createInstance(Ci.nsILoadGroup);
@ -495,7 +485,7 @@ this.PushServiceHttp2 = {
var chan = this._makeChannel(this._serverURI.spec);
chan.requestMethod = "POST";
chan.asyncOpen(listener, null);
chan.asyncOpen2(listener);
})
.catch(err => {
if ("retry" in err) {
@ -511,7 +501,7 @@ this.PushServiceHttp2 = {
return new Promise((resolve,reject) => {
var chan = this._makeChannel(aUri);
chan.requestMethod = "DELETE";
chan.asyncOpen(new PushServiceDelete(resolve, reject), null);
chan.asyncOpen2(new PushServiceDelete(resolve, reject));
});
},
@ -545,10 +535,10 @@ this.PushServiceHttp2 = {
chan.notificationCallbacks = listener;
try {
chan.asyncOpen(listener, chan);
chan.asyncOpen2(listener);
} catch (e) {
console.error("listenForMsgs: Error connecting to push server.",
"asyncOpen failed", e);
"asyncOpen2 failed", e);
conn.listener.disconnect();
chan.cancel(Cr.NS_ERROR_ABORT);
this._retryAfterBackoff(aSubscriptionUri, -1);