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.debug.core.model;
|
|
6 |
|
|
7 |
import org.chromium.sdk.DebugEventListener;
|
|
8 |
import org.chromium.sdk.JavascriptVm;
|
|
9 |
import org.eclipse.core.runtime.CoreException;
|
|
10 |
|
|
11 |
/**
|
|
12 |
* Abstraction of application embedding JavaScript VM. Technically subtypes
|
|
13 |
* of {@code JavascriptVm} describe embedding application themselves.
|
|
14 |
* This interface simply holds reference to {@code JavascriptVm} and adapts
|
|
15 |
* various subtypes of {@code JavascriptVm} to a uniform interface
|
|
16 |
* suitable for {@code DebugTargetImpl}. Notably, it has polymorphous method
|
|
17 |
* {@code #attach(Listener, DebugEventListener)}, which {@code JavascriptVm}
|
|
18 |
* lacks.
|
|
19 |
*/
|
|
20 |
public interface JavascriptVmEmbedder {
|
|
21 |
|
|
22 |
/**
|
|
23 |
* First intermediate object that corresponds to already connected server.
|
|
24 |
* This does not refer to a particular Javascript VM though:
|
|
25 |
* the server may contain several VMs to choose from.
|
|
26 |
*/
|
|
27 |
interface ConnectionToRemote {
|
|
28 |
/**
|
|
29 |
* This method performs selecting a particular Javascript VM. This is
|
|
30 |
* likely to be a user-assisted activity, so this method may block
|
|
31 |
* indefinitely.
|
|
32 |
* @return null if no VM has been chosen and we should cancel the operation
|
|
33 |
*/
|
|
34 |
VmConnector selectVm() throws CoreException;
|
|
35 |
|
|
36 |
void disposeConnection();
|
|
37 |
}
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Intermediate object that works as an intermediate factory
|
|
41 |
* for {@code JavascriptVmEmbedder}.
|
|
42 |
*/
|
|
43 |
interface VmConnector {
|
|
44 |
JavascriptVmEmbedder attach(Listener embedderListener, DebugEventListener debugEventListener)
|
|
45 |
throws CoreException;
|
|
46 |
}
|
|
47 |
|
|
48 |
/**
|
|
49 |
* @return not null
|
|
50 |
*/
|
|
51 |
JavascriptVm getJavascriptVm();
|
|
52 |
|
|
53 |
String getTargetName();
|
|
54 |
|
|
55 |
String getThreadName();
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Listener that should handle embedder-specific events.
|
|
59 |
* TODO(peter.rybin): clean-up this interface; maybe decrease number of
|
|
60 |
* methods.
|
|
61 |
*/
|
|
62 |
interface Listener {
|
|
63 |
/**
|
|
64 |
* State of VM has been reset. All scripts might have been changed, name of
|
|
65 |
* target and thread might have been changed. E.g. browser tab might have
|
|
66 |
* been navigated from one url to another.
|
|
67 |
*/
|
|
68 |
void reset();
|
|
69 |
|
|
70 |
void closed();
|
|
71 |
}
|
|
72 |
}
|