equal
deleted
inserted
replaced
8 import java.util.Collection; |
8 import java.util.Collection; |
9 import java.util.Collections; |
9 import java.util.Collections; |
10 import java.util.List; |
10 import java.util.List; |
11 |
11 |
12 import org.chromium.sdk.Breakpoint; |
12 import org.chromium.sdk.Breakpoint; |
|
13 import org.chromium.sdk.DebugContext; |
13 import org.chromium.sdk.DebugEventListener; |
14 import org.chromium.sdk.DebugEventListener; |
14 import org.chromium.sdk.InvalidContextException; |
15 import org.chromium.sdk.InvalidContextException; |
15 import org.chromium.sdk.Script; |
16 import org.chromium.sdk.Script; |
16 import org.chromium.sdk.SyncCallback; |
17 import org.chromium.sdk.SyncCallback; |
17 import org.chromium.sdk.Version; |
18 import org.chromium.sdk.Version; |
30 import org.chromium.sdk.internal.tools.v8.V8ProtocolUtil; |
31 import org.chromium.sdk.internal.tools.v8.V8ProtocolUtil; |
31 import org.chromium.sdk.internal.tools.v8.request.ContextlessDebuggerMessage; |
32 import org.chromium.sdk.internal.tools.v8.request.ContextlessDebuggerMessage; |
32 import org.chromium.sdk.internal.tools.v8.request.DebuggerMessageFactory; |
33 import org.chromium.sdk.internal.tools.v8.request.DebuggerMessageFactory; |
33 |
34 |
34 /** |
35 /** |
35 * A default, thread-safe implementation of the JsDebugContext interface. |
36 * A class that holds and administers main parts of debug protocol implementation. |
36 */ |
37 */ |
37 public class DebugSession { |
38 public class DebugSession { |
38 |
39 |
39 /** The script manager for the associated tab. */ |
40 /** The script manager for the associated tab. */ |
40 private final ScriptManager scriptManager; |
41 private final ScriptManager scriptManager; |
56 |
57 |
57 private final DefaultResponseHandler defaultResponseHandler; |
58 private final DefaultResponseHandler defaultResponseHandler; |
58 |
59 |
59 public DebugSession(DebugSessionManager sessionManager, V8ContextFilter contextFilter, |
60 public DebugSession(DebugSessionManager sessionManager, V8ContextFilter contextFilter, |
60 V8CommandOutput v8CommandOutput) { |
61 V8CommandOutput v8CommandOutput) { |
61 this.scriptManager = new ScriptManager(contextFilter); |
62 this.scriptManager = new ScriptManager(contextFilter, this); |
62 this.sessionManager = sessionManager; |
63 this.sessionManager = sessionManager; |
63 this.breakpointManager = new BreakpointManager(this); |
64 this.breakpointManager = new BreakpointManager(this); |
64 |
65 |
65 this.defaultResponseHandler = new DefaultResponseHandler(this); |
66 this.defaultResponseHandler = new DefaultResponseHandler(this); |
66 this.v8CommandProcessor = new V8CommandProcessor(v8CommandOutput, defaultResponseHandler); |
67 this.v8CommandProcessor = new V8CommandProcessor(v8CommandOutput, defaultResponseHandler); |
121 return v8Helper; |
122 return v8Helper; |
122 } |
123 } |
123 |
124 |
124 public ContextBuilder getContextBuilder() { |
125 public ContextBuilder getContextBuilder() { |
125 return contextBuilder; |
126 return contextBuilder; |
|
127 } |
|
128 |
|
129 /** |
|
130 * Drops current context and creates a new one. This is useful if context is known to have changed |
|
131 * (e.g. experimental feature LiveEdit may change current stack while execution is suspended). |
|
132 * The method is asynchronous and returns immediately. |
|
133 * Does nothing if currently there is no active context. Otherwise dismisses current context, |
|
134 * invokes {@link DebugEventListener#resumed()} and initiates downloading stack frame descriptions |
|
135 * and building new context. When the context is built, |
|
136 * calls {@link DebugEventListener#suspended(DebugContext)}. |
|
137 * <p> |
|
138 * Must be called from Dispatch Thread. |
|
139 * @return true if context has been actually dropped. |
|
140 */ |
|
141 public boolean recreateCurrentContext() { |
|
142 ContextBuilder.ExpectingBacktraceStep step = contextBuilder.startRebuildCurrentContext(); |
|
143 if (step == null) { |
|
144 return false; |
|
145 } |
|
146 defaultResponseHandler.getBreakpointProcessor().processNextStep(step); |
|
147 return true; |
126 } |
148 } |
127 |
149 |
128 public void suspend(final SuspendCallback suspendCallback) { |
150 public void suspend(final SuspendCallback suspendCallback) { |
129 V8CommandProcessor.V8HandlerCallback v8Callback = new V8CommandCallbackBase() { |
151 V8CommandProcessor.V8HandlerCallback v8Callback = new V8CommandCallbackBase() { |
130 @Override |
152 @Override |