--- a/org.chromium.sdk/src/org/chromium/sdk/internal/tools/v8/BreakpointImpl.java Mon Jun 07 16:33:07 2010 -0700
+++ b/org.chromium.sdk/src/org/chromium/sdk/internal/tools/v8/BreakpointImpl.java Mon Jun 07 16:51:19 2010 -0700
@@ -5,7 +5,9 @@
package org.chromium.sdk.internal.tools.v8;
import org.chromium.sdk.Breakpoint;
-import org.chromium.sdk.BrowserTab;
+import org.chromium.sdk.JavascriptVm;
+import org.chromium.sdk.SyncCallback;
+import org.chromium.sdk.internal.protocol.data.BreakpointInfo;
/**
* A generic implementation of the Breakpoint interface.
@@ -23,6 +25,21 @@
private long id;
/**
+ * The corresponding script name as reported by the JavaScript VM. May be null.
+ */
+ private String scriptName;
+
+ /**
+ * The corresponding script id as reported by the JavaScript VM. May be null.
+ */
+ private Long scriptId;
+
+ /**
+ * Breakpoint line number. May become invalidated by LiveEdit actions.
+ */
+ private long lineNumber;
+
+ /**
* Whether the breakpoint is enabled.
*/
private boolean isEnabled;
@@ -50,16 +67,40 @@
*/
private volatile boolean isDirty = false;
- public BreakpointImpl(Type type, long id, boolean enabled, int ignoreCount, String condition,
- BreakpointManager breakpointManager) {
+ public BreakpointImpl(Type type, long id, String scriptName, Long scriptId, long lineNumber,
+ boolean enabled, int ignoreCount, String condition, BreakpointManager breakpointManager) {
this.type = type;
+ this.scriptName = scriptName;
+ this.scriptId = scriptId;
this.id = id;
this.isEnabled = enabled;
this.ignoreCount = ignoreCount;
this.condition = condition;
+ this.lineNumber = lineNumber;
this.breakpointManager = breakpointManager;
}
+ public BreakpointImpl(BreakpointInfo info, BreakpointManager breakpointManager) {
+ this.type = getType(info);
+ this.id = info.number();
+ this.breakpointManager = breakpointManager;
+ updateFromRemote(info);
+ }
+ public void updateFromRemote(BreakpointInfo info) {
+ if (this.type != getType(info)) {
+ throw new IllegalArgumentException();
+ }
+ if (this.id != info.number()) {
+ throw new IllegalArgumentException();
+ }
+ this.lineNumber = info.line();
+ this.isEnabled = info.active();
+ this.ignoreCount = (int) info.ignoreCount();
+ this.condition = info.condition();
+ this.scriptName = info.script_name();
+ this.scriptId = info.script_id();
+ }
+
public boolean isEnabled() {
return isEnabled;
}
@@ -72,6 +113,14 @@
return id;
}
+ public String getScriptName() {
+ return scriptName;
+ }
+
+ public Long getScriptId() {
+ return scriptId;
+ }
+
public int getIgnoreCount() {
return ignoreCount;
}
@@ -80,6 +129,10 @@
return condition;
}
+ public long getLineNumber() {
+ return lineNumber;
+ }
+
public void setEnabled(boolean enabled) {
if (this.isEnabled != enabled) {
setDirty(true);
@@ -106,21 +159,21 @@
return left == right || (left != null && left.equals(right));
}
- public void clear(final BrowserTab.BreakpointCallback callback) {
- breakpointManager.clearBreakpoint(this, callback);
+ public void clear(JavascriptVm.BreakpointCallback callback, SyncCallback syncCallback) {
+ breakpointManager.clearBreakpoint(this, callback, syncCallback);
// The order must be preserved, otherwise the breakpointProcessor will not be able
// to identify the original breakpoint ID.
this.id = INVALID_ID;
}
- public void flush(final BrowserTab.BreakpointCallback callback) {
+ public void flush(final JavascriptVm.BreakpointCallback callback, SyncCallback syncCallback) {
if (!isDirty()) {
if (callback != null) {
callback.success(this);
}
return;
}
- breakpointManager.changeBreakpoint(this, callback);
+ breakpointManager.changeBreakpoint(this, callback, syncCallback);
setDirty(false);
}
@@ -132,4 +185,13 @@
return isDirty;
}
-}
\ No newline at end of file
+ private static Type getType(BreakpointInfo info) {
+ BreakpointInfo.Type infoType = info.type();
+ switch (infoType) {
+ case scriptId: return Type.SCRIPT_ID;
+ case scriptName: return Type.SCRIPT_NAME;
+ case function: return Type.FUNCTION;
+ }
+ throw new RuntimeException("Unknown type: " + infoType);
+ }
+}