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

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

Issue 2721663005: [DevTools] Access cpu profiler only when JS capability is present. (Closed)
Patch Set: rebased Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
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..5f7554f37b4da3763384ba454fab007295433dfa 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});
@@ -100,8 +91,10 @@ SDK.CPUProfilerModel = class extends SDK.SDKModel {
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);
+ this._profilerAgent.start();
}
/**
@@ -117,20 +110,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 = {

Powered by Google App Engine
This is Rietveld 408576698