Bug 1444796 - Part 1. Add options to startProfiler to customize profiler parameter from remote. r?gregtatum draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 14 Mar 2018 15:05:48 +0900
changeset 767268 c3e9337886788c024559c2b6f90ef0dd6f03ddb9
parent 767163 c56ef1c14a555023949ad727c86e3c2df995edd2
child 767269 6f5962c213ad5ead21a1307439961fc954c41c2d
push id102544
push userbmo:m_kato@ga2.so-net.ne.jp
push dateWed, 14 Mar 2018 06:45:32 +0000
reviewersgregtatum
bugs1444796
milestone61.0a1
Bug 1444796 - Part 1. Add options to startProfiler to customize profiler parameter from remote. r?gregtatum New remote profiler protocol uses perfActor, but startProfiler doesn't support parameters such as interval, So perfActor should support parameters for startProfiler. MozReview-Commit-ID: 3QiNunLyhnf
devtools/server/actors/perf.js
devtools/shared/specs/perf.js
--- a/devtools/server/actors/perf.js
+++ b/devtools/server/actors/perf.js
@@ -40,28 +40,28 @@ exports.PerfActor = ActorClassWithSpec(p
     }
     Services.obs.removeObserver(this._observer, "profiler-started");
     Services.obs.removeObserver(this._observer, "profiler-stopped");
     Services.obs.removeObserver(this._observer, "chrome-document-global-created");
     Services.obs.removeObserver(this._observer, "last-pb-context-exited");
     Actor.prototype.destroy.call(this);
   },
 
-  startProfiler() {
+  startProfiler(options) {
     if (!IS_SUPPORTED_PLATFORM) {
       return false;
     }
 
     // For a quick implementation, decide on some default values. These may need
     // to be tweaked or made configurable as needed.
     const settings = {
-      entries: 1000000,
-      interval: 1,
-      features: ["js", "stackwalk", "threads", "leaf"],
-      threads: ["GeckoMain", "Compositor"]
+      entries: options.entries || 1000000,
+      interval: options.interval || 1,
+      features: options.features || ["js", "stackwalk", "threads", "leaf"],
+      threads: options.threads || ["GeckoMain", "Compositor"]
     };
 
     try {
       // This can throw an error if the profiler is in the wrong state.
       Services.profiler.StartProfiler(
         settings.entries,
         settings.interval,
         settings.features,
--- a/devtools/shared/specs/perf.js
+++ b/devtools/shared/specs/perf.js
@@ -1,14 +1,14 @@
 /* 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 { RetVal, generateActorSpec } = require("devtools/shared/protocol");
+const { Option, RetVal, generateActorSpec } = require("devtools/shared/protocol");
 
 const perfDescription = {
   typeName: "perf",
 
   events: {
     "profiler-started": {
       type: "profiler-started"
     },
@@ -20,17 +20,22 @@ const perfDescription = {
     },
     "profile-unlocked-from-private-browsing": {
       type: "profile-unlocked-from-private-browsing"
     }
   },
 
   methods: {
     startProfiler: {
-      request: {},
+      request: {
+        entries: Option(0, "number"),
+        interval: Option(0, "number"),
+        features: Option(0, "array:string"),
+        threads: Option(0, "array:string"),
+      },
       response: { value: RetVal("boolean") }
     },
 
     /**
      * Returns null when unable to return the profile.
      */
     getProfileAndStopProfiler: {
       request: {},