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

Unified Diff: webkit/glue/devtools/js/debugger_agent.js

Issue 131036: Preserve breakpoints on page reload (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/devtools/js/debugger_agent.js
===================================================================
--- webkit/glue/devtools/js/debugger_agent.js (revision 18697)
+++ webkit/glue/devtools/js/debugger_agent.js (working copy)
@@ -79,6 +79,14 @@
* @type {devtools.profiler.Processor}
*/
this.profilerProcessor_ = new devtools.profiler.Processor();
+
+ /**
+ * Container of all breakpoints set using resource URL. These breakpoints
+ * survive page reload. Breakpoints set by script id(for scripts that don't
+ * have URLs) are stored in ScriptInfo objects.
+ * @type {Object}
+ */
+ this.urlToBreakpoints_ = {};
};
@@ -183,20 +191,43 @@
line = devtools.DebuggerAgent.webkitToV8LineNumber_(line);
- var breakpointInfo = script.getBreakpointInfo(line);
- if (breakpointInfo) {
- return;
+ var commandArguments;
+ if (script.getUrl()) {
+ var breakpoints = this.urlToBreakpoints_[script.getUrl()];
+ if (breakpoints && breakpoints[line]) {
+ return;
+ }
+ if (!breakpoints) {
+ breakpoints = {};
+ this.urlToBreakpoints_[script.getUrl()] = breakpoints;
+ }
+
+ var breakpointInfo = new devtools.BreakpointInfo(line);
+ breakpoints[line] = breakpointInfo;
+
+ commandArguments = {
+ 'type': 'script',
+ 'target': script.getUrl(),
+ 'line': line
+ };
+ } else {
+ var breakpointInfo = script.getBreakpointInfo(line);
+ if (breakpointInfo) {
+ return;
+ }
+
+ breakpointInfo = new devtools.BreakpointInfo(line);
+ script.addBreakpointInfo(breakpointInfo);
+
+ commandArguments = {
+ 'type': 'scriptId',
+ 'target': sourceId,
+ 'line': line
+ };
}
- breakpointInfo = new devtools.BreakpointInfo(sourceId, line);
- script.addBreakpointInfo(breakpointInfo);
+ var cmd = new devtools.DebugCommand('setbreakpoint', commandArguments);
- var cmd = new devtools.DebugCommand('setbreakpoint', {
- 'type': 'scriptId',
- 'target': sourceId,
- 'line': line
- });
-
this.requestNumberToBreakpointInfo_[cmd.getSequenceNumber()] = breakpointInfo;
devtools.DebuggerAgent.sendCommand_(cmd);
@@ -215,8 +246,16 @@
line = devtools.DebuggerAgent.webkitToV8LineNumber_(line);
- var breakpointInfo = script.getBreakpointInfo(line);
- script.removeBreakpointInfo(breakpointInfo);
+ var breakpointInfo;
+ if (script.getUrl()) {
+ var breakpoints = this.urlToBreakpoints_[script.getUrl()];
+ breakpointInfo = breakpoints[line];
+ delete breakpoints[line];
+ } else {
+ breakpointInfo = script.getBreakpointInfo(line);
+ script.removeBreakpointInfo(breakpointInfo);
+ }
+
breakpointInfo.markAsRemoved();
var id = breakpointInfo.getV8Id();
@@ -684,7 +723,7 @@
var context = msg.lookup(script.context.ref);
var contextType = context.data.type;
this.parsedScripts_[script.id] = new devtools.ScriptInfo(
- script.id, script.lineOffset, contextType);
+ script.id, script.name, script.lineOffset, contextType);
WebInspector.parsedScriptSource(
script.id, script.name, script.source, script.lineOffset);
};
@@ -896,6 +935,7 @@
/**
* @param {number} scriptId Id of the script.
+ * @param {?string} url Script resource URL if any.
* @param {number} lineOffset First line 0-based offset in the containing
* document.
* @param {string} contextType Type of the script's context:
@@ -903,10 +943,11 @@
* "injected" - extension content script
* @constructor
*/
-devtools.ScriptInfo = function(scriptId, lineOffset, contextType) {
+devtools.ScriptInfo = function(scriptId, url, lineOffset, contextType) {
this.scriptId_ = scriptId;
this.lineOffset_ = lineOffset;
this.contextType_ = contextType;
+ this.url_ = url;
this.lineToBreakpointInfo_ = {};
};
@@ -929,6 +970,14 @@
/**
+ * @return {?string}
+ */
+devtools.ScriptInfo.prototype.getUrl = function() {
+ return this.url_;
+};
+
+
+/**
* @param {number} line 0-based line number in the script.
* @return {?devtools.BreakpointInfo} Information on a breakpoint at the
* specified line in the script or undefined if there is no breakpoint at
@@ -959,12 +1008,10 @@
/**
- * @param {number} scriptId Id of the owning script.
* @param {number} line Breakpoint 0-based line number in the containing script.
* @constructor
*/
-devtools.BreakpointInfo = function(sourceId, line) {
- this.sourceId_ = sourceId;
+devtools.BreakpointInfo = function(line) {
this.line_ = line;
this.v8id_ = -1;
this.removed_ = false;
@@ -974,14 +1021,6 @@
/**
* @return {number}
*/
-devtools.BreakpointInfo.prototype.getSourceId = function(n) {
- return this.sourceId_;
-};
-
-
-/**
- * @return {number}
- */
devtools.BreakpointInfo.prototype.getLine = function(n) {
return this.line_;
};
« 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