Skip to content

Commit

Permalink
Bug 1243924 - Convert remaining callsites within dom/ to use channel.…
Browse files Browse the repository at this point in the history
…open2() (r=sicking)
  • Loading branch information
Christoph Kerschbaumer committed Jan 29, 2016
1 parent 1f2034e commit 81bc64d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 34 deletions.
16 changes: 7 additions & 9 deletions dom/base/test/unit/head_utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

Components.utils.import("resource://testing-common/httpd.js");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");

const nsIDocumentEncoder = Components.interfaces.nsIDocumentEncoder;
const replacementChar = Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER;
Expand All @@ -17,23 +17,21 @@ function loadContentFile(aFile, aCharset) {
var file = do_get_file(aFile);
var ios = Components.classes['@mozilla.org/network/io-service;1']
.getService(Components.interfaces.nsIIOService);
var chann = ios.newChannelFromURI2(ios.newFileURI(file),
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Components.interfaces.nsILoadInfo.SEC_NORMAL,
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
var chann = NetUtil.newChannel({
uri: ios.newFileURI(file),
loadUsingSystemPrincipal: true
});
chann.contentCharset = aCharset;

/*var inputStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance(Components.interfaces.nsIScriptableInputStream);
inputStream.init(chann.open());
inputStream.init(chann.open2());
return inputStream.read(file.fileSize);
*/

var inputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
.createInstance(Components.interfaces.nsIConverterInputStream);
inputStream.init(chann.open(), aCharset, 1024, replacementChar);
inputStream.init(chann.open2(), aCharset, 1024, replacementChar);
var str = {}, content = '';
while (inputStream.readString(4096, str) != 0) {
content += str.value;
Expand Down
2 changes: 1 addition & 1 deletion dom/contacts/fallback/ContactDB.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ ContactDB.prototype = {
uri: NetUtil.newURI(contactsFile),
loadUsingSystemPrincipal: true});

let stream = chan.open();
let stream = chan.open2();
// Obtain a converter to read from a UTF-8 encoded input stream.
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
Expand Down
2 changes: 1 addition & 1 deletion dom/settings/SettingsDB.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ SettingsDB.prototype = {
let chan = NetUtil.newChannel({
uri: NetUtil.newURI(settingsFile),
loadUsingSystemPrincipal: true});
let stream = chan.open();
let stream = chan.open2();
// Obtain a converter to read from a UTF-8 encoded input stream.
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
Expand Down
16 changes: 7 additions & 9 deletions dom/xslt/tests/XSLTMark/XSLTMark-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const nsIFilePicker = Components.interfaces.nsIFilePicker;
const STDURL_CTRID = "@mozilla.org/network/standard-url;1";
const nsIURI = Components.interfaces.nsIURI;

Components.utils.import("resource://gre/modules/NetUtil.jsm");

var gStop = false;

function loadFile(aUriSpec)
Expand All @@ -22,17 +24,13 @@ function loadFile(aUriSpec)
if (!serv) {
throw Components.results.ERR_FAILURE;
}
var chan = serv.newChannel2(aUriSpec,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: aUriSpec,
loadUsingSystemPrincipal: true
});
var instream =
Components.classes[SIS_CTRID].createInstance(nsISIS);
instream.init(chan.open());
instream.init(chan.open2());

return instream.read(instream.available());
}
Expand Down
21 changes: 7 additions & 14 deletions dom/xslt/tests/buster/buster-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

Components.utils.import("resource://gre/modules/NetUtil.jsm");

var parser = new DOMParser();
var methodExpr = (new XPathEvaluator).createExpression("xsl:output/@method",
{
Expand Down Expand Up @@ -307,21 +309,12 @@ runItem.prototype =

loadTextFile : function(url)
{
var serv = Components.classes[IOSERVICE_CTRID].
getService(nsIIOService);
if (!serv) {
throw Components.results.ERR_FAILURE;
}
var chan = serv.newChannel2(url,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true
});
var instream = doCreate(SIS_CTRID, nsISIS);
instream.init(chan.open());
instream.init(chan.open2());

return instream.read(instream.available());
}
Expand Down

0 comments on commit 81bc64d

Please sign in to comment.