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

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

Issue 115299: Add initial version of DevTools Profiler (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 | « webkit/glue/devtools/debugger_agent_impl.cc ('k') | webkit/glue/devtools/js/devtools.html » ('j') | 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 Provides communication interface to remote v8 debugger. See 6 * @fileoverview Provides communication interface to remote v8 debugger. See
7 * protocol decription at http://code.google.com/p/v8/wiki/DebuggerProtocol 7 * protocol decription at http://code.google.com/p/v8/wiki/DebuggerProtocol
8 */ 8 */
9 goog.provide('devtools.DebuggerAgent'); 9 goog.provide('devtools.DebuggerAgent');
10 10
11 11
12 /** 12 /**
13 * @constructor 13 * @constructor
14 */ 14 */
15 devtools.DebuggerAgent = function() { 15 devtools.DebuggerAgent = function() {
16 RemoteDebuggerAgent.DebuggerOutput = 16 RemoteDebuggerAgent.DebuggerOutput =
17 goog.bind(this.handleDebuggerOutput_, this); 17 goog.bind(this.handleDebuggerOutput_, this);
18 RemoteDebuggerAgent.DidGetContextId = 18 RemoteDebuggerAgent.DidGetContextId =
19 goog.bind(this.didGetContextId_, this); 19 goog.bind(this.didGetContextId_, this);
20 RemoteDebuggerAgent.DidGetLogLines =
21 goog.bind(this.didGetLogLines_, this);
20 22
21 /** 23 /**
22 * Id of the inspected page global context. It is used for filtering scripts. 24 * Id of the inspected page global context. It is used for filtering scripts.
23 * @type {number} 25 * @type {number}
24 */ 26 */
25 this.contextId_ = null; 27 this.contextId_ = null;
26 28
27 /** 29 /**
28 * Mapping from script id to script info. 30 * Mapping from script id to script info.
29 * @type {Object} 31 * @type {Object}
(...skipping 26 matching lines...) Expand all
56 * Mapping: request sequence number->callback. 58 * Mapping: request sequence number->callback.
57 * @type {Object} 59 * @type {Object}
58 */ 60 */
59 this.requestSeqToCallback_ = null; 61 this.requestSeqToCallback_ = null;
60 62
61 /** 63 /**
62 * Whether the scripts list has been requested. 64 * Whether the scripts list has been requested.
63 * @type {boolean} 65 * @type {boolean}
64 */ 66 */
65 this.scriptsCacheInitialized_ = false; 67 this.scriptsCacheInitialized_ = false;
68
69 /**
70 * Whether user has stopped profiling and we are retrieving the rest of
71 * profiler's log.
72 * @type {boolean}
73 */
74 this.isProcessingProfile_ = false;
75
76 /**
77 * The position in log file to read from.
78 * @type {number}
79 */
80 this.lastProfileLogPosition_ = 0;
81
82 /**
83 * Profiler processor instance.
84 * @type {devtools.profiler.Processor}
85 */
86 this.profilerProcessor_ = new devtools.profiler.Processor();
66 }; 87 };
67 88
68 89
69 /** 90 /**
70 * Resets debugger agent to its initial state. 91 * Resets debugger agent to its initial state.
71 */ 92 */
72 devtools.DebuggerAgent.prototype.reset = function() { 93 devtools.DebuggerAgent.prototype.reset = function() {
73 this.scriptsCacheInitialized_ = false; 94 this.scriptsCacheInitialized_ = false;
74 this.contextId_ = null; 95 this.contextId_ = null;
75 this.parsedScripts_ = {}; 96 this.parsedScripts_ = {};
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 var name = names[i]; 301 var name = names[i];
281 var jsonObj = handleToObject[object[name].ref] 302 var jsonObj = handleToObject[object[name].ref]
282 object[name] = devtools.DebuggerAgent.formatValue_(jsonObj, msg); 303 object[name] = devtools.DebuggerAgent.formatValue_(jsonObj, msg);
283 } 304 }
284 callback(object); 305 callback(object);
285 }); 306 });
286 }; 307 };
287 308
288 309
289 /** 310 /**
311 * Starts (resumes) profiling.
312 */
313 devtools.DebuggerAgent.prototype.startProfiling = function() {
314 if (this.isProcessingProfile_) {
315 return;
316 }
317 RemoteDebuggerAgent.StartProfiling();
318 RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_);
319 WebInspector.setRecordingProfile(true);
320 };
321
322
323 /**
324 * Stops (pauses) profiling.
325 */
326 devtools.DebuggerAgent.prototype.stopProfiling = function() {
327 this.isProcessingProfile_ = true;
328 RemoteDebuggerAgent.StopProfiling();
329 };
330
331
332 /**
290 * Removes specified breakpoint from the v8 debugger. 333 * Removes specified breakpoint from the v8 debugger.
291 * @param {number} breakpointId Id of the breakpoint in the v8 debugger. 334 * @param {number} breakpointId Id of the breakpoint in the v8 debugger.
292 */ 335 */
293 devtools.DebuggerAgent.prototype.requestClearBreakpoint_ = function( 336 devtools.DebuggerAgent.prototype.requestClearBreakpoint_ = function(
294 breakpointId) { 337 breakpointId) {
295 var cmd = new devtools.DebugCommand('clearbreakpoint', { 338 var cmd = new devtools.DebugCommand('clearbreakpoint', {
296 'breakpoint': breakpointId 339 'breakpoint': breakpointId
297 }); 340 });
298 devtools.DebuggerAgent.sendCommand_(cmd); 341 devtools.DebuggerAgent.sendCommand_(cmd);
299 }; 342 };
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 var script = msg.getBody().script; 558 var script = msg.getBody().script;
516 // Ignore scripts from other tabs. 559 // Ignore scripts from other tabs.
517 if (!this.isScriptFromInspectedContext_(script, msg)) { 560 if (!this.isScriptFromInspectedContext_(script, msg)) {
518 return; 561 return;
519 } 562 }
520 this.addScriptInfo_(script); 563 this.addScriptInfo_(script);
521 }; 564 };
522 565
523 566
524 /** 567 /**
568 * Handles a portion of a profiler log retrieved by GetLogLines call.
569 * @param {string} log A portion of profiler log.
570 * @param {number} newPosition The position in log file to read from
571 * next time.
572 */
573 devtools.DebuggerAgent.prototype.didGetLogLines_ = function(
574 log, newPosition) {
575 if (log.length > 0) {
576 this.profilerProcessor_.processLogChunk(log);
577 this.lastProfileLogPosition_ = newPosition;
578 } else if (this.isProcessingProfile_) {
579 this.isProcessingProfile_ = false;
580 WebInspector.setRecordingProfile(false);
581 WebInspector.addProfile(this.profilerProcessor_.createProfileForView());
582 return;
583 }
584 setTimeout(function() { RemoteDebuggerAgent.GetLogLines(newPosition); },
585 this.isProcessingProfile_ ? 100 : 1000);
586 };
587
588
589 /**
525 * Adds the script info to the local cache. This method assumes that the script 590 * Adds the script info to the local cache. This method assumes that the script
526 * is not in the cache yet. 591 * is not in the cache yet.
527 * @param {Object} script Script json object from the debugger message. 592 * @param {Object} script Script json object from the debugger message.
528 */ 593 */
529 devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script) { 594 devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script) {
530 this.parsedScripts_[script.id] = new devtools.ScriptInfo( 595 this.parsedScripts_[script.id] = new devtools.ScriptInfo(
531 script.id, script.lineOffset); 596 script.id, script.lineOffset);
532 WebInspector.parsedScriptSource( 597 WebInspector.parsedScriptSource(
533 script.id, script.name, script.source, script.lineOffset); 598 script.id, script.name, script.source, script.lineOffset);
534 }; 599 };
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 1198
1134 1199
1135 /** 1200 /**
1136 * @param {number} handle Object handle. 1201 * @param {number} handle Object handle.
1137 * @return {?Object} Returns the object with the handle if it was sent in this 1202 * @return {?Object} Returns the object with the handle if it was sent in this
1138 * message(some objects referenced by handles may be missing in the message). 1203 * message(some objects referenced by handles may be missing in the message).
1139 */ 1204 */
1140 devtools.DebuggerMessage.prototype.lookup = function(handle) { 1205 devtools.DebuggerMessage.prototype.lookup = function(handle) {
1141 return this.refs_[handle]; 1206 return this.refs_[handle];
1142 }; 1207 };
OLDNEW
« no previous file with comments | « webkit/glue/devtools/debugger_agent_impl.cc ('k') | webkit/glue/devtools/js/devtools.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698