зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1261665 - Remove unecessary Loader.jsm main in favor of require(). r=jryans
This commit is contained in:
Родитель
32b664e0bd
Коммит
2304fa0495
|
@ -98,8 +98,14 @@ function reload(event) {
|
|||
}
|
||||
}, false);
|
||||
|
||||
const {devtools} = Components.utils.import("resource://devtools/shared/Loader.jsm", {});
|
||||
devtools.reload();
|
||||
// As we can't get a reference to existing Loader.jsm instances, we send them
|
||||
// an observer service notification to unload them.
|
||||
Services.obs.notifyObservers(null, "devtools-unload", "reload");
|
||||
|
||||
// Then spawn a brand new Loader.jsm instance and start the main module
|
||||
Cu.unload("resource://devtools/shared/Loader.jsm");
|
||||
const {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
devtools.require("devtools/client/framework/devtools-browser");
|
||||
|
||||
// Go over all top level windows to reload all devtools related things
|
||||
let windowsEnum = Services.wm.getEnumerator(null);
|
||||
|
|
|
@ -17,8 +17,7 @@ var gNewChromeSource = promise.defer()
|
|||
var { DevToolsLoader } = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
var loader = new DevToolsLoader();
|
||||
loader.invisibleToDebugger = true;
|
||||
loader.main("devtools/server/main");
|
||||
var DebuggerServer = loader.DebuggerServer;
|
||||
var { DebuggerServer } = loader.require("devtools/server/main");
|
||||
|
||||
function test() {
|
||||
if (!DebuggerServer.initialized) {
|
||||
|
|
|
@ -70,7 +70,7 @@ DevToolsStartup.prototype = {
|
|||
let { loader } = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
// Ensure loading main devtools module that hooks up into browser UI
|
||||
// and initialize all devtools machinery.
|
||||
loader.main("devtools/client/main");
|
||||
loader.require("devtools/client/framework/devtools-browser");
|
||||
},
|
||||
|
||||
handleConsoleFlag: function(cmdLine) {
|
||||
|
@ -154,8 +154,8 @@ DevToolsStartup.prototype = {
|
|||
// settings).
|
||||
let serverLoader = new DevToolsLoader();
|
||||
serverLoader.invisibleToDebugger = true;
|
||||
serverLoader.main("devtools/server/main");
|
||||
let debuggerServer = serverLoader.DebuggerServer;
|
||||
let { DebuggerServer: debuggerServer } =
|
||||
serverLoader.require("devtools/server/main");
|
||||
debuggerServer.init();
|
||||
debuggerServer.addBrowserActors();
|
||||
debuggerServer.allowChromeProcess = true;
|
||||
|
|
|
@ -127,8 +127,8 @@ BrowserToolboxProcess.prototype = {
|
|||
// invisible to the debugger (unlike the usual loader settings).
|
||||
this.loader = new DevToolsLoader();
|
||||
this.loader.invisibleToDebugger = true;
|
||||
this.loader.main("devtools/server/main");
|
||||
this.debuggerServer = this.loader.DebuggerServer;
|
||||
let { DebuggerServer } = this.loader.require("devtools/server/main");
|
||||
this.debuggerServer = DebuggerServer;
|
||||
dumpn("Created a separate loader instance for the DebuggerServer.");
|
||||
|
||||
// Forward interesting events.
|
||||
|
|
|
@ -10,7 +10,7 @@ var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
|||
|
||||
var { loader, require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
// Require this module to setup core modules
|
||||
loader.main("devtools/client/main");
|
||||
loader.require("devtools/client/framework/devtools-browser");
|
||||
|
||||
var { gDevTools } = require("devtools/client/framework/devtools");
|
||||
var { TargetFactory } = require("devtools/client/framework/target");
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* This module could have been devtools-browser.js.
|
||||
* But we need this wrapper in order to define precisely what we are exporting
|
||||
* out of client module loader (Loader.jsm): only Toolbox and TargetFactory.
|
||||
*/
|
||||
|
||||
// For compatiblity reasons, exposes these symbols on "devtools":
|
||||
Object.defineProperty(exports, "Toolbox", {
|
||||
get: () => require("devtools/client/framework/toolbox").Toolbox
|
||||
});
|
||||
Object.defineProperty(exports, "TargetFactory", {
|
||||
get: () => require("devtools/client/framework/target").TargetFactory
|
||||
});
|
||||
|
||||
// Load the main browser module
|
||||
require("devtools/client/framework/devtools-browser");
|
|
@ -51,6 +51,5 @@ JAR_MANIFESTS += ['jar.mn']
|
|||
|
||||
DevToolsModules(
|
||||
'definitions.js',
|
||||
'main.js',
|
||||
'menus.js',
|
||||
)
|
||||
|
|
|
@ -19,8 +19,7 @@ function init(msg) {
|
|||
// in the same process.
|
||||
let devtools = new DevToolsLoader();
|
||||
devtools.invisibleToDebugger = true;
|
||||
devtools.main("devtools/server/main");
|
||||
let { DebuggerServer, ActorPool } = devtools;
|
||||
let { DebuggerServer, ActorPool } = devtools.require("devtools/server/main");
|
||||
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
/* globals NetUtil, FileUtils, OS */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -14,10 +13,6 @@ var { Constructor: CC, classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
|||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
|
||||
|
||||
var { Loader } = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {});
|
||||
var promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
|
||||
|
||||
|
@ -135,11 +130,9 @@ BuiltinProvider.prototype = {
|
|||
var gNextLoaderID = 0;
|
||||
|
||||
/**
|
||||
* The main devtools API.
|
||||
* In addition to a few loader-related details, this object will also include all
|
||||
* exports from the main module. The standard instance of this loader is
|
||||
* exported as |devtools| below, but if a fresh copy of the loader is needed,
|
||||
* then a new one can also be created.
|
||||
* The main devtools API. The standard instance of this loader is exported as
|
||||
* |devtools| below, but if a fresh copy of the loader is needed, then a new
|
||||
* one can also be created.
|
||||
*/
|
||||
this.DevToolsLoader = function DevToolsLoader() {
|
||||
this.require = this.require.bind(this);
|
||||
|
@ -147,7 +140,8 @@ this.DevToolsLoader = function DevToolsLoader() {
|
|||
this.lazyImporter = XPCOMUtils.defineLazyModuleGetter.bind(XPCOMUtils);
|
||||
this.lazyServiceGetter = XPCOMUtils.defineLazyServiceGetter.bind(XPCOMUtils);
|
||||
this.lazyRequireGetter = this.lazyRequireGetter.bind(this);
|
||||
this.main = this.main.bind(this);
|
||||
|
||||
Services.obs.addObserver(this, "devtools-unload", false);
|
||||
};
|
||||
|
||||
DevToolsLoader.prototype = {
|
||||
|
@ -218,46 +212,6 @@ DevToolsLoader.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a URI to the loader.
|
||||
* @param string id
|
||||
* The module id that can be used within the loader to refer to this module.
|
||||
* @param string uri
|
||||
* The URI to load as a module.
|
||||
* @returns The module's exports.
|
||||
*/
|
||||
loadURI: function(id, uri) {
|
||||
let module = Loader.Module(id, uri);
|
||||
return Loader.load(this.provider.loader, module).exports;
|
||||
},
|
||||
|
||||
/**
|
||||
* Let the loader know the ID of the main module to load.
|
||||
*
|
||||
* The loader doesn't need a main module, but it's nice to have. This
|
||||
* will be called by the browser devtools to load the devtools/main module.
|
||||
*
|
||||
* When only using the server, there's no main module, and this method
|
||||
* can be ignored.
|
||||
*/
|
||||
main: function(id) {
|
||||
// Ensure the main module isn't loaded twice, because it may have observable
|
||||
// side-effects.
|
||||
if (this._mainid) {
|
||||
return;
|
||||
}
|
||||
this._mainid = id;
|
||||
this._main = Loader.main(this.provider.loader, id);
|
||||
|
||||
// Mirror the main module's exports on this object.
|
||||
Object.getOwnPropertyNames(this._main).forEach(key => {
|
||||
XPCOMUtils.defineLazyGetter(this, key, () => this._main[key]);
|
||||
});
|
||||
|
||||
var events = this.require("sdk/system/events");
|
||||
events.emit("devtools-loaded", {});
|
||||
},
|
||||
|
||||
/**
|
||||
* Override the provider used to load the tools.
|
||||
*/
|
||||
|
@ -286,8 +240,7 @@ DevToolsLoader.prototype = {
|
|||
lazyImporter: this.lazyImporter,
|
||||
lazyServiceGetter: this.lazyServiceGetter,
|
||||
lazyRequireGetter: this.lazyRequireGetter,
|
||||
id: this.id,
|
||||
main: this.main
|
||||
id: this.id
|
||||
},
|
||||
// Make sure `define` function exists. This allows defining some modules
|
||||
// in AMD format while retaining CommonJS compatibility through this hook.
|
||||
|
@ -323,18 +276,21 @@ DevToolsLoader.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Reload the current provider.
|
||||
* Handles "devtools-unload" event
|
||||
*
|
||||
* @param String data
|
||||
* reason passed to modules when unloaded
|
||||
*/
|
||||
reload: function() {
|
||||
var events = this.require("sdk/system/events");
|
||||
events.emit("startupcache-invalidate", {});
|
||||
observe: function(subject, topic, data) {
|
||||
if (topic != "devtools-unload") {
|
||||
return;
|
||||
}
|
||||
Services.obs.removeObserver(this, "devtools-unload");
|
||||
|
||||
this._provider.unload("reload");
|
||||
delete this._provider;
|
||||
let mainid = this._mainid;
|
||||
delete this._mainid;
|
||||
this._loadProvider();
|
||||
this.main(mainid);
|
||||
if (this._provider) {
|
||||
this._provider.unload(data);
|
||||
delete this._provider;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -353,3 +309,11 @@ DevToolsLoader.prototype = {
|
|||
this.devtools = this.loader = new DevToolsLoader();
|
||||
|
||||
this.require = this.devtools.require.bind(this.devtools);
|
||||
|
||||
// For compatibility reasons, expose these symbols on "devtools":
|
||||
Object.defineProperty(this.devtools, "Toolbox", {
|
||||
get: () => this.require("devtools/client/framework/toolbox").Toolbox
|
||||
});
|
||||
Object.defineProperty(this.devtools, "TargetFactory", {
|
||||
get: () => this.require("devtools/client/framework/target").TargetFactory
|
||||
});
|
||||
|
|
|
@ -25,8 +25,7 @@ XPCOMUtils.defineLazyGetter(this, "debuggerServer", () => {
|
|||
// settings).
|
||||
let serverLoader = new DevToolsLoader();
|
||||
serverLoader.invisibleToDebugger = true;
|
||||
serverLoader.main("devtools/server/main");
|
||||
let debuggerServer = serverLoader.DebuggerServer;
|
||||
let { DebuggerServer: debuggerServer } = serverLoader.require("devtools/server/main");
|
||||
debuggerServer.init();
|
||||
debuggerServer.addBrowserActors();
|
||||
debuggerServer.allowChromeProcess = !l10n.hiddenByChromePref();
|
||||
|
|
Загрузка…
Ссылка в новой задаче