| OLD | NEW |
| 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 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 */ | 62 */ |
| 63 this.requestSeqToCallback_ = null; | 63 this.requestSeqToCallback_ = null; |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * Whether the scripts list has been requested. | 66 * Whether the scripts list has been requested. |
| 67 * @type {boolean} | 67 * @type {boolean} |
| 68 */ | 68 */ |
| 69 this.scriptsCacheInitialized_ = false; | 69 this.scriptsCacheInitialized_ = false; |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * Whether user has stopped profiling and we are retrieving the rest of | 72 * Whether profiling session is started. |
| 73 * profiler's log. | |
| 74 * @type {boolean} | 73 * @type {boolean} |
| 75 */ | 74 */ |
| 76 this.isProcessingProfile_ = false; | 75 this.isProfilingStarted_ = false; |
| 77 | 76 |
| 78 /** | 77 /** |
| 79 * The position in log file to read from. | 78 * The position in log file to read from. |
| 80 * @type {number} | 79 * @type {number} |
| 81 */ | 80 */ |
| 82 this.lastProfileLogPosition_ = 0; | 81 this.lastProfileLogPosition_ = 0; |
| 83 | 82 |
| 84 /** | 83 /** |
| 85 * Profiler processor instance. | 84 * Profiler processor instance. |
| 86 * @type {devtools.profiler.Processor} | 85 * @type {devtools.profiler.Processor} |
| 87 */ | 86 */ |
| 88 this.profilerProcessor_ = new devtools.profiler.Processor(); | 87 this.profilerProcessor_ = new devtools.profiler.Processor( |
| 88 goog.bind(WebInspector.addProfile, WebInspector)); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * Resets debugger agent to its initial state. | 93 * Resets debugger agent to its initial state. |
| 94 */ | 94 */ |
| 95 devtools.DebuggerAgent.prototype.reset = function() { | 95 devtools.DebuggerAgent.prototype.reset = function() { |
| 96 this.scriptsCacheInitialized_ = false; | 96 this.scriptsCacheInitialized_ = false; |
| 97 this.contextId_ = null; | 97 this.contextId_ = null; |
| 98 this.parsedScripts_ = {}; | 98 this.parsedScripts_ = {}; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 341 } |
| 342 callback(object); | 342 callback(object); |
| 343 } | 343 } |
| 344 }; | 344 }; |
| 345 | 345 |
| 346 | 346 |
| 347 /** | 347 /** |
| 348 * Starts (resumes) profiling. | 348 * Starts (resumes) profiling. |
| 349 */ | 349 */ |
| 350 devtools.DebuggerAgent.prototype.startProfiling = function() { | 350 devtools.DebuggerAgent.prototype.startProfiling = function() { |
| 351 if (this.isProcessingProfile_) { | |
| 352 return; | |
| 353 } | |
| 354 RemoteDebuggerAgent.StartProfiling(); | 351 RemoteDebuggerAgent.StartProfiling(); |
| 355 // Query if profiling has been really started. | |
| 356 RemoteDebuggerAgent.IsProfilingStarted(); | 352 RemoteDebuggerAgent.IsProfilingStarted(); |
| 357 }; | 353 }; |
| 358 | 354 |
| 359 | 355 |
| 360 /** | 356 /** |
| 361 * Stops (pauses) profiling. | 357 * Stops (pauses) profiling. |
| 362 */ | 358 */ |
| 363 devtools.DebuggerAgent.prototype.stopProfiling = function() { | 359 devtools.DebuggerAgent.prototype.stopProfiling = function() { |
| 364 this.isProcessingProfile_ = true; | |
| 365 RemoteDebuggerAgent.StopProfiling(); | 360 RemoteDebuggerAgent.StopProfiling(); |
| 366 }; | 361 }; |
| 367 | 362 |
| 368 | 363 |
| 369 /** | 364 /** |
| 370 * Removes specified breakpoint from the v8 debugger. | 365 * Removes specified breakpoint from the v8 debugger. |
| 371 * @param {number} breakpointId Id of the breakpoint in the v8 debugger. | 366 * @param {number} breakpointId Id of the breakpoint in the v8 debugger. |
| 372 */ | 367 */ |
| 373 devtools.DebuggerAgent.prototype.requestClearBreakpoint_ = function( | 368 devtools.DebuggerAgent.prototype.requestClearBreakpoint_ = function( |
| 374 breakpointId) { | 369 breakpointId) { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 } | 601 } |
| 607 this.addScriptInfo_(script); | 602 this.addScriptInfo_(script); |
| 608 }; | 603 }; |
| 609 | 604 |
| 610 | 605 |
| 611 /** | 606 /** |
| 612 * Handles current profiler status. | 607 * Handles current profiler status. |
| 613 */ | 608 */ |
| 614 devtools.DebuggerAgent.prototype.didIsProfilingStarted_ = function( | 609 devtools.DebuggerAgent.prototype.didIsProfilingStarted_ = function( |
| 615 is_started) { | 610 is_started) { |
| 616 if (is_started) { | 611 if (is_started && !this.isProfilingStarted_) { |
| 617 // Start to query log data. | 612 // Start to query log data. |
| 618 RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_); | 613 RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_); |
| 619 } | 614 } |
| 615 this.isProfilingStarted_ = is_started; |
| 616 // Update button. |
| 620 WebInspector.setRecordingProfile(is_started); | 617 WebInspector.setRecordingProfile(is_started); |
| 618 if (is_started) { |
| 619 // Monitor profiler state. It can stop itself on buffer fill-up. |
| 620 setTimeout(function() { RemoteDebuggerAgent.IsProfilingStarted(); }, 1000); |
| 621 } |
| 621 }; | 622 }; |
| 622 | 623 |
| 623 | 624 |
| 624 /** | 625 /** |
| 625 * Handles a portion of a profiler log retrieved by GetLogLines call. | 626 * Handles a portion of a profiler log retrieved by GetLogLines call. |
| 626 * @param {string} log A portion of profiler log. | 627 * @param {string} log A portion of profiler log. |
| 627 * @param {number} newPosition The position in log file to read from | 628 * @param {number} newPosition The position in log file to read from |
| 628 * next time. | 629 * next time. |
| 629 */ | 630 */ |
| 630 devtools.DebuggerAgent.prototype.didGetLogLines_ = function( | 631 devtools.DebuggerAgent.prototype.didGetLogLines_ = function( |
| 631 log, newPosition) { | 632 log, newPosition) { |
| 632 if (log.length > 0) { | 633 if (log.length > 0) { |
| 633 this.profilerProcessor_.processLogChunk(log); | 634 this.profilerProcessor_.processLogChunk(log); |
| 634 this.lastProfileLogPosition_ = newPosition; | 635 this.lastProfileLogPosition_ = newPosition; |
| 635 } else if (this.isProcessingProfile_) { | 636 } else if (!this.isProfilingStarted_) { |
| 636 this.isProcessingProfile_ = false; | 637 // No new data and profiling is stopped---suspend log reading. |
| 637 WebInspector.setRecordingProfile(false); | |
| 638 WebInspector.addProfile(this.profilerProcessor_.createProfileForView()); | |
| 639 return; | 638 return; |
| 640 } | 639 } |
| 641 setTimeout(function() { RemoteDebuggerAgent.GetLogLines(newPosition); }, | 640 setTimeout(function() { RemoteDebuggerAgent.GetLogLines(newPosition); }, 500); |
| 642 this.isProcessingProfile_ ? 100 : 1000); | |
| 643 }; | 641 }; |
| 644 | 642 |
| 645 | 643 |
| 646 /** | 644 /** |
| 647 * Adds the script info to the local cache. This method assumes that the script | 645 * Adds the script info to the local cache. This method assumes that the script |
| 648 * is not in the cache yet. | 646 * is not in the cache yet. |
| 649 * @param {Object} script Script json object from the debugger message. | 647 * @param {Object} script Script json object from the debugger message. |
| 650 */ | 648 */ |
| 651 devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script) { | 649 devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script) { |
| 652 this.parsedScripts_[script.id] = new devtools.ScriptInfo( | 650 this.parsedScripts_[script.id] = new devtools.ScriptInfo( |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 | 1153 |
| 1156 | 1154 |
| 1157 /** | 1155 /** |
| 1158 * @param {number} handle Object handle. | 1156 * @param {number} handle Object handle. |
| 1159 * @return {?Object} Returns the object with the handle if it was sent in this | 1157 * @return {?Object} Returns the object with the handle if it was sent in this |
| 1160 * message(some objects referenced by handles may be missing in the message). | 1158 * message(some objects referenced by handles may be missing in the message). |
| 1161 */ | 1159 */ |
| 1162 devtools.DebuggerMessage.prototype.lookup = function(handle) { | 1160 devtools.DebuggerMessage.prototype.lookup = function(handle) { |
| 1163 return this.refs_[handle]; | 1161 return this.refs_[handle]; |
| 1164 }; | 1162 }; |
| OLD | NEW |