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;
|
|
6 |
|
|
7 |
import java.net.SocketAddress;
|
|
8 |
|
|
9 |
import org.chromium.sdk.internal.BrowserFactoryImpl;
|
|
10 |
|
|
11 |
/**
|
|
12 |
* A factory for Browser instances.
|
|
13 |
*/
|
|
14 |
public abstract class BrowserFactory {
|
|
15 |
|
|
16 |
private static BrowserFactory instance;
|
|
17 |
|
|
18 |
/**
|
|
19 |
* Gets a {@link BrowserFactory} instance. This method should be overridden by
|
|
20 |
* implementations that want to construct other implementations of
|
|
21 |
* {@link Browser}.
|
|
22 |
*
|
|
23 |
* @return a BrowserFactory singleton instance
|
|
24 |
*/
|
|
25 |
public static BrowserFactory getInstance() {
|
|
26 |
if (instance == null) {
|
|
27 |
instance = new BrowserFactoryImpl();
|
|
28 |
}
|
|
29 |
return instance;
|
|
30 |
}
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Returns a Browser implementor instance that talks to a browser listening at
|
|
34 |
* {@code socketAddress}. Note that you shouldn't try to create several instances
|
|
35 |
* of Browser connecting to the same {@code socketAddress}.
|
|
36 |
*
|
|
37 |
* @param socketAddress the browser is listening on
|
|
38 |
* @param connectionLoggerFactory provides facility for listening to network
|
|
39 |
* traffic; may be null
|
|
40 |
* @return a Browser instance for the {@code socketAddress}
|
|
41 |
*/
|
|
42 |
public abstract Browser create(SocketAddress socketAddress,
|
|
43 |
ConnectionLogger.Factory connectionLoggerFactory);
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Constructs StandaloneVm instance that talks to a V8 JavaScript VM via
|
|
47 |
* DebuggerAgent opened at {@code socketAddress}.
|
|
48 |
* @param socketAddress V8 DebuggerAgent is listening on
|
|
49 |
* @param connectionLogger provides facility for listening to network
|
|
50 |
* traffic; may be null
|
|
51 |
*/
|
|
52 |
public abstract StandaloneVm createStandalone(SocketAddress socketAddress,
|
|
53 |
ConnectionLogger connectionLogger);
|
|
54 |
}
|