Bug 1277622 - Use ActorClassWithSpec for the HeapSnapshotFileActor; r=ejpbruel
authorNick Fitzgerald <fitzgen@gmail.com>
Fri, 03 Jun 2016 10:45:10 -0700
changeset 339356 2e7770dcd50e115f4348a2e6486530b8187908cb
parent 339355 79f819ffec36ba80c63e4b32a680654f75d623ab
child 339357 9ff998641a493cd21990e500850742007c2ee3b8
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersejpbruel
bugs1277622
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1277622 - Use ActorClassWithSpec for the HeapSnapshotFileActor; r=ejpbruel We don't have a HeapSnapshotFileFront, this actor is used under the covers in the MemoryFront, but we should work towards all actors being defined in the WithSpec way.
devtools/server/actors/heap-snapshot-file.js
devtools/shared/specs/heap-snapshot-file.js
devtools/shared/specs/moz.build
--- a/devtools/server/actors/heap-snapshot-file.js
+++ b/devtools/server/actors/heap-snapshot-file.js
@@ -4,31 +4,31 @@
 
 "use strict";
 
 const protocol = require("devtools/shared/protocol");
 const { method, Arg } = protocol;
 const Services = require("Services");
 const { Task } = require("devtools/shared/task");
 
+const { heapSnapshotFileSpec } = require("devtools/shared/specs/heap-snapshot-file");
+
 loader.lazyRequireGetter(this, "DevToolsUtils",
                          "devtools/shared/DevToolsUtils");
 loader.lazyRequireGetter(this, "OS", "resource://gre/modules/osfile.jsm", true);
 loader.lazyRequireGetter(this, "HeapSnapshotFileUtils",
                          "devtools/shared/heapsnapshot/HeapSnapshotFileUtils");
 
 /**
  * The HeapSnapshotFileActor handles transferring heap snapshot files from the
  * server to the client. This has to be a global actor in the parent process
  * because child processes are sandboxed and do not have access to the file
  * system.
  */
-exports.HeapSnapshotFileActor = protocol.ActorClass({
-  typeName: "heapSnapshotFile",
-
+exports.HeapSnapshotFileActor = protocol.ActorClassWithSpec(heapSnapshotFileSpec, {
   initialize: function (conn, parent) {
     if (Services.appInfo &&
         (Services.appInfo.processType !==
          Services.appInfo.PROCESS_TYPE_DEFAULT)) {
       const err = new Error("Attempt to create a HeapSnapshotFileActor in a " +
                             "child process! The HeapSnapshotFileActor *MUST* " +
                             "be in the parent process!");
       DevToolsUtils.reportException(
@@ -37,17 +37,17 @@ exports.HeapSnapshotFileActor = protocol
     }
 
     protocol.Actor.prototype.initialize.call(this, conn, parent);
   },
 
   /**
    * @see MemoryFront.prototype.transferHeapSnapshot
    */
-  transferHeapSnapshot: method(Task.async(function* (snapshotId) {
+  transferHeapSnapshot: Task.async(function* (snapshotId) {
     const snapshotFilePath =
           HeapSnapshotFileUtils.getHeapSnapshotTempFilePath(snapshotId);
     if (!snapshotFilePath) {
       throw new Error(`No heap snapshot with id: ${snapshotId}`);
     }
 
     const streamPromise = DevToolsUtils.openFileStream(snapshotFilePath);
 
@@ -60,15 +60,11 @@ exports.HeapSnapshotFileActor = protocol
 
     const [bulk, stream] = yield Promise.all([bulkPromise, streamPromise]);
 
     try {
       yield bulk.copyFrom(stream);
     } finally {
       stream.close();
     }
-  }), {
-    request: {
-      snapshotId: Arg(0, "string")
-    }
   }),
 
 });
new file mode 100644
--- /dev/null
+++ b/devtools/shared/specs/heap-snapshot-file.js
@@ -0,0 +1,20 @@
+/* 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";
+
+const { Arg, generateActorSpec } = require("devtools/shared/protocol");
+
+const heapSnapshotFileSpec = generateActorSpec({
+  typeName: "heapSnapshotFile",
+
+  methods: {
+    transferHeapSnapshot: {
+      request: {
+        snapshotId: Arg(0, "string")
+      }
+    }
+  },
+});
+
+exports.heapSnapshotFileSpec = heapSnapshotFileSpec;
--- a/devtools/shared/specs/moz.build
+++ b/devtools/shared/specs/moz.build
@@ -3,16 +3,17 @@
 # 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/.
 
 DevToolsModules(
     'addons.js',
     'animation.js',
     'css-properties.js',
+    'heap-snapshot-file.js',
     'highlighters.js',
     'inspector.js',
     'node.js',
     'storage.js',
     'styleeditor.js',
     'styles.js',
     'stylesheets.js'
 )