Bug 1003095 - Copy the lazy getter functions from XPCOMUtils.jsm to DevToolsUtils.js;r=past
This commit is contained in:
@@ -351,3 +351,50 @@ exports.update = function update(aTarget, aNewAttrs) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a getter on a specified object that will be created upon first use.
|
||||
*
|
||||
* @param aObject
|
||||
* The object to define the lazy getter on.
|
||||
* @param aName
|
||||
* The name of the getter to define on aObject.
|
||||
* @param aLambda
|
||||
* A function that returns what the getter should return. This will
|
||||
* only ever be called once.
|
||||
*/
|
||||
exports.defineLazyGetter = function defineLazyGetter(aObject, aName, aLambda) {
|
||||
Object.defineProperty(aObject, aName, {
|
||||
get: function () {
|
||||
delete aObject[aName];
|
||||
return aObject[aName] = aLambda.apply(aObject);
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines a getter on a specified object for a module. The module will not
|
||||
* be imported until first use.
|
||||
*
|
||||
* @param aObject
|
||||
* The object to define the lazy getter on.
|
||||
* @param aName
|
||||
* The name of the getter to define on aObject for the module.
|
||||
* @param aResource
|
||||
* The URL used to obtain the module.
|
||||
* @param aSymbol
|
||||
* The name of the symbol exported by the module.
|
||||
* This parameter is optional and defaults to aName.
|
||||
*/
|
||||
exports.defineLazyModuleGetter = function defineLazyModuleGetter(aObject, aName,
|
||||
aResource,
|
||||
aSymbol)
|
||||
{
|
||||
this.defineLazyGetter(aObject, aName, function XPCU_moduleLambda() {
|
||||
var temp = {};
|
||||
Cu.import(aResource, temp);
|
||||
return temp[aSymbol || aName];
|
||||
});
|
||||
};
|
||||
|
||||
@@ -49,7 +49,6 @@ Object.defineProperty(this, "Components", {
|
||||
const DBG_STRINGS_URI = "chrome://global/locale/devtools/debugger.properties";
|
||||
|
||||
const nsFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const LOG_PREF = "devtools.debugger.log";
|
||||
const VERBOSE_PREF = "devtools.debugger.log.verbose";
|
||||
@@ -85,13 +84,6 @@ this.all = all;
|
||||
|
||||
Cu.import("resource://gre/modules/devtools/SourceMap.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "console",
|
||||
"resource://gre/modules/devtools/Console.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "NetworkMonitorManager", () => {
|
||||
return require("devtools/toolkit/webconsole/network-monitor").NetworkMonitorManager;
|
||||
});
|
||||
|
||||
// XPCOM constructors
|
||||
const ServerSocket = CC("@mozilla.org/network/server-socket;1",
|
||||
"nsIServerSocket",
|
||||
@@ -197,9 +189,10 @@ var DebuggerServer = {
|
||||
* @return true if the connection should be permitted, false otherwise
|
||||
*/
|
||||
_defaultAllowConnection: function DS__defaultAllowConnection() {
|
||||
let title = L10N.getStr("remoteIncomingPromptTitle");
|
||||
let msg = L10N.getStr("remoteIncomingPromptMessage");
|
||||
let disableButton = L10N.getStr("remoteIncomingPromptDisable");
|
||||
let bundle = Services.strings.createBundle(DBG_STRINGS_URI)
|
||||
let title = bundle.GetStringFromName("remoteIncomingPromptTitle");
|
||||
let msg = bundle.GetStringFromName("remoteIncomingPromptMessage");
|
||||
let disableButton = bundle.GetStringFromName("remoteIncomingPromptDisable");
|
||||
let prompt = Services.prompt;
|
||||
let flags = prompt.BUTTON_POS_0 * prompt.BUTTON_TITLE_OK +
|
||||
prompt.BUTTON_POS_1 * prompt.BUTTON_TITLE_CANCEL +
|
||||
@@ -601,6 +594,7 @@ var DebuggerServer = {
|
||||
|
||||
actor = msg.json.actor;
|
||||
|
||||
let { NetworkMonitorManager } = require("devtools/toolkit/webconsole/network-monitor");
|
||||
netMonitor = new NetworkMonitorManager(aFrame, actor.actor);
|
||||
|
||||
deferred.resolve(actor);
|
||||
@@ -1277,23 +1271,3 @@ DebuggerServerConnection.prototype = {
|
||||
uneval(Object.keys(aPool._actors)));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Localization convenience methods.
|
||||
*/
|
||||
let L10N = {
|
||||
|
||||
/**
|
||||
* L10N shortcut function.
|
||||
*
|
||||
* @param string aName
|
||||
* @return string
|
||||
*/
|
||||
getStr: function L10N_getStr(aName) {
|
||||
return this.stringBundle.GetStringFromName(aName);
|
||||
}
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(L10N, "stringBundle", function() {
|
||||
return Services.strings.createBundle(DBG_STRINGS_URI);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user