mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1241579 - Convert services/ to use channel.open2() (r=sicking)
This commit is contained in:
parent
f9b797ccdd
commit
df2754a3be
@ -40,6 +40,8 @@
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
var exports = {};
|
||||
|
||||
var ios = Cc['@mozilla.org/network/io-service;1']
|
||||
@ -313,17 +315,23 @@
|
||||
else
|
||||
baseURI = ios.newURI(base, null, null);
|
||||
var newURI = ios.newURI(path, null, baseURI);
|
||||
var channel = ios.newChannelFromURI(newURI);
|
||||
var channel = NetUtil.newChannel({
|
||||
uri: newURI,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
try {
|
||||
channel.open().close();
|
||||
channel.open2().close();
|
||||
} catch (e if e.result == Cr.NS_ERROR_FILE_NOT_FOUND) {
|
||||
return null;
|
||||
}
|
||||
return newURI.spec;
|
||||
},
|
||||
getFile: function getFile(path) {
|
||||
var channel = ios.newChannel(path, null, null);
|
||||
var iStream = channel.open();
|
||||
var channel = NetUtil.newChannel({
|
||||
uri: path,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var iStream = channel.open2();
|
||||
var ciStream = Cc["@mozilla.org/intl/converter-input-stream;1"].
|
||||
createInstance(Ci.nsIConverterInputStream);
|
||||
var bufLen = 0x8000;
|
||||
|
@ -9,7 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/AddonManager.jsm");
|
||||
Cu.import("resource://gre/modules/addons/AddonRepository.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://services-common/async.js");
|
||||
Cu.import("resource://services-sync/addonutils.js");
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
@ -20,15 +20,11 @@ const STATE_ENABLED = 1;
|
||||
const STATE_DISABLED = 2;
|
||||
|
||||
function GetFileAsText(file) {
|
||||
let channel = Services.io.newChannel2(file,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
let inputStream = channel.open();
|
||||
let channel = NetUtil.newChannel({
|
||||
uri: file,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
let inputStream = channel.open2();
|
||||
if (channel instanceof Ci.nsIHttpChannel &&
|
||||
channel.responseStatus != 200) {
|
||||
return "";
|
||||
|
Loading…
Reference in New Issue
Block a user