mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1167053 - Convert NetUtil.newChannel2 callsites to use new API - remove newChannel2,asyncFetch2 (r=sicking,paolo)
This commit is contained in:
parent
b9e76daa73
commit
292ac6382e
@ -158,98 +158,6 @@ this.NetUtil = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated Use asyncFecth({ ...options... }, callback) instead.
|
||||
*/
|
||||
asyncFetch2: function NetUtil_asyncFetch2(aSource,
|
||||
aCallback,
|
||||
aLoadingNode,
|
||||
aLoadingPrincipal,
|
||||
aTriggeringPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType)
|
||||
{
|
||||
if (!aSource || !aCallback) {
|
||||
let exception = new Components.Exception(
|
||||
"Must have a source and a callback",
|
||||
Cr.NS_ERROR_INVALID_ARG,
|
||||
Components.stack.caller
|
||||
);
|
||||
throw exception;
|
||||
}
|
||||
|
||||
// if aSource is an instance of an nsIChannel, all the individual
|
||||
// args to create a loadInfo must be "undefined".
|
||||
if (aSource instanceof Ci.nsIChannel) {
|
||||
if ((typeof aLoadingNode != "undefined") ||
|
||||
(typeof aLoadingPrincipal != "undefined") ||
|
||||
(typeof aTriggeringPrincipal != "undefined") ||
|
||||
(typeof aSecurityFlags != "undefined") ||
|
||||
(typeof aContentPolicyType != "undefined")) {
|
||||
|
||||
let exception = new Components.Exception(
|
||||
"LoadInfo arguments must be undefined",
|
||||
Cr.NS_ERROR_INVALID_ARG,
|
||||
Components.stack.caller
|
||||
);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a pipe that will create our output stream that we can use once
|
||||
// we have gotten all the data.
|
||||
let pipe = Cc["@mozilla.org/pipe;1"].
|
||||
createInstance(Ci.nsIPipe);
|
||||
pipe.init(true, true, 0, PR_UINT32_MAX, null);
|
||||
|
||||
// Create a listener that will give data to the pipe's output stream.
|
||||
let listener = Cc["@mozilla.org/network/simple-stream-listener;1"].
|
||||
createInstance(Ci.nsISimpleStreamListener);
|
||||
listener.init(pipe.outputStream, {
|
||||
onStartRequest: function(aRequest, aContext) {},
|
||||
onStopRequest: function(aRequest, aContext, aStatusCode) {
|
||||
pipe.outputStream.close();
|
||||
aCallback(pipe.inputStream, aStatusCode, aRequest);
|
||||
}
|
||||
});
|
||||
|
||||
// Input streams are handled slightly differently from everything else.
|
||||
if (aSource instanceof Ci.nsIInputStream) {
|
||||
let pump = Cc["@mozilla.org/network/input-stream-pump;1"].
|
||||
createInstance(Ci.nsIInputStreamPump);
|
||||
pump.init(aSource, -1, -1, 0, 0, true);
|
||||
pump.asyncRead(listener, null);
|
||||
return;
|
||||
}
|
||||
|
||||
let channel = aSource;
|
||||
if (!(channel instanceof Ci.nsIChannel)) {
|
||||
channel = this.newChannel2(aSource,
|
||||
"", // aOriginCharset
|
||||
null, // aBaseURI
|
||||
aLoadingNode,
|
||||
aLoadingPrincipal,
|
||||
aTriggeringPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType);
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
channel.asyncOpen(listener, null);
|
||||
}
|
||||
catch (e) {
|
||||
let exception = new Components.Exception(
|
||||
"Failed to open input source '" + channel.originalURI.spec + "'",
|
||||
e.result,
|
||||
Components.stack.caller,
|
||||
aSource,
|
||||
e
|
||||
);
|
||||
throw exception;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a new URI for the given spec, character set, and base URI, or
|
||||
* an nsIFile.
|
||||
@ -471,41 +379,6 @@ this.NetUtil = {
|
||||
contentPolicyType);
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated Use newChannel({ ...options... }) instead.
|
||||
*/
|
||||
newChannel2: function NetUtil_newChannel2(aWhatToLoad,
|
||||
aOriginCharset,
|
||||
aBaseURI,
|
||||
aLoadingNode,
|
||||
aLoadingPrincipal,
|
||||
aTriggeringPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType)
|
||||
{
|
||||
if (!aWhatToLoad) {
|
||||
let exception = new Components.Exception(
|
||||
"Must have a non-null string spec, nsIURI, or nsIFile object",
|
||||
Cr.NS_ERROR_INVALID_ARG,
|
||||
Components.stack.caller
|
||||
);
|
||||
throw exception;
|
||||
}
|
||||
|
||||
let uri = aWhatToLoad;
|
||||
if (!(aWhatToLoad instanceof Ci.nsIURI)) {
|
||||
// We either have a string or an nsIFile that we'll need a URI for.
|
||||
uri = this.newURI(aWhatToLoad, aOriginCharset, aBaseURI);
|
||||
}
|
||||
|
||||
return this.ioService.newChannelFromURI2(uri,
|
||||
aLoadingNode,
|
||||
aLoadingPrincipal,
|
||||
aTriggeringPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reads aCount bytes from aInputStream into a string.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user