Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Unified Diff: net/test/test_server.cc

Issue 9369029: Add '--host' option to testserver.py and expose it via a new TestServer constructor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Integrate the definition of kLocalhost to facilitate follow-up CLs. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/test/test_server.cc
diff --git a/net/test/test_server.cc b/net/test/test_server.cc
index 329f99447436804d8c41d2203d8529c724666051..6e65cca6c6c7083c4ee917661c9bd17090bcaa95 100644
--- a/net/test/test_server.cc
+++ b/net/test/test_server.cc
@@ -81,11 +81,22 @@ FilePath TestServer::HTTPSOptions::GetCertificateFile() const {
return FilePath();
}
+const char* TestServer::kLocalhost = "127.0.0.1";
+
TestServer::TestServer(Type type, const FilePath& document_root)
: type_(type),
started_(false),
log_to_console_(false) {
- Init(document_root);
+ Init("127.0.0.1", document_root);
+}
+
+TestServer::TestServer(Type type,
+ const std::string& host,
+ const FilePath& document_root)
+ : type_(type),
+ started_(false),
+ log_to_console_(false) {
+ Init(host, document_root);
}
TestServer::TestServer(const HTTPSOptions& https_options,
@@ -94,7 +105,7 @@ TestServer::TestServer(const HTTPSOptions& https_options,
type_(TYPE_HTTPS),
started_(false),
log_to_console_(false) {
- Init(document_root);
+ Init(GetHostname(TYPE_HTTPS, https_options), document_root);
}
TestServer::~TestServer() {
@@ -265,12 +276,12 @@ bool TestServer::GetFilePathWithReplacements(
return true;
}
-void TestServer::Init(const FilePath& document_root) {
+void TestServer::Init(const std::string& host, const FilePath& document_root) {
// At this point, the port that the testserver will listen on is unknown.
// The testserver will listen on an ephemeral port, and write the port
// number out over a pipe that this TestServer object will read from. Once
// that is complete, the host_port_pair_ will contain the actual port.
- host_port_pair_ = HostPortPair(GetHostname(type_, https_options_), 0);
+ host_port_pair_ = HostPortPair(host, 0);
process_handle_ = base::kNullProcessHandle;
FilePath src_dir;
@@ -360,6 +371,7 @@ bool TestServer::LoadTestRootCert() {
}
bool TestServer::AddCommandLineArguments(CommandLine* command_line) const {
+ command_line->AppendArg("--host=" + host_port_pair_.host());
command_line->AppendArg("--port=" +
base::IntToString(host_port_pair_.port()));
command_line->AppendArgNative(FILE_PATH_LITERAL("--data-dir=") +

Powered by Google App Engine
This is Rietveld 408576698