OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_TEST_LAYOUT_TEST_HTTP_SERVER_H_ | 5 #ifndef CONTENT_TEST_LAYOUT_TEST_HTTP_SERVER_H_ |
6 #define CONTENT_TEST_LAYOUT_TEST_HTTP_SERVER_H_ | 6 #define CONTENT_TEST_LAYOUT_TEST_HTTP_SERVER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 | 10 |
11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
12 #include "base/win/scoped_handle.h" | 12 #include "base/win/scoped_handle.h" |
13 #endif | 13 #endif |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 // This object bounds the lifetime of an external HTTP server | 17 // This object bounds the lifetime of an external HTTP server |
18 // used for layout tests. | 18 // used for layout tests. |
19 // | 19 // |
20 // NOTE: If you're not running a layout test, you probably want | 20 // NOTE: If you're not running a layout test, you probably want |
21 // a more lightweight net/test/test_server HTTP server. | 21 // a more lightweight net/test/test_server HTTP server. |
22 class LayoutTestHttpServer { | 22 class LayoutTestHttpServer { |
23 public: | 23 public: |
24 LayoutTestHttpServer(const FilePath& root_directory, int port); | 24 LayoutTestHttpServer(const base::FilePath& root_directory, int port); |
25 ~LayoutTestHttpServer(); | 25 ~LayoutTestHttpServer(); |
26 | 26 |
27 // Starts the server. Returns true on success. | 27 // Starts the server. Returns true on success. |
28 bool Start() WARN_UNUSED_RESULT; | 28 bool Start() WARN_UNUSED_RESULT; |
29 | 29 |
30 // Stops the server. Returns true on success. | 30 // Stops the server. Returns true on success. |
31 // | 31 // |
32 // NOTE: It is recommended to explicitly call Stop and check its return value. | 32 // NOTE: It is recommended to explicitly call Stop and check its return value. |
33 // If Stop fails, the server is most likely still running and future attempts | 33 // If Stop fails, the server is most likely still running and future attempts |
34 // to bind to the same port will fail, possibly resulting in further test | 34 // to bind to the same port will fail, possibly resulting in further test |
35 // failures. | 35 // failures. |
36 bool Stop() WARN_UNUSED_RESULT; | 36 bool Stop() WARN_UNUSED_RESULT; |
37 | 37 |
38 int port() const { return port_; } | 38 int port() const { return port_; } |
39 | 39 |
40 private: | 40 private: |
41 FilePath root_directory_; // Root directory of the server. | 41 base::FilePath root_directory_; // Root directory of the server. |
42 | 42 |
43 int port_; // Port on which the server should listen. | 43 int port_; // Port on which the server should listen. |
44 | 44 |
45 bool running_; // True if the server is currently running. | 45 bool running_; // True if the server is currently running. |
46 | 46 |
47 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
48 // JobObject used to clean up orphaned child processes. | 48 // JobObject used to clean up orphaned child processes. |
49 base::win::ScopedHandle job_handle_; | 49 base::win::ScopedHandle job_handle_; |
50 #endif | 50 #endif |
51 | 51 |
52 DISALLOW_COPY_AND_ASSIGN(LayoutTestHttpServer); | 52 DISALLOW_COPY_AND_ASSIGN(LayoutTestHttpServer); |
53 }; | 53 }; |
54 | 54 |
55 } // namespace content | 55 } // namespace content |
56 | 56 |
57 #endif // CONTENT_TEST_LAYOUT_TEST_HTTP_SERVER_H_ | 57 #endif // CONTENT_TEST_LAYOUT_TEST_HTTP_SERVER_H_ |
OLD | NEW |