|
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 |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.sdk; |
|
6 |
|
7 import java.util.Collection; |
|
8 |
|
9 import org.chromium.sdk.internal.tools.v8.MethodIsBlockingException; |
|
10 |
|
11 /** |
|
12 * Abstraction of a remote Javascript virtual machine. Clients can use it to |
|
13 * conduct debugging process. This interface does not specify attach method, |
|
14 * because it cannot be polymorphous. |
|
15 */ |
|
16 public interface JavascriptVm { |
|
17 |
|
18 /** |
|
19 * A callback for breakpoint-related requests. |
|
20 */ |
|
21 public interface BreakpointCallback { |
|
22 |
|
23 void success(Breakpoint breakpoint); |
|
24 |
|
25 void failure(String errorMessage); |
|
26 } |
|
27 |
|
28 /** |
|
29 * A callback for retrieving scripts. |
|
30 */ |
|
31 public interface ScriptsCallback { |
|
32 |
|
33 void success(Collection<Script> scripts); |
|
34 |
|
35 void failure(String errorMessage); |
|
36 } |
|
37 |
|
38 /** |
|
39 * A callback for suspend request. |
|
40 */ |
|
41 public interface SuspendCallback { |
|
42 |
|
43 /** |
|
44 * Signals that command successfully finished. After this DebugContext should be built |
|
45 * and unless there are some problems, |
|
46 * {@link DebugEventListener#suspended(DebugContext)} will be called soon. |
|
47 */ |
|
48 void success(); |
|
49 |
|
50 void failure(Exception reason); |
|
51 } |
|
52 |
|
53 /** |
|
54 * Detaches from the related tab debugger. |
|
55 * |
|
56 * @return whether the operation succeeded |
|
57 */ |
|
58 boolean detach(); |
|
59 |
|
60 /** |
|
61 * @return whether the tab is currently attached |
|
62 */ |
|
63 boolean isAttached(); |
|
64 |
|
65 /** |
|
66 * Retrieves user scripts loaded into the tab. |
|
67 * Blocks until the result is ready. |
|
68 * |
|
69 * @param callback to invoke once the operation result is available, |
|
70 * may be {@code null} |
|
71 * @throws MethodIsBlockingException if called from a callback because it |
|
72 * blocks until scripts are received |
|
73 */ |
|
74 void getScripts(ScriptsCallback callback) throws MethodIsBlockingException; |
|
75 |
|
76 /** |
|
77 * Sets a breakpoint with the specified parameters. |
|
78 * |
|
79 * @param type of the breakpoint |
|
80 * @param target of the breakpoint, depends on the {@code type} value: |
|
81 * <table border=1> |
|
82 * <tr><td>type value</td><td>target value</td></tr> |
|
83 * <tr><td>FUNCTION</td><td>a function expression</td></tr> |
|
84 * <tr><td>SCRIPT_NAME</td><td>a script name (as reported by Script#getName())</td></tr> |
|
85 * <tr><td>SCRIPT_ID</td><td>a stringified script ID (as reported by Script#getId())</td></tr> |
|
86 * </table> |
|
87 * @param line in the script or function. If none, use |
|
88 * {@link Breakpoint#EMPTY_VALUE} |
|
89 * @param position of the target start within the line. If none, use |
|
90 * {@link Breakpoint#EMPTY_VALUE} |
|
91 * @param enabled whether the breakpoint is enabled initially |
|
92 * @param condition nullable string with breakpoint condition |
|
93 * @param ignoreCount number specifying the amount of breakpoint hits to |
|
94 * ignore. If none, use {@link Breakpoint#EMPTY_VALUE} |
|
95 * @param callback to invoke when the evaluation result is ready, |
|
96 * may be {@code null} |
|
97 */ |
|
98 void setBreakpoint(Breakpoint.Type type, String target, int line, int position, boolean enabled, |
|
99 String condition, int ignoreCount, BreakpointCallback callback); |
|
100 |
|
101 /** |
|
102 * Tries to suspend VM. If successful, {@link DebugEventListener#suspended(DebugContext)} |
|
103 * will be called. |
|
104 * @param callback to invoke once the operation result is available, |
|
105 * may be {@code null} |
|
106 */ |
|
107 void suspend(SuspendCallback callback); |
|
108 } |