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