Bug 644905 - Set resource aliases in manifest. r=rnewman

This commit is contained in:
Philipp von Weitershausen 2011-03-25 00:57:23 -07:00
parent 07ccf6df79
commit f28bda026b
4 changed files with 25 additions and 27 deletions

View File

@ -50,9 +50,16 @@ registrar.registerFactory(Components.ID("{fbfae60b-64a4-44ef-a911-08ceb70b9f31}"
}
// Provide resource://services-crypto if it isn't already available
let weaveService = Cc["@mozilla.org/weave/service;1"].getService();
weaveService.wrappedJSObject.addResourceAlias();
// Register resource alias. Normally done in SyncComponents.manifest.
function addResourceAlias() {
Cu.import("resource://gre/modules/Services.jsm");
const resProt = Services.io.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler);
let uri = Services.io.newURI("resource:///modules/services-crypto/",
null, null);
resProt.setSubstitution("services-crypto", uri);
}
addResourceAlias();
/**
* Print some debug message to the console. All arguments will be printed,

View File

@ -6,3 +6,6 @@ component {d28f8a0b-95da-48f4-b712-caf37097be41} Weave.js
contract @mozilla.org/network/protocol/about;1?what=sync-log {d28f8a0b-95da-48f4-b712-caf37097be41}
component {a08ee179-df50-48e0-9c87-79e4dd5caeb1} Weave.js
contract @mozilla.org/network/protocol/about;1?what=sync-log.1 {a08ee179-df50-48e0-9c87-79e4dd5caeb1}
# Register resource aliases
resource services-sync resource:///modules/services-sync/
resource services-crypto resource:///modules/services-crypto/

View File

@ -58,8 +58,6 @@ WeaveService.prototype = {
break;
case "final-ui-startup":
this.addResourceAlias();
// Force Weave service to load if it hasn't triggered from overlays
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this.timer.initWithCallback({
@ -71,25 +69,6 @@ WeaveService.prototype = {
}, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
break;
}
},
addResourceAlias: function() {
let ioService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
let resProt = ioService.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler);
// Only create alias if resource://services-sync doesn't already exist.
if (!resProt.hasSubstitution("services-sync")) {
let uri = ioService.newURI("resource:///modules/services-sync/",
null, null);
resProt.setSubstitution("services-sync", uri);
}
if (!resProt.hasSubstitution("services-crypto")) {
let uri = ioService.newURI("resource:///modules/services-crypto/",
null, null);
resProt.setSubstitution("services-crypto", uri);
}
}
};

View File

@ -66,9 +66,18 @@ registrar.registerFactory(Components.ID("{fbfae60b-64a4-44ef-a911-08ceb70b9f31}"
}
// Provide resource://services-sync if it isn't already available
let weaveService = Cc["@mozilla.org/weave/service;1"].getService();
weaveService.wrappedJSObject.addResourceAlias();
// Register resource aliases. Normally done in SyncComponents.manifest.
function addResourceAlias() {
Cu.import("resource://gre/modules/Services.jsm");
const resProt = Services.io.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler);
let uri;
uri = Services.io.newURI("resource:///modules/services-sync/", null, null);
resProt.setSubstitution("services-sync", uri);
uri = Services.io.newURI("resource:///modules/services-crypto/", null, null);
resProt.setSubstitution("services-crypto", uri);
}
addResourceAlias();
// Some tests hang on OSX debug builds. See bug 604565.