| Index: third_party/WebKit/Source/devtools/front_end/sdk/CPUProfilerModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfilerModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfilerModel.js
|
| index 0ac11dc68171527c620731b59c81c97dcac7fec2..03046f753bcd2ce3c642ceaa0e894fa93cd64e31 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfilerModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfilerModel.js
|
| @@ -25,119 +25,115 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| -
|
| /**
|
| - * @constructor
|
| - * @extends {WebInspector.SDKModel}
|
| - * @param {!WebInspector.Target} target
|
| * @implements {ProfilerAgent.Dispatcher}
|
| + * @unrestricted
|
| */
|
| -WebInspector.CPUProfilerModel = function(target)
|
| -{
|
| - WebInspector.SDKModel.call(this, WebInspector.CPUProfilerModel, target);
|
| +WebInspector.CPUProfilerModel = class extends WebInspector.SDKModel {
|
| + /**
|
| + * @param {!WebInspector.Target} target
|
| + */
|
| + constructor(target) {
|
| + super(WebInspector.CPUProfilerModel, target);
|
| this._isRecording = false;
|
| target.registerProfilerDispatcher(this);
|
| target.profilerAgent().enable();
|
|
|
| this._configureCpuProfilerSamplingInterval();
|
| - WebInspector.moduleSetting("highResolutionCpuProfiling").addChangeListener(this._configureCpuProfilerSamplingInterval, this);
|
| -};
|
| + WebInspector.moduleSetting('highResolutionCpuProfiling')
|
| + .addChangeListener(this._configureCpuProfilerSamplingInterval, this);
|
| + }
|
|
|
| -/** @enum {symbol} */
|
| -WebInspector.CPUProfilerModel.Events = {
|
| - ConsoleProfileStarted: Symbol("ConsoleProfileStarted"),
|
| - ConsoleProfileFinished: Symbol("ConsoleProfileFinished")
|
| -};
|
| + _configureCpuProfilerSamplingInterval() {
|
| + var intervalUs = WebInspector.moduleSetting('highResolutionCpuProfiling').get() ? 100 : 1000;
|
| + this.target().profilerAgent().setSamplingInterval(intervalUs);
|
| + }
|
|
|
| -/** @typedef {!{id: string, scriptLocation: !WebInspector.DebuggerModel.Location, title: (string|undefined), cpuProfile: (!ProfilerAgent.Profile|undefined)}} */
|
| -WebInspector.CPUProfilerModel.EventData;
|
| + /**
|
| + * @override
|
| + * @param {string} id
|
| + * @param {!DebuggerAgent.Location} scriptLocation
|
| + * @param {string=} title
|
| + */
|
| + consoleProfileStarted(id, scriptLocation, title) {
|
| + this._dispatchProfileEvent(WebInspector.CPUProfilerModel.Events.ConsoleProfileStarted, id, scriptLocation, title);
|
| + }
|
|
|
| -WebInspector.CPUProfilerModel.prototype = {
|
| - _configureCpuProfilerSamplingInterval: function()
|
| - {
|
| - var intervalUs = WebInspector.moduleSetting("highResolutionCpuProfiling").get() ? 100 : 1000;
|
| - this.target().profilerAgent().setSamplingInterval(intervalUs);
|
| - },
|
| + /**
|
| + * @override
|
| + * @param {string} id
|
| + * @param {!DebuggerAgent.Location} scriptLocation
|
| + * @param {!ProfilerAgent.Profile} cpuProfile
|
| + * @param {string=} title
|
| + */
|
| + consoleProfileFinished(id, scriptLocation, cpuProfile, title) {
|
| + this._dispatchProfileEvent(
|
| + WebInspector.CPUProfilerModel.Events.ConsoleProfileFinished, id, scriptLocation, title, cpuProfile);
|
| + }
|
|
|
| - /**
|
| - * @override
|
| - * @param {string} id
|
| - * @param {!DebuggerAgent.Location} scriptLocation
|
| - * @param {string=} title
|
| - */
|
| - consoleProfileStarted: function(id, scriptLocation, title)
|
| - {
|
| - this._dispatchProfileEvent(WebInspector.CPUProfilerModel.Events.ConsoleProfileStarted, id, scriptLocation, title);
|
| - },
|
| + /**
|
| + * @param {symbol} eventName
|
| + * @param {string} id
|
| + * @param {!DebuggerAgent.Location} scriptLocation
|
| + * @param {string=} title
|
| + * @param {!ProfilerAgent.Profile=} cpuProfile
|
| + */
|
| + _dispatchProfileEvent(eventName, id, scriptLocation, title, cpuProfile) {
|
| + // Make sure ProfilesPanel is initialized and CPUProfileType is created.
|
| + self.runtime.loadModulePromise('profiler').then(_ => {
|
| + var debuggerModel =
|
| + /** @type {!WebInspector.DebuggerModel} */ (WebInspector.DebuggerModel.fromTarget(this.target()));
|
| + var debuggerLocation = WebInspector.DebuggerModel.Location.fromPayload(debuggerModel, scriptLocation);
|
| + var globalId = this.target().id() + '.' + id;
|
| + var data = /** @type {!WebInspector.CPUProfilerModel.EventData} */ (
|
| + {id: globalId, scriptLocation: debuggerLocation, cpuProfile: cpuProfile, title: title});
|
| + this.dispatchEventToListeners(eventName, data);
|
| + });
|
| + }
|
|
|
| - /**
|
| - * @override
|
| - * @param {string} id
|
| - * @param {!DebuggerAgent.Location} scriptLocation
|
| - * @param {!ProfilerAgent.Profile} cpuProfile
|
| - * @param {string=} title
|
| - */
|
| - consoleProfileFinished: function(id, scriptLocation, cpuProfile, title)
|
| - {
|
| - this._dispatchProfileEvent(WebInspector.CPUProfilerModel.Events.ConsoleProfileFinished, id, scriptLocation, title, cpuProfile);
|
| - },
|
| + /**
|
| + * @return {boolean}
|
| + */
|
| + isRecordingProfile() {
|
| + return this._isRecording;
|
| + }
|
|
|
| - /**
|
| - * @param {symbol} eventName
|
| - * @param {string} id
|
| - * @param {!DebuggerAgent.Location} scriptLocation
|
| - * @param {string=} title
|
| - * @param {!ProfilerAgent.Profile=} cpuProfile
|
| - */
|
| - _dispatchProfileEvent: function(eventName, id, scriptLocation, title, cpuProfile)
|
| - {
|
| - // Make sure ProfilesPanel is initialized and CPUProfileType is created.
|
| - self.runtime.loadModulePromise("profiler").then(_ => {
|
| - var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (WebInspector.DebuggerModel.fromTarget(this.target()));
|
| - var debuggerLocation = WebInspector.DebuggerModel.Location.fromPayload(debuggerModel, scriptLocation);
|
| - var globalId = this.target().id() + "." + id;
|
| - var data = /** @type {!WebInspector.CPUProfilerModel.EventData} */ ({id: globalId, scriptLocation: debuggerLocation, cpuProfile: cpuProfile, title: title});
|
| - this.dispatchEventToListeners(eventName, data);
|
| - });
|
| - },
|
| -
|
| - /**
|
| - * @return {boolean}
|
| - */
|
| - isRecordingProfile: function()
|
| - {
|
| - return this._isRecording;
|
| - },
|
| -
|
| - startRecording: function()
|
| - {
|
| - this._isRecording = true;
|
| - this.target().profilerAgent().start();
|
| - WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.ProfilesCPUProfileTaken);
|
| - },
|
| + startRecording() {
|
| + this._isRecording = true;
|
| + this.target().profilerAgent().start();
|
| + WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.ProfilesCPUProfileTaken);
|
| + }
|
|
|
| + /**
|
| + * @return {!Promise.<?ProfilerAgent.Profile>}
|
| + */
|
| + stopRecording() {
|
| /**
|
| - * @return {!Promise.<?ProfilerAgent.Profile>}
|
| + * @param {?Protocol.Error} error
|
| + * @param {?ProfilerAgent.Profile} profile
|
| + * @return {?ProfilerAgent.Profile}
|
| */
|
| - stopRecording: function()
|
| - {
|
| - /**
|
| - * @param {?Protocol.Error} error
|
| - * @param {?ProfilerAgent.Profile} profile
|
| - * @return {?ProfilerAgent.Profile}
|
| - */
|
| - function extractProfile(error, profile)
|
| - {
|
| - return !error && profile ? profile : null;
|
| - }
|
| - this._isRecording = false;
|
| - return this.target().profilerAgent().stop(extractProfile);
|
| - },
|
| + function extractProfile(error, profile) {
|
| + return !error && profile ? profile : null;
|
| + }
|
| + this._isRecording = false;
|
| + return this.target().profilerAgent().stop(extractProfile);
|
| + }
|
|
|
| - dispose: function()
|
| - {
|
| - WebInspector.moduleSetting("highResolutionCpuProfiling").removeChangeListener(this._configureCpuProfilerSamplingInterval, this);
|
| - },
|
| + /**
|
| + * @override
|
| + */
|
| + dispose() {
|
| + WebInspector.moduleSetting('highResolutionCpuProfiling')
|
| + .removeChangeListener(this._configureCpuProfilerSamplingInterval, this);
|
| + }
|
| +};
|
|
|
| - __proto__: WebInspector.SDKModel.prototype
|
| +/** @enum {symbol} */
|
| +WebInspector.CPUProfilerModel.Events = {
|
| + ConsoleProfileStarted: Symbol('ConsoleProfileStarted'),
|
| + ConsoleProfileFinished: Symbol('ConsoleProfileFinished')
|
| };
|
| +
|
| +/** @typedef {!{id: string, scriptLocation: !WebInspector.DebuggerModel.Location, title: (string|undefined), cpuProfile: (!ProfilerAgent.Profile|undefined)}} */
|
| +WebInspector.CPUProfilerModel.EventData;
|
|
|