Bug 514415 - Expose NetUtil's reference to nsIIOService. r=sdwilsh, sr=bzbarsky

This commit is contained in:
Ryan Flint 2009-10-03 01:11:20 -04:00
Родитель c65a6fdf9a
Коммит fda9a02a86
3 изменённых файлов: 24 добавлений и 14 удалений

Просмотреть файл

@ -148,7 +148,19 @@ const NetUtil = {
throw exception;
}
return ioService.newURI(aSpec, aOriginCharset, aBaseURI);
return this.ioService.newURI(aSpec, aOriginCharset, aBaseURI);
},
/**
* Returns a reference to nsIIOService.
*
* @return a reference to nsIIOService.
*/
get ioService()
{
delete this.ioService;
return this.ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
},
};
@ -160,6 +172,3 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
// Define our lazy getters.
XPCOMUtils.defineLazyServiceGetter(this, "ioUtil", "@mozilla.org/io-util;1",
"nsIIOUtil");
XPCOMUtils.defineLazyServiceGetter(this, "ioService",
"@mozilla.org/network/io-service;1",
"nsIIOService");

Просмотреть файл

@ -173,6 +173,12 @@ function test_newURI()
run_next_test();
}
function test_ioService()
{
do_check_true(NetUtil.ioService instanceof Ci.nsIIOService);
run_next_test();
}
////////////////////////////////////////////////////////////////////////////////
//// Test Runner
@ -181,6 +187,7 @@ let tests = [
test_async_write_file_nsISafeOutputStream,
test_newURI_no_spec_throws,
test_newURI,
test_ioService,
];
let index = 0;

Просмотреть файл

@ -209,12 +209,6 @@ __defineGetter__("gObsSvc", function() {
getService(Ci.nsIObserverService);
});
__defineGetter__("gIoSvc", function() {
delete this.gIoSvc;
return this.gIoSvc = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
});
__defineGetter__("gPrefSvc", function() {
delete this.gPrefSvc;
return this.gPrefSvc = Cc["@mozilla.org/preferences-service;1"].
@ -1141,7 +1135,7 @@ Engine.prototype = {
LOG("_initFromURI: Downloading engine from: \"" + this._uri.spec + "\".");
var chan = gIoSvc.newChannelFromURI(this._uri);
var chan = NetUtil.ioService.newChannelFromURI(this._uri);
if (this._engineToUpdate && (chan instanceof Ci.nsIHttpChannel)) {
var lastModified = engineMetadataService.getAttr(this._engineToUpdate,
@ -1401,7 +1395,7 @@ Engine.prototype = {
if (!this._readOnly) {
LOG("_setIcon: Downloading icon: \"" + uri.spec +
"\" for engine: \"" + this.name + "\"");
var chan = gIoSvc.newChannelFromURI(uri);
var chan = NetUtil.ioService.newChannelFromURI(uri);
function iconLoadCallback(aByteArray, aEngine) {
// This callback may run after we've already set a preferred icon,
@ -2661,7 +2655,7 @@ SearchService.prototype = {
if (!file.isFile() || file.fileSize == 0 || file.isHidden())
continue;
var fileURL = gIoSvc.newFileURI(file).QueryInterface(Ci.nsIURL);
var fileURL = NetUtil.ioService.newFileURI(file).QueryInterface(Ci.nsIURL);
var fileExtension = fileURL.fileExtension.toLowerCase();
var isWritable = isInProfile && file.isWritable();
@ -2704,7 +2698,7 @@ SearchService.prototype = {
if (!addedEngine._iconURI) {
var icon = this._findSherlockIcon(file, fileURL.fileBaseName);
if (icon)
addedEngine._iconURI = gIoSvc.newFileURI(icon);
addedEngine._iconURI = NetUtil.ioService.newFileURI(icon);
}
}