Bug 1256397 - Convert ThreadActor into an instance of ActorClass;r=jryans
authorEddy Bruel <ejpbruel@mozilla.com>
Fri, 01 Apr 2016 10:59:59 +0200
changeset 291368 5fbd6d5079f498694e20506054759c867b30a622
parent 291367 f91054a848d692f7c6f66a5be829ffa5421a898a
child 291369 43ee605bf4666503c19e2b5a27972e8cd4a307aa
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1256397
milestone48.0a1
Bug 1256397 - Convert ThreadActor into an instance of ActorClass;r=jryans
devtools/server/actors/script.js
--- a/devtools/server/actors/script.js
+++ b/devtools/server/actors/script.js
@@ -10,23 +10,25 @@ const Services = require("Services");
 const { Cc, Ci, Cu, Cr, components, ChromeWorker } = require("chrome");
 const { ActorPool, OriginalLocation, GeneratedLocation } = require("devtools/server/actors/common");
 const { BreakpointActor, setBreakpointAtEntryPoints } = require("devtools/server/actors/breakpoint");
 const { EnvironmentActor } = require("devtools/server/actors/environment");
 const { FrameActor } = require("devtools/server/actors/frame");
 const { ObjectActor, createValueGrip, longStringGrip } = require("devtools/server/actors/object");
 const { SourceActor, getSourceURL } = require("devtools/server/actors/source");
 const { DebuggerServer } = require("devtools/server/main");
+const { ActorClass } = require("devtools/server/protocol");
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const { assert, dumpn, update, fetch } = DevToolsUtils;
 const promise = require("promise");
 const PromiseDebugging = require("PromiseDebugging");
 const xpcInspector = require("xpcInspector");
 const ScriptStore = require("./utils/ScriptStore");
 const { DevToolsWorker } = require("devtools/shared/worker/worker");
+const object = require("sdk/util/object");
 
 const { defer, resolve, reject, all } = promise;
 
 loader.lazyGetter(this, "Debugger", () => {
   let Debugger = require("Debugger");
   hackDebugger(Debugger);
   return Debugger;
 });
@@ -402,65 +404,64 @@ EventLoop.prototype = {
  *          - preNest: Function called before entering a nested event loop.
  *          - postNest: Function called after exiting a nested event loop.
  *          - makeDebugger: A function that takes no arguments and instantiates
  *            a Debugger that manages its globals on its own.
  * @param aGlobal object [optional]
  *        An optional (for content debugging only) reference to the content
  *        window.
  */
-function ThreadActor(aParent, aGlobal)
-{
-  this._state = "detached";
-  this._frameActors = [];
-  this._parent = aParent;
-  this._dbg = null;
-  this._gripDepth = 0;
-  this._threadLifetimePool = null;
-  this._tabClosed = false;
-  this._scripts = null;
-  this._pauseOnDOMEvents = null;
+const ThreadActor = ActorClass({
+  typeName: "context",
 
-  this._options = {
-    useSourceMaps: false,
-    autoBlackBox: false
-  };
+  initialize: function (aParent, aGlobal) {
+    this._state = "detached";
+    this._frameActors = [];
+    this._parent = aParent;
+    this._dbg = null;
+    this._gripDepth = 0;
+    this._threadLifetimePool = null;
+    this._tabClosed = false;
+    this._scripts = null;
+    this._pauseOnDOMEvents = null;
 
-  this.breakpointActorMap = new BreakpointActorMap();
-  this.sourceActorStore = new SourceActorStore();
+    this._options = {
+      useSourceMaps: false,
+      autoBlackBox: false
+    };
 
-  this._debuggerSourcesSeen = null;
+    this.breakpointActorMap = new BreakpointActorMap();
+    this.sourceActorStore = new SourceActorStore();
 
-  // A map of actorID -> actor for breakpoints created and managed by the
-  // server.
-  this._hiddenBreakpoints = new Map();
+    this._debuggerSourcesSeen = null;
 
-  this.global = aGlobal;
+    // A map of actorID -> actor for breakpoints created and managed by the
+    // server.
+    this._hiddenBreakpoints = new Map();
+
+    this.global = aGlobal;
 
-  this._allEventsListener = this._allEventsListener.bind(this);
-  this.onNewGlobal = this.onNewGlobal.bind(this);
-  this.onSourceEvent = this.onSourceEvent.bind(this);
-  this.uncaughtExceptionHook = this.uncaughtExceptionHook.bind(this);
-  this.onDebuggerStatement = this.onDebuggerStatement.bind(this);
-  this.onNewScript = this.onNewScript.bind(this);
-  this.objectGrip = this.objectGrip.bind(this);
-  this.pauseObjectGrip = this.pauseObjectGrip.bind(this);
-  this._onWindowReady = this._onWindowReady.bind(this);
-  events.on(this._parent, "window-ready", this._onWindowReady);
-  // Set a wrappedJSObject property so |this| can be sent via the observer svc
-  // for the xpcshell harness.
-  this.wrappedJSObject = this;
-}
+    this._allEventsListener = this._allEventsListener.bind(this);
+    this.onNewGlobal = this.onNewGlobal.bind(this);
+    this.onSourceEvent = this.onSourceEvent.bind(this);
+    this.uncaughtExceptionHook = this.uncaughtExceptionHook.bind(this);
+    this.onDebuggerStatement = this.onDebuggerStatement.bind(this);
+    this.onNewScript = this.onNewScript.bind(this);
+    this.objectGrip = this.objectGrip.bind(this);
+    this.pauseObjectGrip = this.pauseObjectGrip.bind(this);
+    this._onWindowReady = this._onWindowReady.bind(this);
+    events.on(this._parent, "window-ready", this._onWindowReady);
+    // Set a wrappedJSObject property so |this| can be sent via the observer svc
+    // for the xpcshell harness.
+    this.wrappedJSObject = this;
+  },
 
-ThreadActor.prototype = {
   // Used by the ObjectActor to keep track of the depth of grip() calls.
   _gripDepth: null,
 
-  actorPrefix: "context",
-
   get dbg() {
     if (!this._dbg) {
       this._dbg = this._parent.makeDebugger();
       this._dbg.uncaughtExceptionHook = this.uncaughtExceptionHook;
       this._dbg.onDebuggerStatement = this.onDebuggerStatement;
       this._dbg.onNewScript = this.onNewScript;
       this._dbg.on("newGlobal", this.onNewGlobal);
       // Keep the debugger disabled until a client attaches.
@@ -2027,32 +2028,32 @@ ThreadActor.prototype = {
                            '" does not recognize the packet type ' +
                            '"prototypeAndProperties"') };
       }
       result[actorID] = handler.call(actor, {});
     }
     return { from: this.actorID,
              actors: result };
   }
-};
+});
 
