• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Chromium Authors
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.net.test;
6 
7 import org.chromium.net.test.IConnectionListener;
8 
9 interface IEmbeddedTestServerImpl {
10 
11     /** Initialize the native object. */
initializeNative(boolean https)12     boolean initializeNative(boolean https);
13 
14     /** Start the server.
15      *
16      *  @param port The port to use for the server, 0 to auto-select an unused port.
17      *  @return Whether the server was successfully started.
18      */
start(int port)19     boolean start(int port);
20 
21     /** Get the path of the server's root certificate.
22      *
23      *  @return The pathname of a PEM file containing the server's root certificate.
24      */
getRootCertPemPath()25     String getRootCertPemPath();
26 
27     /** Add the default handlers and serve files from the provided directory relative to the
28      *  external storage directory.
29      *
30      *  @param directoryPath The path of the directory from which files should be served, relative
31      *      to the external storage directory.
32      */
addDefaultHandlers(String directoryPath)33     void addDefaultHandlers(String directoryPath);
34 
35     /** Configure the server to use a particular type of SSL certificate.
36      *
37      * @param serverCertificate The type of certificate the server should use.
38      */
setSSLConfig(int serverCertificate)39     void setSSLConfig(int serverCertificate);
40 
41     /** Serve files from the provided directory.
42      *
43      *  @param directoryPath The path of the directory from which files should be served.
44      */
serveFilesFromDirectory(String directoryPath)45     void serveFilesFromDirectory(String directoryPath);
46 
47     /** Get the full URL for the given relative URL.
48      *
49      *  @param relativeUrl The relative URL for which a full URL should be returned.
50      *  @return The URL as a String.
51      */
getURL(String relativeUrl)52     String getURL(String relativeUrl);
53 
54     /** Get the full URL for the given relative URL. Similar to the above method but uses the given
55      *  hostname instead of 127.0.0.1. The hostname should be resolved to 127.0.0.1.
56      *
57      *  @param hostName The host name which should be used.
58      *  @param relativeUrl The relative URL for which a full URL should be returned.
59      *  @return The URL as a String.
60      */
getURLWithHostName(String hostName, String relativeUrl)61     String getURLWithHostName(String hostName, String relativeUrl);
62 
63     /** Shut down the server.
64      *
65      *  @return Whether the server was successfully shut down.
66      */
shutdownAndWaitUntilComplete()67     boolean shutdownAndWaitUntilComplete();
68 
69     /** Destroy the native object. */
destroy()70     void destroy();
71 
72     /** Set a connection listener. Must be called before {@link start()}. */
setConnectionListener(IConnectionListener callback)73     void setConnectionListener(IConnectionListener callback);
74 }
75