Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/CPUProfilerModel.js

Issue 2850333002: DevTools: Promisify Profiler and HeapProfiler domains (Closed)
Patch Set: addressing comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 10 *
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 startRecording() { 116 startRecording() {
117 this._isRecording = true; 117 this._isRecording = true;
118 var intervalUs = Common.moduleSetting('highResolutionCpuProfiling').get() ? 100 : 1000; 118 var intervalUs = Common.moduleSetting('highResolutionCpuProfiling').get() ? 100 : 1000;
119 this._profilerAgent.setSamplingInterval(intervalUs); 119 this._profilerAgent.setSamplingInterval(intervalUs);
120 this._profilerAgent.start(); 120 this._profilerAgent.start();
121 } 121 }
122 122
123 /** 123 /**
124 * @return {!Promise.<?Protocol.Profiler.Profile>} 124 * @return {!Promise<?Protocol.Profiler.Profile>}
125 */ 125 */
126 stopRecording() { 126 stopRecording() {
127 /**
128 * @param {?Protocol.Error} error
129 * @param {?Protocol.Profiler.Profile} profile
130 * @return {?Protocol.Profiler.Profile}
131 */
132 function extractProfile(error, profile) {
133 return !error && profile ? profile : null;
134 }
135 this._isRecording = false; 127 this._isRecording = false;
136 return this._profilerAgent.stop(extractProfile); 128 return this._profilerAgent.stop();
137 } 129 }
138 130
139 /** 131 /**
140 * @return {!Promise} 132 * @return {!Promise}
141 */ 133 */
142 startPreciseCoverage() { 134 startPreciseCoverage() {
143 return this._profilerAgent.startPreciseCoverage(); 135 return this._profilerAgent.startPreciseCoverage();
144 } 136 }
145 137
146 /** 138 /**
147 * @return {!Promise<!Array<!Protocol.Profiler.ScriptCoverage>>} 139 * @return {!Promise<!Array<!Protocol.Profiler.ScriptCoverage>>}
148 */ 140 */
149 takePreciseCoverage() { 141 takePreciseCoverage() {
150 return this._profilerAgent.takePreciseCoverage((error, coverage) => error ? [] : coverage); 142 return this._profilerAgent.takePreciseCoverage().then(result => result || [] );
151 } 143 }
152 144
153 /** 145 /**
154 * @return {!Promise} 146 * @return {!Promise}
155 */ 147 */
156 stopPreciseCoverage() { 148 stopPreciseCoverage() {
157 return this._profilerAgent.stopPreciseCoverage(); 149 return this._profilerAgent.stopPreciseCoverage();
158 } 150 }
159 }; 151 };
160 152
161 SDK.SDKModel.register(SDK.CPUProfilerModel, SDK.Target.Capability.JS, true); 153 SDK.SDKModel.register(SDK.CPUProfilerModel, SDK.Target.Capability.JS, true);
162 154
163 /** @enum {symbol} */ 155 /** @enum {symbol} */
164 SDK.CPUProfilerModel.Events = { 156 SDK.CPUProfilerModel.Events = {
165 ConsoleProfileStarted: Symbol('ConsoleProfileStarted'), 157 ConsoleProfileStarted: Symbol('ConsoleProfileStarted'),
166 ConsoleProfileFinished: Symbol('ConsoleProfileFinished') 158 ConsoleProfileFinished: Symbol('ConsoleProfileFinished')
167 }; 159 };
168 160
169 /** @typedef {!{id: string, scriptLocation: !SDK.DebuggerModel.Location, title: string, cpuProfile: (!Protocol.Profiler.Profile|undefined), cpuProfilerModel: !S DK.CPUProfilerModel}} */ 161 /** @typedef {!{id: string, scriptLocation: !SDK.DebuggerModel.Location, title: string, cpuProfile: (!Protocol.Profiler.Profile|undefined), cpuProfilerModel: !S DK.CPUProfilerModel}} */
170 SDK.CPUProfilerModel.EventData; 162 SDK.CPUProfilerModel.EventData;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698