Bug 1204703 - Add AsyncOpen2 to channels in toolkit/ and b2g/ (r=sicking)

--HG--
extra : source : deda472458fd5314c11461302008ce984dbd00a7
This commit is contained in:
Christoph Kerschbaumer 2015-09-18 09:27:32 -07:00
parent 35ed4ce561
commit 696a2d029f
2 changed files with 21 additions and 1 deletions

View File

@ -12,6 +12,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
XPCOMUtils.defineLazyServiceGetter(this, "contentSecManager",
"@mozilla.org/contentsecuritymanager;1",
"nsIContentSecurityManager");
this.EXPORTED_SYMBOLS = ["ActivityChannel"];
this.ActivityChannel = function(aURI, aLoadInfo, aName, aDetails) {
@ -51,7 +55,9 @@ this.ActivityChannel.prototype = {
},
asyncOpen2: function(aListener) {
this.asyncOpen(aListener, null);
// throws an error if security checks fail
var outListener = contentSecManager.performSecurityCheck(this, aListener);
this.asyncOpen(outListener, null);
},
QueryInterface2: XPCOMUtils.generateQI([Ci.nsIChannel])

View File

@ -20,6 +20,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "Prefetcher",
XPCOMUtils.defineLazyServiceGetter(this, "SystemPrincipal",
"@mozilla.org/systemprincipal;1", "nsIPrincipal");
XPCOMUtils.defineLazyServiceGetter(this, "contentSecManager",
"@mozilla.org/contentsecuritymanager;1",
"nsIContentSecurityManager");
// Similar to Python. Returns dict[key] if it exists. Otherwise,
// sets dict[key] to default_ and returns default_.
function setDefault(dict, key, default_)
@ -274,10 +278,20 @@ AboutProtocolChannel.prototype = {
Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
},
asyncOpen2: function(listener) {
// throws an error if security checks fail
var outListener = contentSecManager.performSecurityCheck(this, listener);
this.asyncOpen(outListener, null);
},
open: function() {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
open2: function() {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
isPending: function() {
return false;
},