org.chromium.sdk/src/org/chromium/sdk/internal/tools/v8/request/SetBreakpointMessage.java
changeset 2 e4420d2515f1
child 355 8726e95bcbba
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.chromium.sdk/src/org/chromium/sdk/internal/tools/v8/request/SetBreakpointMessage.java	Wed Dec 23 17:13:18 2009 -0800
@@ -0,0 +1,49 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.sdk.internal.tools.v8.request;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.chromium.sdk.Breakpoint;
+import org.chromium.sdk.internal.tools.v8.DebuggerCommand;
+
+/**
+ * Represents a "setbreakpoint" V8 request message.
+ */
+public class SetBreakpointMessage extends ContextlessDebuggerMessage {
+
+  private static final Map<Breakpoint.Type, String> typeToV8Type =
+      new HashMap<Breakpoint.Type, String>();
+
+  static {
+    typeToV8Type.put(Breakpoint.Type.FUNCTION, "function");
+    typeToV8Type.put(Breakpoint.Type.SCRIPT_NAME, "script");
+    typeToV8Type.put(Breakpoint.Type.SCRIPT_ID, "scriptId");
+  }
+
+  /**
+   * @param type ("function", "handle", or "script")
+   * @param target function expression, script identification, or handle decimal number
+   * @param line in the script or function
+   * @param position of the target start within the line
+   * @param enabled whether the breakpoint is enabled initially. Nullable, default is true
+   * @param condition nullable string with breakpoint condition
+   * @param ignoreCount nullable number specifying the amount of break point hits to ignore.
+   *        Default is 0
+   */
+  public SetBreakpointMessage(Breakpoint.Type type, String target,
+      Integer line, Integer position, Boolean enabled, String condition,
+      Integer ignoreCount) {
+    super(DebuggerCommand.SETBREAKPOINT.value);
+    putArgument("type", typeToV8Type.get(type));
+    putArgument("target", target);
+    putArgument("line", line);
+    putArgument("position", position);
+    putArgument("enabled", enabled);
+    putArgument("condition", condition);
+    putArgument("ignoreCount", ignoreCount);
+  }
+}