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

Side by Side Diff: webkit/glue/devtools/js/profiler_processor.js

Issue 384144: DevTools: fix timer leak. (Closed)
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « no previous file | 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 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Profiler processor is used to process log file produced 6 * @fileoverview Profiler processor is used to process log file produced
7 * by V8 and produce an internal profile representation which is used 7 * by V8 and produce an internal profile representation which is used
8 * for building profile views in 'Profiles' tab. 8 * for building profile views in 'Profiles' tab.
9 */ 9 */
10 goog.provide('devtools.profiler.Processor'); 10 goog.provide('devtools.profiler.Processor');
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 */ 221 */
222 this.profileId_ = 1; 222 this.profileId_ = 1;
223 223
224 /** 224 /**
225 * Counter for processed ticks. 225 * Counter for processed ticks.
226 * @type {number} 226 * @type {number}
227 */ 227 */
228 this.ticksCount_ = 0; 228 this.ticksCount_ = 0;
229 229
230 /** 230 /**
231 * Interval id for updating processing status.
232 * @type {number}
233 */
234 this.processingInterval_ = null;
235
236 /**
231 * The current heap snapshot. 237 * The current heap snapshot.
232 * @type {string} 238 * @type {string}
233 */ 239 */
234 this.currentHeapSnapshot_ = null; 240 this.currentHeapSnapshot_ = null;
235 241
236 /** 242 /**
237 * Next heap snapshot id. 243 * Next heap snapshot id.
238 * @type {number} 244 * @type {number}
239 */ 245 */
240 this.heapSnapshotId_ = 1; 246 this.heapSnapshotId_ = 1;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 * @param {function(devtools.profiler.ProfileView)} callback Callback function. 301 * @param {function(devtools.profiler.ProfileView)} callback Callback function.
296 */ 302 */
297 devtools.profiler.Processor.prototype.setNewProfileCallback = function( 303 devtools.profiler.Processor.prototype.setNewProfileCallback = function(
298 callback) { 304 callback) {
299 this.newProfileCallback_ = callback; 305 this.newProfileCallback_ = callback;
300 }; 306 };
301 307
302 308
303 devtools.profiler.Processor.prototype.processProfiler_ = function( 309 devtools.profiler.Processor.prototype.processProfiler_ = function(
304 state, params) { 310 state, params) {
305 var processingInterval = null;
306 switch (state) { 311 switch (state) {
307 case 'resume': 312 case 'resume':
308 if (this.currentProfile_ == null) { 313 if (this.currentProfile_ == null) {
309 this.currentProfile_ = new devtools.profiler.JsProfile(); 314 this.currentProfile_ = new devtools.profiler.JsProfile();
310 // see the comment for devtools.profiler.Processor.PROGRAM_ENTRY 315 // see the comment for devtools.profiler.Processor.PROGRAM_ENTRY
311 this.currentProfile_.addCode( 316 this.currentProfile_.addCode(
312 'Function', '(program)', 317 'Function', '(program)',
313 devtools.profiler.Processor.PROGRAM_ENTRY, 1); 318 devtools.profiler.Processor.PROGRAM_ENTRY, 1);
314 if (this.startedProfileProcessing_) { 319 if (this.startedProfileProcessing_) {
315 this.startedProfileProcessing_(); 320 this.startedProfileProcessing_();
316 } 321 }
317 this.ticksCount_ = 0; 322 this.ticksCount_ = 0;
318 var self = this; 323 var self = this;
319 if (this.profileProcessingStatus_) { 324 if (this.profileProcessingStatus_) {
320 processingInterval = window.setInterval( 325 this.processingInterval_ = window.setInterval(
321 function() { self.profileProcessingStatus_(self.ticksCount_); }, 326 function() { self.profileProcessingStatus_(self.ticksCount_); },
322 1000); 327 1000);
323 } 328 }
324 } 329 }
325 break; 330 break;
326 case 'pause': 331 case 'pause':
327 if (this.currentProfile_ != null) { 332 if (this.currentProfile_ != null) {
328 window.clearInterval(processingInterval); 333 window.clearInterval(this.processingInterval_);
334 this.processingInterval_ = null;
329 if (this.finishedProfileProcessing_) { 335 if (this.finishedProfileProcessing_) {
330 this.finishedProfileProcessing_(this.createProfileForView()); 336 this.finishedProfileProcessing_(this.createProfileForView());
331 } 337 }
332 this.currentProfile_ = null; 338 this.currentProfile_ = null;
333 } 339 }
334 break; 340 break;
335 case 'begin': 341 case 'begin':
336 var samplingRate = NaN; 342 var samplingRate = NaN;
337 if (params.length > 0) { 343 if (params.length > 0) {
338 samplingRate = parseInt(params[0]); 344 samplingRate = parseInt(params[0]);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 /** 475 /**
470 * Creates a profile for further displaying in ProfileView. 476 * Creates a profile for further displaying in ProfileView.
471 */ 477 */
472 devtools.profiler.Processor.prototype.createProfileForView = function() { 478 devtools.profiler.Processor.prototype.createProfileForView = function() {
473 var profile = this.viewBuilder_.buildView( 479 var profile = this.viewBuilder_.buildView(
474 this.currentProfile_.getTopDownProfile()); 480 this.currentProfile_.getTopDownProfile());
475 profile.uid = this.profileId_++; 481 profile.uid = this.profileId_++;
476 profile.title = UserInitiatedProfileName + '.' + profile.uid; 482 profile.title = UserInitiatedProfileName + '.' + profile.uid;
477 return profile; 483 return profile;
478 }; 484 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698