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

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

Issue 360053003: DevTools: Basic support of multiple targets for CPU profiler (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 target.profilerAgent().enable(); 43 target.profilerAgent().enable();
44 } 44 }
45 45
46 WebInspector.CPUProfilerModel.EventTypes = { 46 WebInspector.CPUProfilerModel.EventTypes = {
47 ProfileStarted: "profile-started", 47 ProfileStarted: "profile-started",
48 ProfileStopped: "profile-stopped" 48 ProfileStopped: "profile-stopped"
49 }; 49 };
50 50
51 WebInspector.CPUProfilerModel.prototype = { 51 WebInspector.CPUProfilerModel.prototype = {
52 /** 52 /**
53 * @param {!WebInspector.CPUProfilerModel.Delegate} delegate 53 * @param {?WebInspector.CPUProfilerModel.Delegate} delegate
54 */ 54 */
55 setDelegate: function(delegate) 55 setDelegate: function(delegate)
56 { 56 {
57 this._delegate = delegate; 57 this._delegate = delegate;
58 }, 58 },
59 59
60 /** 60 /**
61 * @param {string} id 61 * @param {string} id
62 * @param {!DebuggerAgent.Location} scriptLocation 62 * @param {!DebuggerAgent.Location} scriptLocation
63 * @param {!ProfilerAgent.CPUProfile} cpuProfile 63 * @param {!ProfilerAgent.CPUProfile} cpuProfile
64 * @param {string=} title 64 * @param {string=} title
65 */ 65 */
66 consoleProfileFinished: function(id, scriptLocation, cpuProfile, title) 66 consoleProfileFinished: function(id, scriptLocation, cpuProfile, title)
67 { 67 {
68 // Make sure ProfilesPanel is initialized and CPUProfileType is created. 68 // Make sure ProfilesPanel is initialized and CPUProfileType is created.
69 WebInspector.moduleManager.loadModule("profiler"); 69 WebInspector.moduleManager.loadModule("profiler");
70 this._delegate.consoleProfileFinished(id, WebInspector.DebuggerModel.Loc ation.fromPayload(this.target(), scriptLocation), cpuProfile, title); 70 if (this._delegate)
71 this._delegate.consoleProfileFinished(id, WebInspector.DebuggerModel .Location.fromPayload(this.target(), scriptLocation), cpuProfile, title);
71 }, 72 },
72 73
73 /** 74 /**
74 * @param {string} id 75 * @param {string} id
75 * @param {!DebuggerAgent.Location} scriptLocation 76 * @param {!DebuggerAgent.Location} scriptLocation
76 * @param {string=} title 77 * @param {string=} title
77 */ 78 */
78 consoleProfileStarted: function(id, scriptLocation, title) 79 consoleProfileStarted: function(id, scriptLocation, title)
79 { 80 {
80 // Make sure ProfilesPanel is initialized and CPUProfileType is created. 81 // Make sure ProfilesPanel is initialized and CPUProfileType is created.
81 WebInspector.moduleManager.loadModule("profiler"); 82 WebInspector.moduleManager.loadModule("profiler");
82 this._delegate.consoleProfileStarted(id, WebInspector.DebuggerModel.Loca tion.fromPayload(this.target(), scriptLocation), title); 83 if (this._delegate)
83 }, 84 this._delegate.consoleProfileStarted(id, WebInspector.DebuggerModel .Location.fromPayload(this.target(), scriptLocation), title);
84
85 /**
86 * @param {boolean} isRecording
87 */
88 setRecording: function(isRecording)
89 {
90 this._isRecording = isRecording;
91 this.dispatchEventToListeners(isRecording ?
92 WebInspector.CPUProfilerModel.EventTypes.ProfileStarted :
93 WebInspector.CPUProfilerModel.EventTypes.ProfileStopped);
94 }, 85 },
95 86
96 /** 87 /**
97 * @return {boolean} 88 * @return {boolean}
98 */ 89 */
99 isRecordingProfile: function() 90 isRecordingProfile: function()
100 { 91 {
101 return this._isRecording; 92 return this._isRecording;
102 }, 93 },
103 94
95 startRecording: function()
96 {
97 this._isRecording = true;
98 this.target().profilerAgent().start();
99 this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.P rofileStarted);
100 WebInspector.userMetrics.ProfilesCPUProfileTaken.record();
101 },
102
103 /**
104 * @param {!function(?string,?ProfilerAgent.CPUProfile)} callback
105 */
106 stopRecording: function(callback)
107 {
108 this._isRecording = false;
109 this.target().profilerAgent().stop(callback);
110 this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.P rofileStopped);
111 },
112
104 __proto__: WebInspector.TargetAwareObject.prototype 113 __proto__: WebInspector.TargetAwareObject.prototype
105 } 114 }
106 115
107 /** @interface */ 116 /** @interface */
108 WebInspector.CPUProfilerModel.Delegate = function() {}; 117 WebInspector.CPUProfilerModel.Delegate = function() {};
109 118
110 WebInspector.CPUProfilerModel.Delegate.prototype = { 119 WebInspector.CPUProfilerModel.Delegate.prototype = {
111 /** 120 /**
112 * @param {string} protocolId 121 * @param {string} protocolId
113 * @param {!WebInspector.DebuggerModel.Location} scriptLocation 122 * @param {!WebInspector.DebuggerModel.Location} scriptLocation
114 * @param {string=} title 123 * @param {string=} title
115 */ 124 */
116 consoleProfileStarted: function(protocolId, scriptLocation, title) {}, 125 consoleProfileStarted: function(protocolId, scriptLocation, title) {},
117 126
118 /** 127 /**
119 * @param {string} protocolId 128 * @param {string} protocolId
120 * @param {!WebInspector.DebuggerModel.Location} scriptLocation 129 * @param {!WebInspector.DebuggerModel.Location} scriptLocation
121 * @param {!ProfilerAgent.CPUProfile} cpuProfile 130 * @param {!ProfilerAgent.CPUProfile} cpuProfile
122 * @param {string=} title 131 * @param {string=} title
123 */ 132 */
124 consoleProfileFinished: function(protocolId, scriptLocation, cpuProfile, tit le) {} 133 consoleProfileFinished: function(protocolId, scriptLocation, cpuProfile, tit le) {}
125 } 134 }
126 135
127 /** 136 /**
128 * @type {!WebInspector.CPUProfilerModel} 137 * @type {!WebInspector.CPUProfilerModel}
129 */ 138 */
130 WebInspector.cpuProfilerModel; 139 WebInspector.cpuProfilerModel;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698