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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/profiler/CPUProfileView.js

Issue 2721663005: [DevTools] Access cpu profiler only when JS capability is present. (Closed)
Patch Set: coverage Created 3 years, 9 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 scriptId: scriptLocation.scriptId, 182 scriptId: scriptLocation.scriptId,
183 url: script ? script.contentURL() : '', 183 url: script ? script.contentURL() : '',
184 lineNumber: scriptLocation.lineNumber, 184 lineNumber: scriptLocation.lineNumber,
185 columnNumber: scriptLocation.columnNumber || 0 185 columnNumber: scriptLocation.columnNumber || 0
186 }]); 186 }]);
187 187
188 target.consoleModel.addMessage(message); 188 target.consoleModel.addMessage(message);
189 } 189 }
190 190
191 startRecordingProfile() { 191 startRecordingProfile() {
192 var target = UI.context.flavor(SDK.Target); 192 var cpuProfilerModel = UI.context.flavor(SDK.CPUProfilerModel);
193 if (this.profileBeingRecorded() || !target) 193 if (this.profileBeingRecorded() || !cpuProfilerModel)
194 return; 194 return;
195 var profile = new Profiler.CPUProfileHeader(target, this); 195 var profile = new Profiler.CPUProfileHeader(cpuProfilerModel.target(), this) ;
196 this.setProfileBeingRecorded(profile); 196 this.setProfileBeingRecorded(profile);
197 SDK.targetManager.suspendAllTargets(); 197 SDK.targetManager.suspendAllTargets();
198 this.addProfile(profile); 198 this.addProfile(profile);
199 profile.updateStatus(Common.UIString('Recording\u2026')); 199 profile.updateStatus(Common.UIString('Recording\u2026'));
200 this._recording = true; 200 this._recording = true;
201 target.cpuProfilerModel.startRecording(); 201 cpuProfilerModel.startRecording();
202 } 202 }
203 203
204 stopRecordingProfile() { 204 stopRecordingProfile() {
205 this._recording = false; 205 this._recording = false;
206 if (!this.profileBeingRecorded() || !this.profileBeingRecorded().target()) 206 if (!this.profileBeingRecorded() || !this.profileBeingRecorded().target())
207 return; 207 return;
208 208
209 var recordedProfile; 209 var recordedProfile;
210 210
211 /** 211 /**
(...skipping 11 matching lines...) Expand all
223 } 223 }
224 224
225 /** 225 /**
226 * @this {Profiler.CPUProfileType} 226 * @this {Profiler.CPUProfileType}
227 */ 227 */
228 function fireEvent() { 228 function fireEvent() {
229 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, recordedProfile); 229 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, recordedProfile);
230 } 230 }
231 231
232 this.profileBeingRecorded() 232 this.profileBeingRecorded()
233 .target() 233 .target()
alph 2017/02/28 23:59:13 nit: I'd rather write the synchronous part in a si
dgozman 2017/03/01 00:18:41 That's what I did, but formatter thinks differentl
234 .cpuProfilerModel.stopRecording() 234 .model(SDK.CPUProfilerModel)
235 .stopRecording()
235 .then(didStopProfiling.bind(this)) 236 .then(didStopProfiling.bind(this))
236 .then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager)) 237 .then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager))
237 .then(fireEvent.bind(this)); 238 .then(fireEvent.bind(this));
238 } 239 }
239 240
240 /** 241 /**
241 * @override 242 * @override
242 * @param {string} title 243 * @param {string} title
243 * @return {!Profiler.ProfileHeader} 244 * @return {!Profiler.ProfileHeader}
244 */ 245 */
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 * @param {!SDK.CPUProfileNode} node 459 * @param {!SDK.CPUProfileNode} node
459 */ 460 */
460 constructor(depth, duration, startTime, selfTime, node) { 461 constructor(depth, duration, startTime, selfTime, node) {
461 this.depth = depth; 462 this.depth = depth;
462 this.duration = duration; 463 this.duration = duration;
463 this.startTime = startTime; 464 this.startTime = startTime;
464 this.selfTime = selfTime; 465 this.selfTime = selfTime;
465 this.node = node; 466 this.node = node;
466 } 467 }
467 }; 468 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698