Bug 988237 - Convert all protocol.js actors to lazy loading. r=past

This commit is contained in:
Alexandre Poirot 2014-09-16 06:00:00 -04:00
Родитель 8b8231711d
Коммит 4c4f6aa44c
25 изменённых файлов: 156 добавлений и 259 удалений

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

@ -12,14 +12,6 @@ const {ContentObserver} = require("devtools/content-observer");
const {on, once, off, emit} = events;
const {method, Arg, Option, RetVal} = protocol;
exports.register = function(handle) {
handle.addTabActor(CallWatcherActor, "callWatcherActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(CallWatcherActor);
};
/**
* Type describing a single function call in a stack trace.
*/

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

@ -51,16 +51,6 @@ const INTERESTING_CALLS = [
"useProgram"
];
exports.register = function(handle) {
handle.addTabActor(CanvasActor, "canvasActor");
handle.addGlobalActor(CanvasActor, "canvasActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(CanvasActor);
handle.removeGlobalActor(CanvasActor);
};
/**
* Type representing an Uint32Array buffer, serialized fast(er).
*

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

@ -826,19 +826,6 @@ const CSSUsageFront = protocol.FrontClass(CSSUsageActor, {
exports.CSSUsageFront = CSSUsageFront;
/**
* Registration / De-registration
*/
exports.register = function(handle) {
handle.addGlobalActor(CSSUsageActor, "cssUsageActor");
handle.addTabActor(CSSUsageActor, "cssUsageActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(CSSUsageActor, "cssUsageActor");
handle.removeTabActor(CSSUsageActor, "cssUsageActor");
};
const knownFronts = new WeakMap();
/**

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

@ -22,14 +22,7 @@ const APP_MAP = {
'{a23983c0-fd0e-11dc-95ff-0800200c9a66}': 'mobile/xul'
}
exports.register = function(handle) {
handle.addGlobalActor(DeviceActor, "deviceActor");
};
exports.unregister = function(handle) {
};
let DeviceActor = protocol.ActorClass({
let DeviceActor = exports.DeviceActor = protocol.ActorClass({
typeName: "device",
_desc: null,

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

@ -15,17 +15,7 @@ const protocol = require("devtools/server/protocol");
const {method, Arg, RetVal} = protocol;
const events = require("sdk/event/core");
exports.register = function(handle) {
handle.addGlobalActor(EventLoopLagActor, "eventLoopLagActor");
handle.addTabActor(EventLoopLagActor, "eventLoopLagActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(EventLoopLagActor);
handle.removeTabActor(EventLoopLagActor);
};
let EventLoopLagActor = protocol.ActorClass({
let EventLoopLagActor = exports.EventLoopLagActor = protocol.ActorClass({
typeName: "eventLoopLag",

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

@ -12,16 +12,6 @@ const DevToolsUtils = require("devtools/toolkit/DevToolsUtils.js");
const {on, once, off, emit} = events;
const {method, custom, Arg, Option, RetVal} = protocol;
exports.register = function(handle) {
handle.addTabActor(FramerateActor, "framerateActor");
handle.addGlobalActor(FramerateActor, "framerateActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(FramerateActor);
handle.removeGlobalActor(FramerateActor);
};
/**
* A very simple utility for monitoring framerate.
*/

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

@ -31,7 +31,7 @@ var RetVal = protocol.RetVal;
/**
* Manage remote connections that want to talk to GCLI
*/
var GcliActor = protocol.ActorClass({
var GcliActor = exports.GcliActor = protocol.ActorClass({
typeName: "gcli",
initialize: function(conn, tabActor) {
@ -205,14 +205,3 @@ exports.GcliFront = protocol.FrontClass(GcliActor, {
this.manage(this);
},
});
/**
* Called the framework on DebuggerServer.registerModule()
*/
exports.register = function(handle) {
handle.addTabActor(GcliActor, "gcliActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(GcliActor);
};

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

@ -126,16 +126,6 @@ loader.lazyGetter(this, "eventListenerService", function() {
.getService(Ci.nsIEventListenerService);
});
exports.register = function(handle) {
handle.addGlobalActor(InspectorActor, "inspectorActor");
handle.addTabActor(InspectorActor, "inspectorActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(InspectorActor);
handle.removeTabActor(InspectorActor);
};
// XXX: A poor man's makeInfallible until we move it out of transport.js
// Which should be very soon.
function makeInfallible(handler) {
@ -2795,7 +2785,7 @@ var AttributeModificationList = Class({
* Server side of the inspector actor, which is used to create
* inspector-related actors, including the walker.
*/
var InspectorActor = protocol.ActorClass({
var InspectorActor = exports.InspectorActor = protocol.ActorClass({
typeName: "inspector",
initialize: function(conn, tabActor) {
protocol.Actor.prototype.initialize.call(this, conn);

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

@ -33,20 +33,10 @@ const Heritage = require("sdk/core/heritage");
const {setTimeout, clearTimeout} = require("sdk/timers");
const EventEmitter = require("devtools/toolkit/event-emitter");
exports.register = function(handle) {
handle.addGlobalActor(ReflowActor, "reflowActor");
handle.addTabActor(ReflowActor, "reflowActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(ReflowActor);
handle.removeTabActor(ReflowActor);
};
/**
* The reflow actor tracks reflows and emits events about them.
*/
let ReflowActor = protocol.ActorClass({
let ReflowActor = exports.ReflowActor = protocol.ActorClass({
typeName: "reflow",
events: {

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

@ -156,13 +156,3 @@ exports.MemoryFront = protocol.FrontClass(MemoryActor, {
this.manage(this);
}
});
exports.register = function(handle) {
handle.addGlobalActor(MemoryActor, "memoryActor");
handle.addTabActor(MemoryActor, "memoryActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(MemoryActor, "memoryActor");
handle.removeTabActor(MemoryActor, "memoryActor");
};

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

@ -109,17 +109,6 @@ MonitorActor.prototype.requestTypes = {
exports.MonitorActor = MonitorActor;
exports.register = function(handle) {
handle.addGlobalActor(MonitorActor, "monitorActor");
handle.addTabActor(MonitorActor, "monitorActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(MonitorActor, "monitorActor");
handle.removeTabActor(MonitorActor, "monitorActor");
};
let USSAgent = {
_mgr: null,
_timeout: null,

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

@ -16,7 +16,7 @@ exports.register = function(handle) {
exports.unregister = function(handle) {
};
let PreferenceActor = protocol.ActorClass({
let PreferenceActor = exports.PreferenceActor = protocol.ActorClass({
typeName: "preference",
getBoolPref: method(function(name) {

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

@ -4,6 +4,7 @@
"use strict";
const {Cc, Ci, Cu, Cr} = require("chrome");
const Services = require("Services");
const DevToolsUtils = require("devtools/toolkit/DevToolsUtils.js");
let DEFAULT_PROFILER_ENTRIES = 1000000;
@ -239,6 +240,8 @@ ProfilerActor.prototype = {
}
};
exports.ProfilerActor = ProfilerActor;
/**
* JSON.stringify callback used in ProfilerActor.prototype.observe.
*/
@ -303,13 +306,3 @@ ProfilerActor.prototype.requestTypes = {
"registerEventNotifications": ProfilerActor.prototype.onRegisterEventNotifications,
"unregisterEventNotifications": ProfilerActor.prototype.onUnregisterEventNotifications
};
exports.register = function(handle) {
handle.addGlobalActor(ProfilerActor, "profilerActor");
handle.addTabActor(ProfilerActor, "profilerActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(ProfilerActor, "profilerActor");
handle.removeTabActor(ProfilerActor, "profilerActor");
};

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

@ -4852,6 +4852,7 @@ function ThreadSources(aThreadActor, aOptions, aAllowPredicate,
ThreadSources._blackBoxedSources = new Set(["self-hosted"]);
ThreadSources._prettyPrintedSources = new Map();
/**
* Matches strings of the form "foo.min.js" or "foo-min.js", etc. If the regular
* expression matches, we can be fairly sure that the source is minified, and
@ -5445,14 +5446,9 @@ function getSymbolName(symbol) {
return name || undefined;
}
exports.register = function(handle) {
exports.cleanup = function() {
// Reset shared globals when reloading the debugger server
ThreadActor.breakpointStore = new BreakpointStore();
ThreadSources._blackBoxedSources = new Set(["self-hosted"]);
ThreadSources._prettyPrintedSources = new Map();
};
exports.unregister = function(handle) {
ThreadActor.breakpointStore = null;
ThreadSources._blackBoxedSources.clear();
ThreadSources._prettyPrintedSources.clear();
};
}

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

@ -28,14 +28,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "Sqlite",
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
exports.register = function(handle) {
handle.addTabActor(StorageActor, "storageActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(StorageActor);
};
// Global required for window less Indexed DB instantiation.
let global = this;

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

@ -32,23 +32,13 @@ transition-property: all !important;\
let LOAD_ERROR = "error-load";
exports.register = function(handle) {
handle.addTabActor(StyleEditorActor, "styleEditorActor");
handle.addGlobalActor(StyleEditorActor, "styleEditorActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(StyleEditorActor);
handle.removeGlobalActor(StyleEditorActor);
};
types.addActorType("old-stylesheet");
/**
* Creates a StyleEditorActor. StyleEditorActor provides remote access to the
* stylesheets of a document.
*/
let StyleEditorActor = protocol.ActorClass({
let StyleEditorActor = exports.StyleEditorActor = protocol.ActorClass({
typeName: "styleeditor",
/**

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

@ -35,16 +35,6 @@ transition-property: all !important;\
let LOAD_ERROR = "error-load";
exports.register = function(handle) {
handle.addTabActor(StyleSheetsActor, "styleSheetsActor");
handle.addGlobalActor(StyleSheetsActor, "styleSheetsActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(StyleSheetsActor);
handle.removeGlobalActor(StyleSheetsActor);
};
types.addActorType("stylesheet");
types.addActorType("originalsource");
@ -52,7 +42,7 @@ types.addActorType("originalsource");
* Creates a StyleSheetsActor. StyleSheetsActor provides remote access to the
* stylesheets of a document.
*/
let StyleSheetsActor = protocol.ActorClass({
let StyleSheetsActor = exports.StyleSheetsActor = protocol.ActorClass({
typeName: "stylesheets",
/**

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

@ -30,21 +30,11 @@ const {setTimeout, clearTimeout} = require("sdk/timers");
const DEFAULT_TIMELINE_DATA_PULL_TIMEOUT = 200; // ms
exports.register = function(handle) {
handle.addGlobalActor(TimelineActor, "timelineActor");
handle.addTabActor(TimelineActor, "timelineActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(TimelineActor);
handle.removeTabActor(TimelineActor);
};
/**
* The timeline actor pops and forwards timeline markers registered in
* a docshell.
*/
let TimelineActor = protocol.ActorClass({
let TimelineActor = exports.TimelineActor = protocol.ActorClass({
typeName: "timeline",
events: {

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

@ -15,25 +15,20 @@ Cu.import("resource://gre/modules/Task.jsm");
// TODO bug 943125: remove this polyfill and use Debugger.Frame.prototype.depth
// once it is implemented.
if (!Object.getOwnPropertyDescriptor(Debugger.Frame.prototype, "depth")) {
Debugger.Frame.prototype._depth = null;
Object.defineProperty(Debugger.Frame.prototype, "depth", {
get: function () {
if (this._depth === null) {
if (!this.older) {
this._depth = 0;
} else {
// Hide depth from self-hosted frames.
const increment = this.script && this.script.url == "self-hosted"
? 0
: 1;
this._depth = increment + this.older.depth;
}
}
return this._depth;
function getFrameDepth(frame) {
if (typeof(frame.depth) != "number") {
if (!frame.older) {
frame.depth = 0;
} else {
// Hide depth from self-hosted frames.
const increment = frame.script && frame.script.url == "self-hosted"
? 0
: 1;
frame.depth = increment + getFrameDepth(frame.older);
}
});
}
return frame.depth;
}
const { setTimeout } = require("sdk/timers");
@ -362,7 +357,7 @@ TracerActor.prototype = {
}
if (this._requestsForTraceType.depth) {
packet.depth = aFrame.depth;
packet.depth = getFrameDepth(aFrame);
}
const onExitFrame = this.onExitFrame;
@ -406,7 +401,7 @@ TracerActor.prototype = {
}
if (this._requestsForTraceType.depth) {
packet.depth = aFrame.depth;
packet.depth = getFrameDepth(aFrame);
}
if (aCompletion) {
@ -437,14 +432,7 @@ TracerActor.prototype.requestTypes = {
"stopTrace": TracerActor.prototype.onStopTrace
};
exports.register = function(handle) {
handle.addTabActor(TracerActor, "traceActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(TracerActor, "traceActor");
};
exports.TracerActor = TracerActor;
/**
* MapStack is a collection of key/value pairs with stack ordering,

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

@ -17,16 +17,6 @@ const { ThreadActor } = require("devtools/server/actors/script");
const { on, once, off, emit } = events;
const { method, Arg, Option, RetVal } = protocol;
exports.register = function(handle) {
handle.addTabActor(WebAudioActor, "webaudioActor");
handle.addGlobalActor(WebAudioActor, "webaudioActor");
};
exports.unregister = function(handle) {
handle.removeTabActor(WebAudioActor);
handle.removeGlobalActor(WebAudioActor);
};
const AUDIO_GLOBALS = [
"AudioContext", "AudioNode"
];

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

@ -1476,6 +1476,8 @@ WebConsoleActor.prototype.requestTypes =
sendHTTPRequest: WebConsoleActor.prototype.onSendHTTPRequest
};
exports.WebConsoleActor = WebConsoleActor;
/**
* The AddonConsoleActor implements capabilities needed for the add-on web
@ -1994,13 +1996,3 @@ NetworkEventActor.prototype.requestTypes =
"getResponseContent": NetworkEventActor.prototype.onGetResponseContent,
"getEventTimings": NetworkEventActor.prototype.onGetEventTimings,
};
exports.register = function(handle) {
handle.addGlobalActor(WebConsoleActor, "consoleActor");
handle.addTabActor(WebConsoleActor, "consoleActor");
};
exports.unregister = function(handle) {
handle.removeGlobalActor(WebConsoleActor, "consoleActor");
handle.removeTabActor(WebConsoleActor, "consoleActor");
};

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

@ -18,16 +18,6 @@ const PROGRAM_DEFAULT_TRAITS = 0;
const PROGRAM_BLACKBOX_TRAIT = 1;
const PROGRAM_HIGHLIGHT_TRAIT = 2;
exports.register = function(handle) {
handle.addTabActor(WebGLActor, "webglActor");
handle.addGlobalActor(WebGLActor, "webglActor");
}
exports.unregister = function(handle) {
handle.removeTabActor(WebGLActor);
handle.removeGlobalActor(WebGLActor);
}
/**
* A WebGL Shader contributing to building a WebGL Program.
* You can either retrieve, or compile the source of a shader, which will

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

@ -275,6 +275,13 @@ var DebuggerServer = {
}
gRegisteredModules = {};
// The thread actor is special. It isn't registered as all the other ones
// with a global or tab scope. It is loaded instead by its parent tab actor
// on an 'attach' request. But tests still expect to observe its state
// being reset when DebuggerServer is reset, so let's explicitly reset
// it here.
require("devtools/server/actors/script").cleanup();
this.closeAllListeners();
this.globalActorFactories = {};
this.tabActorFactories = {};
@ -428,11 +435,19 @@ var DebuggerServer = {
this.addTabActors();
let { ChromeDebuggerActor } = require("devtools/server/actors/script");
this.addGlobalActor(ChromeDebuggerActor, "chromeDebugger");
this.registerModule("devtools/server/actors/preference");
this.registerModule("devtools/server/actors/preference", {
prefix: "preference",
constructor: "PreferenceActor",
type: { global: true }
});
}
this.addActors("resource://gre/modules/devtools/server/actors/webapps.js");
this.registerModule("devtools/server/actors/device");
this.registerModule("devtools/server/actors/device", {
prefix: "device",
constructor: "DeviceActor",
type: { global: true }
});
},
/**
@ -458,27 +473,102 @@ var DebuggerServer = {
* Install tab actors.
*/
addTabActors: function() {
this.registerModule("devtools/server/actors/script");
this.registerModule("devtools/server/actors/webconsole");
this.registerModule("devtools/server/actors/inspector");
this.registerModule("devtools/server/actors/call-watcher");
this.registerModule("devtools/server/actors/canvas");
this.registerModule("devtools/server/actors/webgl");
this.registerModule("devtools/server/actors/webaudio");
this.registerModule("devtools/server/actors/stylesheets");
this.registerModule("devtools/server/actors/styleeditor");
this.registerModule("devtools/server/actors/storage");
this.registerModule("devtools/server/actors/gcli");
this.registerModule("devtools/server/actors/tracer");
this.registerModule("devtools/server/actors/memory");
this.registerModule("devtools/server/actors/framerate");
this.registerModule("devtools/server/actors/eventlooplag");
this.registerModule("devtools/server/actors/layout");
this.registerModule("devtools/server/actors/csscoverage");
this.registerModule("devtools/server/actors/monitor");
this.registerModule("devtools/server/actors/timeline");
this.registerModule("devtools/server/actors/webconsole", {
prefix: "console",
constructor: "WebConsoleActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/inspector", {
prefix: "inspector",
constructor: "InspectorActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/call-watcher", {
prefix: "callWatcher",
constructor: "CallWatcherActor",
type: { tab: true }
});
this.registerModule("devtools/server/actors/canvas", {
prefix: "canvas",
constructor: "CanvasActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/webgl", {
prefix: "webgl",
constructor: "WebGLActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/webaudio", {
prefix: "webaudio",
constructor: "WebAudioActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/stylesheets", {
prefix: "styleSheets",
constructor: "StyleSheetsActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/styleeditor", {
prefix: "styleEditor",
constructor: "StyleEditorActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/storage", {
prefix: "storage",
constructor: "StorageActor",
type: { tab: true }
});
this.registerModule("devtools/server/actors/gcli", {
prefix: "gcli",
constructor: "GcliActor",
type: { tab: true }
});
this.registerModule("devtools/server/actors/tracer", {
prefix: "trace",
constructor: "TracerActor",
type: { tab: true }
});
this.registerModule("devtools/server/actors/memory", {
prefix: "memory",
constructor: "MemoryActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/framerate", {
prefix: "framerate",
constructor: "FramerateActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/eventlooplag", {
prefix: "eventLoopLag",
constructor: "EventLoopLagActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/layout", {
prefix: "reflow",
constructor: "ReflowActor",
type: { tab: true }
});
this.registerModule("devtools/server/actors/csscoverage", {
prefix: "cssUsage",
constructor: "CSSUsageActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/monitor", {
prefix: "monitor",
constructor: "MonitorActor",
type: { global: true, tab: true }
});
this.registerModule("devtools/server/actors/timeline", {
prefix: "timeline",
constructor: "TimelineActor",
type: { global: true, tab: true }
});
if ("nsIProfiler" in Ci) {
this.registerModule("devtools/server/actors/profiler");
this.registerModule("devtools/server/actors/profiler", {
prefix: "profiler",
constructor: "ProfilerActor",
type: { global: true, tab: true }
});
}
},

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

@ -203,7 +203,6 @@ function attachTestTabAndResume(aClient, aTitle, aCallback) {
*/
function initTestDebuggerServer(aServer = DebuggerServer)
{
aServer.registerModule("devtools/server/actors/script");
aServer.registerModule("xpcshell-test/testactors");
// Allow incoming connections.
aServer.init(function () { return true; });
@ -211,9 +210,12 @@ function initTestDebuggerServer(aServer = DebuggerServer)
function initTestTracerServer(aServer = DebuggerServer)
{
aServer.registerModule("devtools/server/actors/script");
aServer.registerModule("xpcshell-test/testactors");
aServer.registerModule("devtools/server/actors/tracer");
aServer.registerModule("devtools/server/actors/tracer", {
prefix: "trace",
constructor: "TracerActor",
type: { global: true, tab: true }
});
// Allow incoming connections.
aServer.init(function () { return true; });
}

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

@ -189,7 +189,11 @@ function attachTestTabAndResume(aClient, aTitle, aCallback) {
* Initialize the testing debugger server.
*/
function initTestDebuggerServer() {
DebuggerServer.registerModule("devtools/server/actors/script");
DebuggerServer.registerModule("devtools/server/actors/script", {
prefix: "script",
constructor: "ScriptActor",
type: { global: true, tab: true }
});
DebuggerServer.registerModule("xpcshell-test/testactors");
// Allow incoming connections.
DebuggerServer.init(function () { return true; });