-ThreadActor.prototype.requestTypes = {
+ThreadActor.prototype.requestTypes = object.merge(ThreadActor.prototype.requestTypes, {
   "attach": ThreadActor.prototype.onAttach,
   "detach": ThreadActor.prototype.onDetach,
   "reconfigure": ThreadActor.prototype.onReconfigure,
   "resume": ThreadActor.prototype.onResume,
   "clientEvaluate": ThreadActor.prototype.onClientEvaluate,
   "frames": ThreadActor.prototype.onFrames,
   "interrupt": ThreadActor.prototype.onInterrupt,
   "eventListeners": ThreadActor.prototype.onEventListeners,
   "releaseMany": ThreadActor.prototype.onReleaseMany,
   "sources": ThreadActor.prototype.onSources,
   "threadGrips": ThreadActor.prototype.onThreadGrips,
-  "prototypesAndProperties": ThreadActor.prototype.onPrototypesAndProperties,
-};
+  "prototypesAndProperties": ThreadActor.prototype.onPrototypesAndProperties
+});
 
 exports.ThreadActor = ThreadActor;
 
 /**
  * Creates a PauseActor.
  *
  * PauseActors exist for the lifetime of a given debuggee pause.  Used to
  * scope pause-lifetime grips.
@@ -2249,17 +2250,17 @@ function hackDebugger(Debugger) {
  *        constructor usable with addGlobalActor.)
  *
  * @param aParent object
  *        This actor's parent actor. See ThreadActor for a list of expected
  *        properties.
  */
 function ChromeDebuggerActor(aConnection, aParent)
 {
-  ThreadActor.call(this, aParent);
+  ThreadActor.prototype.initialize.call(this, aParent);
 }
 
 ChromeDebuggerActor.prototype = Object.create(ThreadActor.prototype);
 
 update(ChromeDebuggerActor.prototype, {
   constructor: ChromeDebuggerActor,
 
   // A constant prefix that will be used to form the actor ID by the server.
@@ -2277,17 +2278,17 @@ exports.ChromeDebuggerActor = ChromeDebu
  *        is associated. (Currently unused, but required to make this
  *        constructor usable with addGlobalActor.)
  *
  * @param aParent object
  *        This actor's parent actor. See ThreadActor for a list of expected
  *        properties.
  */
 function AddonThreadActor(aConnect, aParent) {
-  ThreadActor.call(this, aParent);
+  ThreadActor.prototype.initialize.call(this, aParent);
 }
 
 AddonThreadActor.prototype = Object.create(ThreadActor.prototype);
 
 update(AddonThreadActor.prototype, {
   constructor: AddonThreadActor,
 
   // A constant prefix that will be used to form the actor ID by the server.