| 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 NET_TEST_TEST_SERVER_H_ | 5 #ifndef NET_TEST_TEST_SERVER_H_ |
| 6 #define NET_TEST_TEST_SERVER_H_ | 6 #define NET_TEST_TEST_SERVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 | 14 |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
| 17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
| 18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
| 19 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 | 21 |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 #include "base/win/scoped_handle.h" | 23 #include "base/win/scoped_handle.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 class CommandLine; | 26 class CommandLine; |
| 27 class GURL; |
| 28 |
| 29 namespace base { |
| 27 class DictionaryValue; | 30 class DictionaryValue; |
| 28 class GURL; | 31 } |
| 29 | 32 |
| 30 namespace net { | 33 namespace net { |
| 31 | 34 |
| 32 class AddressList; | 35 class AddressList; |
| 33 | 36 |
| 34 // This object bounds the lifetime of an external python-based HTTP/FTP server | 37 // This object bounds the lifetime of an external python-based HTTP/FTP server |
| 35 // that can provide various responses useful for testing. | 38 // that can provide various responses useful for testing. |
| 36 class TestServer { | 39 class TestServer { |
| 37 public: | 40 public: |
| 38 typedef std::pair<std::string, std::string> StringPair; | 41 typedef std::pair<std::string, std::string> StringPair; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 113 |
| 111 ~TestServer(); | 114 ~TestServer(); |
| 112 | 115 |
| 113 bool Start() WARN_UNUSED_RESULT; | 116 bool Start() WARN_UNUSED_RESULT; |
| 114 | 117 |
| 115 // Stop the server started by Start(). | 118 // Stop the server started by Start(). |
| 116 bool Stop(); | 119 bool Stop(); |
| 117 | 120 |
| 118 const FilePath& document_root() const { return document_root_; } | 121 const FilePath& document_root() const { return document_root_; } |
| 119 const HostPortPair& host_port_pair() const; | 122 const HostPortPair& host_port_pair() const; |
| 120 const DictionaryValue& server_data() const; | 123 const base::DictionaryValue& server_data() const; |
| 121 std::string GetScheme() const; | 124 std::string GetScheme() const; |
| 122 bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT; | 125 bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT; |
| 123 | 126 |
| 124 GURL GetURL(const std::string& path) const; | 127 GURL GetURL(const std::string& path) const; |
| 125 | 128 |
| 126 GURL GetURLWithUser(const std::string& path, | 129 GURL GetURLWithUser(const std::string& path, |
| 127 const std::string& user) const; | 130 const std::string& user) const; |
| 128 | 131 |
| 129 GURL GetURLWithUserAndPassword(const std::string& path, | 132 GURL GetURLWithUserAndPassword(const std::string& path, |
| 130 const std::string& user, | 133 const std::string& user, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // Document root of the test server. | 167 // Document root of the test server. |
| 165 FilePath document_root_; | 168 FilePath document_root_; |
| 166 | 169 |
| 167 // Directory that contains the SSL certificates. | 170 // Directory that contains the SSL certificates. |
| 168 FilePath certificates_dir_; | 171 FilePath certificates_dir_; |
| 169 | 172 |
| 170 // Address the test server listens on. | 173 // Address the test server listens on. |
| 171 HostPortPair host_port_pair_; | 174 HostPortPair host_port_pair_; |
| 172 | 175 |
| 173 // Holds the data sent from the server (e.g., port number). | 176 // Holds the data sent from the server (e.g., port number). |
| 174 scoped_ptr<DictionaryValue> server_data_; | 177 scoped_ptr<base::DictionaryValue> server_data_; |
| 175 | 178 |
| 176 // Handle of the Python process running the test server. | 179 // Handle of the Python process running the test server. |
| 177 base::ProcessHandle process_handle_; | 180 base::ProcessHandle process_handle_; |
| 178 | 181 |
| 179 scoped_ptr<net::ScopedPortException> allowed_port_; | 182 scoped_ptr<net::ScopedPortException> allowed_port_; |
| 180 | 183 |
| 181 #if defined(OS_WIN) | 184 #if defined(OS_WIN) |
| 182 // JobObject used to clean up orphaned child processes. | 185 // JobObject used to clean up orphaned child processes. |
| 183 base::win::ScopedHandle job_handle_; | 186 base::win::ScopedHandle job_handle_; |
| 184 | 187 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 202 | 205 |
| 203 // Has the server been started? | 206 // Has the server been started? |
| 204 bool started_; | 207 bool started_; |
| 205 | 208 |
| 206 DISALLOW_COPY_AND_ASSIGN(TestServer); | 209 DISALLOW_COPY_AND_ASSIGN(TestServer); |
| 207 }; | 210 }; |
| 208 | 211 |
| 209 } // namespace net | 212 } // namespace net |
| 210 | 213 |
| 211 #endif // NET_TEST_TEST_SERVER_H_ | 214 #endif // NET_TEST_TEST_SERVER_H_ |
| OLD | NEW |