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

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: Fix tests 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
« no previous file with comments | « Source/devtools/front_end/profiler/CPUProfileView.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
28 28
29 /** 29 /**
30 * @constructor 30 * @constructor
31 * @extends {WebInspector.TargetAwareObject} 31 * @extends {WebInspector.TargetAwareObject}
32 * @param {!WebInspector.Target} target 32 * @param {!WebInspector.Target} target
33 * @implements {ProfilerAgent.Dispatcher} 33 * @implements {ProfilerAgent.Dispatcher}
34 */ 34 */
35 WebInspector.CPUProfilerModel = function(target) 35 WebInspector.CPUProfilerModel = function(target)
36 { 36 {
37 WebInspector.TargetAwareObject.call(this, target); 37 WebInspector.TargetAwareObject.call(this, target);
38
39 /** @type {?WebInspector.CPUProfilerModel.Delegate} */
40 this._delegate = null;
41 this._isRecording = false; 38 this._isRecording = false;
42 target.registerProfilerDispatcher(this); 39 target.registerProfilerDispatcher(this);
43 target.profilerAgent().enable(); 40 target.profilerAgent().enable();
44 } 41 }
45 42
46 WebInspector.CPUProfilerModel.EventTypes = { 43 WebInspector.CPUProfilerModel.EventTypes = {
47 ProfileStarted: "profile-started", 44 ProfileStarted: "ProfileStarted",
48 ProfileStopped: "profile-stopped" 45 ProfileStopped: "ProfileStopped",
46 ConsoleProfileStarted: "ConsoleProfileStarted",
47 ConsoleProfileFinished: "ConsoleProfileFinished"
49 }; 48 };
50 49
51 WebInspector.CPUProfilerModel.prototype = { 50 WebInspector.CPUProfilerModel.prototype = {
52 /** 51 /**
53 * @param {!WebInspector.CPUProfilerModel.Delegate} delegate
54 */
55 setDelegate: function(delegate)
56 {
57 this._delegate = delegate;
58 },
59
60 /**
61 * @param {string} id 52 * @param {string} id
62 * @param {!DebuggerAgent.Location} scriptLocation 53 * @param {!DebuggerAgent.Location} scriptLocation
63 * @param {!ProfilerAgent.CPUProfile} cpuProfile 54 * @param {!ProfilerAgent.CPUProfile} cpuProfile
64 * @param {string=} title 55 * @param {string=} title
65 */ 56 */
66 consoleProfileFinished: function(id, scriptLocation, cpuProfile, title) 57 consoleProfileFinished: function(id, scriptLocation, cpuProfile, title)
67 { 58 {
68 // Make sure ProfilesPanel is initialized and CPUProfileType is created. 59 // Make sure ProfilesPanel is initialized and CPUProfileType is created.
69 WebInspector.moduleManager.loadModule("profiler"); 60 WebInspector.moduleManager.loadModule("profiler");
70 this._delegate.consoleProfileFinished(id, WebInspector.DebuggerModel.Loc ation.fromPayload(this.target(), scriptLocation), cpuProfile, title); 61 var debuggerLocation = WebInspector.DebuggerModel.Location.fromPayload(t his.target(), scriptLocation);
62 this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.C onsoleProfileFinished, {protocolId: id, scriptLocation: debuggerLocation, cpuPro file: cpuProfile, title: title});
71 }, 63 },
72 64
73 /** 65 /**
74 * @param {string} id 66 * @param {string} id
75 * @param {!DebuggerAgent.Location} scriptLocation 67 * @param {!DebuggerAgent.Location} scriptLocation
76 * @param {string=} title 68 * @param {string=} title
77 */ 69 */
78 consoleProfileStarted: function(id, scriptLocation, title) 70 consoleProfileStarted: function(id, scriptLocation, title)
79 { 71 {
80 // Make sure ProfilesPanel is initialized and CPUProfileType is created. 72 // Make sure ProfilesPanel is initialized and CPUProfileType is created.
81 WebInspector.moduleManager.loadModule("profiler"); 73 WebInspector.moduleManager.loadModule("profiler");
82 this._delegate.consoleProfileStarted(id, WebInspector.DebuggerModel.Loca tion.fromPayload(this.target(), scriptLocation), title); 74 var debuggerLocation = WebInspector.DebuggerModel.Location.fromPayload(t his.target(), scriptLocation)
75 this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.C onsoleProfileStarted, {protocolId: id, scriptLocation: debuggerLocation, title: title});
83 }, 76 },
84 77
85 /** 78 /**
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 },
95
96 /**
97 * @return {boolean} 79 * @return {boolean}
98 */ 80 */
99 isRecordingProfile: function() 81 isRecordingProfile: function()
100 { 82 {
101 return this._isRecording; 83 return this._isRecording;
102 }, 84 },
103 85
86 startRecording: function()
87 {
88 this._isRecording = true;
89 this.target().profilerAgent().start();
90 this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.P rofileStarted);
91 WebInspector.userMetrics.ProfilesCPUProfileTaken.record();
92 },
93
94 /**
95 * @param {!function(?string,?ProfilerAgent.CPUProfile)} callback
96 */
97 stopRecording: function(callback)
98 {
99 this._isRecording = false;
100 this.target().profilerAgent().stop(callback);
101 this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.P rofileStopped);
102 },
103
104 __proto__: WebInspector.TargetAwareObject.prototype 104 __proto__: WebInspector.TargetAwareObject.prototype
105 } 105 }
106 106
107 /** @interface */
108 WebInspector.CPUProfilerModel.Delegate = function() {};
109
110 WebInspector.CPUProfilerModel.Delegate.prototype = {
111 /**
112 * @param {string} protocolId
113 * @param {!WebInspector.DebuggerModel.Location} scriptLocation
114 * @param {string=} title
115 */
116 consoleProfileStarted: function(protocolId, scriptLocation, title) {},
117
118 /**
119 * @param {string} protocolId
120 * @param {!WebInspector.DebuggerModel.Location} scriptLocation
121 * @param {!ProfilerAgent.CPUProfile} cpuProfile
122 * @param {string=} title
123 */
124 consoleProfileFinished: function(protocolId, scriptLocation, cpuProfile, tit le) {}
125 }
126
127 /** 107 /**
128 * @type {!WebInspector.CPUProfilerModel} 108 * @type {!WebInspector.CPUProfilerModel}
129 */ 109 */
130 WebInspector.cpuProfilerModel; 110 WebInspector.cpuProfilerModel;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/profiler/CPUProfileView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698