Chromium Code Reviews| 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 500369d22a8a9a6d40268e8200d6a6901525c188..16045c95bce2cb7a600d8bf9b3af5ba2473de2e1 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfilerModel.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfilerModel.js |
| @@ -25,9 +25,9 @@ |
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| + |
| /** |
| * @implements {Protocol.ProfilerDispatcher} |
| - * @unrestricted |
| */ |
| SDK.CPUProfilerModel = class extends SDK.SDKModel { |
| /** |
| @@ -36,17 +36,10 @@ SDK.CPUProfilerModel = class extends SDK.SDKModel { |
| constructor(target) { |
| super(target); |
| this._isRecording = false; |
| + this._profilerAgent = target.profilerAgent(); |
| target.registerProfilerDispatcher(this); |
| - target.profilerAgent().enable(); |
| - |
| - this._configureCpuProfilerSamplingInterval(); |
| - Common.moduleSetting('highResolutionCpuProfiling') |
| - .addChangeListener(this._configureCpuProfilerSamplingInterval, this); |
| - } |
| - |
| - _configureCpuProfilerSamplingInterval() { |
| - var intervalUs = Common.moduleSetting('highResolutionCpuProfiling').get() ? 100 : 1000; |
| - this.target().profilerAgent().setSamplingInterval(intervalUs); |
| + this._profilerAgent.enable(); |
| + this._debuggerModel = /** @type {!SDK.DebuggerModel} */ (target.model(SDK.DebuggerModel)); |
| } |
| /** |
| @@ -80,10 +73,8 @@ SDK.CPUProfilerModel = class extends SDK.SDKModel { |
| */ |
| _dispatchProfileEvent(eventName, id, scriptLocation, title, cpuProfile) { |
| // Make sure ProfilesPanel is initialized and CPUProfileType is created. |
| - self.runtime.loadModulePromise('profiler').then(_ => { |
| - var debuggerModel = |
| - /** @type {!SDK.DebuggerModel} */ (SDK.DebuggerModel.fromTarget(this.target())); |
| - var debuggerLocation = SDK.DebuggerModel.Location.fromPayload(debuggerModel, scriptLocation); |
| + self.runtime.loadModulePromise('profiler').then(() => { |
| + var debuggerLocation = SDK.DebuggerModel.Location.fromPayload(this._debuggerModel, scriptLocation); |
| var globalId = this.target().id() + '.' + id; |
| var data = /** @type {!SDK.CPUProfilerModel.EventData} */ ( |
| {id: globalId, scriptLocation: debuggerLocation, cpuProfile: cpuProfile, title: title}); |
| @@ -98,10 +89,15 @@ SDK.CPUProfilerModel = class extends SDK.SDKModel { |
| return this._isRecording; |
| } |
| + /** |
| + * @return {!Promise} |
|
alph
2017/02/28 23:59:13
Why promise? It's a sync function
dgozman
2017/03/01 00:18:41
Correct, removed the promise.
|
| + */ |
| startRecording() { |
| this._isRecording = true; |
| - this.target().profilerAgent().start(); |
| Host.userMetrics.actionTaken(Host.UserMetrics.Action.ProfilesCPUProfileTaken); |
| + var intervalUs = Common.moduleSetting('highResolutionCpuProfiling').get() ? 100 : 1000; |
| + this._profilerAgent.setSamplingInterval(intervalUs); |
| + return this._profilerAgent.start(); |
| } |
| /** |
| @@ -117,20 +113,32 @@ SDK.CPUProfilerModel = class extends SDK.SDKModel { |
| return !error && profile ? profile : null; |
| } |
| this._isRecording = false; |
| - return this.target().profilerAgent().stop(extractProfile); |
| + return this._profilerAgent.stop(extractProfile); |
| } |
| /** |
| - * @override |
| + * @return {!Promise} |
| + */ |
| + startPreciseCoverage() { |
| + return this._profilerAgent.startPreciseCoverage(); |
| + } |
| + |
| + /** |
| + * @return {!Promise<!Array<!Protocol.Profiler.ScriptCoverage>>} |
| + */ |
| + takePreciseCoverage() { |
| + return this._profilerAgent.takePreciseCoverage((error, coverage) => error ? [] : coverage); |
| + } |
| + |
| + /** |
| + * @return {!Promise} |
| */ |
| - dispose() { |
| - Common.moduleSetting('highResolutionCpuProfiling') |
| - .removeChangeListener(this._configureCpuProfilerSamplingInterval, this); |
| + stopPreciseCoverage() { |
| + return this._profilerAgent.stopPreciseCoverage(); |
| } |
| }; |
| -// TODO(dgozman): should be JS. |
| -SDK.SDKModel.register(SDK.CPUProfilerModel, SDK.Target.Capability.None); |
| +SDK.SDKModel.register(SDK.CPUProfilerModel, SDK.Target.Capability.JS); |
| /** @enum {symbol} */ |
| SDK.CPUProfilerModel.Events = { |