| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_TEST_LOCAL_TEST_SERVER_H_ | 5 #ifndef NET_TEST_LOCAL_TEST_SERVER_H_ |
| 6 #define NET_TEST_LOCAL_TEST_SERVER_H_ | 6 #define NET_TEST_LOCAL_TEST_SERVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 const FilePath& document_root); | 36 const FilePath& document_root); |
| 37 | 37 |
| 38 virtual ~LocalTestServer(); | 38 virtual ~LocalTestServer(); |
| 39 | 39 |
| 40 bool Start() WARN_UNUSED_RESULT; | 40 bool Start() WARN_UNUSED_RESULT; |
| 41 | 41 |
| 42 // Stop the server started by Start(). | 42 // Stop the server started by Start(). |
| 43 bool Stop(); | 43 bool Stop(); |
| 44 | 44 |
| 45 // Modify PYTHONPATH to contain libraries we need. | 45 // Modify PYTHONPATH to contain libraries we need. |
| 46 virtual bool SetPythonPath() const WARN_UNUSED_RESULT; | 46 static bool SetPythonPath() WARN_UNUSED_RESULT; |
| 47 | |
| 48 // This is a static version so that RunSyncTest in run_testserver.py can use | |
| 49 // it. | |
| 50 // TODO(mattm): We should refactor that so this isn't necessary. | |
| 51 static bool SetPythonPathStatic() WARN_UNUSED_RESULT; | |
| 52 | 47 |
| 53 // Returns true if successfully stored the FilePath for the directory of the | 48 // Returns true if successfully stored the FilePath for the directory of the |
| 54 // testserver python script in |*directory|. | 49 // testserver python script in |*directory|. |
| 55 static bool GetTestServerDirectory(FilePath* directory) WARN_UNUSED_RESULT; | 50 static bool GetTestServerDirectory(FilePath* directory) WARN_UNUSED_RESULT; |
| 56 | 51 |
| 57 // Returns true if successfully stored the FilePath for the testserver python | |
| 58 // script in |*testserver_path|. | |
| 59 virtual bool GetTestServerPath(FilePath* testserver_path) const | |
| 60 WARN_UNUSED_RESULT; | |
| 61 | |
| 62 // Adds the command line arguments for the Python test server to | 52 // Adds the command line arguments for the Python test server to |
| 63 // |command_line|. Returns true on success. | 53 // |command_line|. Returns true on success. |
| 64 virtual bool AddCommandLineArguments(CommandLine* command_line) const | 54 virtual bool AddCommandLineArguments(CommandLine* command_line) const; |
| 65 WARN_UNUSED_RESULT; | |
| 66 | 55 |
| 67 private: | 56 private: |
| 68 bool Init(const FilePath& document_root); | 57 bool Init(const FilePath& document_root); |
| 69 | 58 |
| 70 // Launches the Python test server. Returns true on success. | 59 // Launches the Python test server. Returns true on success. |
| 71 bool LaunchPython(const FilePath& testserver_path) WARN_UNUSED_RESULT; | 60 bool LaunchPython(const FilePath& testserver_path) WARN_UNUSED_RESULT; |
| 72 | 61 |
| 73 // Waits for the server to start. Returns true on success. | 62 // Waits for the server to start. Returns true on success. |
| 74 bool WaitToStart() WARN_UNUSED_RESULT; | 63 bool WaitToStart() WARN_UNUSED_RESULT; |
| 75 | 64 |
| 76 // Adds the Python command line arguments and test server path to | |
| 77 // |command_line|. | |
| 78 void AddPythonArguments(const FilePath& testserver_path, | |
| 79 CommandLine* command_line) const; | |
| 80 | |
| 81 // Handle of the Python process running the test server. | 65 // Handle of the Python process running the test server. |
| 82 base::ProcessHandle process_handle_; | 66 base::ProcessHandle process_handle_; |
| 83 | 67 |
| 84 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
| 85 // JobObject used to clean up orphaned child processes. | 69 // JobObject used to clean up orphaned child processes. |
| 86 base::win::ScopedHandle job_handle_; | 70 base::win::ScopedHandle job_handle_; |
| 87 | 71 |
| 88 // The pipe file handle we read from. | 72 // The pipe file handle we read from. |
| 89 base::win::ScopedHandle child_read_fd_; | 73 base::win::ScopedHandle child_read_fd_; |
| 90 | 74 |
| 91 // The pipe file handle the child and we write to. | 75 // The pipe file handle the child and we write to. |
| 92 base::win::ScopedHandle child_write_fd_; | 76 base::win::ScopedHandle child_write_fd_; |
| 93 #endif | 77 #endif |
| 94 | 78 |
| 95 #if defined(OS_POSIX) | 79 #if defined(OS_POSIX) |
| 96 // The file descriptor the child writes to when it starts. | 80 // The file descriptor the child writes to when it starts. |
| 97 int child_fd_; | 81 int child_fd_; |
| 98 file_util::ScopedFD child_fd_closer_; | 82 file_util::ScopedFD child_fd_closer_; |
| 99 #endif | 83 #endif |
| 100 | 84 |
| 101 DISALLOW_COPY_AND_ASSIGN(LocalTestServer); | 85 DISALLOW_COPY_AND_ASSIGN(LocalTestServer); |
| 102 }; | 86 }; |
| 103 | 87 |
| 104 } // namespace net | 88 } // namespace net |
| 105 | 89 |
| 106 #endif // NET_TEST_LOCAL_TEST_SERVER_H_ | 90 #endif // NET_TEST_LOCAL_TEST_SERVER_H_ |
| OLD | NEW |