OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 #ifndef CHROME_TEST_LAYOUT_TEST_HTTP_SERVER_H_ | |
6 #define CHROME_TEST_LAYOUT_TEST_HTTP_SERVER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/compiler_specific.h" | |
10 #include "base/file_path.h" | |
11 | |
12 // This object bounds the lifetime of an external HTTP server | |
13 // used for layout tests. | |
14 // | |
15 // NOTE: If you're not running a layout test, you probably want | |
16 // a more lightweight net/test/test_server HTTP server. | |
17 class LayoutTestHttpServer { | |
18 public: | |
19 LayoutTestHttpServer(const FilePath& root_directory, int port); | |
20 ~LayoutTestHttpServer(); | |
21 | |
22 // Starts the server. Returns true on success. | |
23 bool Start() WARN_UNUSED_RESULT; | |
24 | |
25 // Stops the server. Returns true on success. | |
26 // | |
27 // NOTE: It is recommended to explicitly call Stop and check its return value. | |
28 // If Stop fails, the server is most likely still running and future attempts | |
29 // to bind to the same port will fail, possibly resulting in further test | |
30 // failures. | |
31 bool Stop() WARN_UNUSED_RESULT; | |
32 | |
33 private: | |
34 FilePath root_directory_; // Root directory of the server. | |
35 | |
36 int port_; // Port on which the server should listen. | |
37 | |
38 bool running_; // True if the server is currently running. | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(LayoutTestHttpServer); | |
41 }; | |
42 | |
43 #endif // CHROME_TEST_LAYOUT_TEST_HTTP_SERVER_H_ | |
OLD | NEW |