author | Eugene Ostroukhov <eugeneo@symbian.org> |
Wed, 28 Jul 2010 09:27:51 -0700 | |
changeset 455 | 5da55957c779 |
parent 355 | 8726e95bcbba |
permissions | -rw-r--r-- |
2 | 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.internal; |
|
6 |
||
276
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
7 |
import java.io.IOException; |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
8 |
|
2 | 9 |
import org.chromium.sdk.Breakpoint; |
10 |
import org.chromium.sdk.CallbackSemaphore; |
|
11 |
import org.chromium.sdk.JavascriptVm; |
|
355
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
276
diff
changeset
|
12 |
import org.chromium.sdk.SyncCallback; |
2 | 13 |
import org.chromium.sdk.internal.tools.v8.MethodIsBlockingException; |
14 |
||
15 |
/** |
|
16 |
* Base implementation of JavascriptVm. |
|
17 |
*/ |
|
18 |
public abstract class JavascriptVmImpl implements JavascriptVm { |
|
19 |
||
20 |
protected JavascriptVmImpl() { |
|
21 |
} |
|
22 |
||
23 |
public void suspend(SuspendCallback callback) { |
|
24 |
getDebugSession().suspend(callback); |
|
25 |
} |
|
26 |
||
27 |
public void getScripts(ScriptsCallback callback) throws MethodIsBlockingException { |
|
28 |
CallbackSemaphore callbackSemaphore = new CallbackSemaphore(); |
|
29 |
getDebugSession().getScriptLoader().loadAllScripts(callback, callbackSemaphore); |
|
30 |
||
31 |
boolean res = callbackSemaphore.tryAcquireDefault(); |
|
32 |
if (!res) { |
|
33 |
callback.failure("Timeout"); |
|
34 |
} |
|
35 |
} |
|
36 |
||
37 |
public void setBreakpoint(Breakpoint.Type type, String target, int line, |
|
38 |
int position, boolean enabled, String condition, int ignoreCount, |
|
355
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
276
diff
changeset
|
39 |
BreakpointCallback callback, SyncCallback syncCallback) { |
2 | 40 |
getDebugSession().getBreakpointManager() |
355
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
276
diff
changeset
|
41 |
.setBreakpoint(type, target, line, position, enabled, condition, ignoreCount, callback, |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
276
diff
changeset
|
42 |
syncCallback); |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
276
diff
changeset
|
43 |
} |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
276
diff
changeset
|
44 |
|
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
276
diff
changeset
|
45 |
public void listBreakpoints(final ListBreakpointsCallback callback, SyncCallback syncCallback) { |
8726e95bcbba
Initial commit of updated Chrome Java SDK
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
276
diff
changeset
|
46 |
getDebugSession().getBreakpointManager().reloadBreakpoints(callback, syncCallback); |
2 | 47 |
} |
48 |
||
49 |
protected abstract DebugSession getDebugSession(); |
|
276
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
50 |
|
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
51 |
// TODO(peter.rybin): This message will be obsolete in JavaSE-1.6. |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
52 |
public static IOException newIOException(String message, Throwable cause) { |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
53 |
IOException result = new IOException(message); |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
54 |
result.initCause(cause); |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
55 |
return result; |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
56 |
} |
2 | 57 |
} |