Chromium Code Reviews| 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 #include "net/test/local_test_server.h" | 5 #include "net/test/local_test_server.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 LocalTestServer::LocalTestServer(Type type, | 60 LocalTestServer::LocalTestServer(Type type, |
| 61 const std::string& host, | 61 const std::string& host, |
| 62 const FilePath& document_root) | 62 const FilePath& document_root) |
| 63 : BaseTestServer(type, host) { | 63 : BaseTestServer(type, host) { |
| 64 if (!Init(document_root)) | 64 if (!Init(document_root)) |
| 65 NOTREACHED(); | 65 NOTREACHED(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 LocalTestServer::LocalTestServer(const HTTPSOptions& https_options, | 68 LocalTestServer::LocalTestServer(Type type, |
| 69 const SSLOptions& ssl_options, | |
| 69 const FilePath& document_root) | 70 const FilePath& document_root) |
| 70 : BaseTestServer(https_options) { | 71 : BaseTestServer(type, ssl_options) { |
| 71 if (!Init(document_root)) | 72 if (!Init(document_root)) |
| 72 NOTREACHED(); | 73 NOTREACHED(); |
| 73 } | 74 } |
| 74 | 75 |
| 75 LocalTestServer::~LocalTestServer() { | 76 LocalTestServer::~LocalTestServer() { |
| 76 Stop(); | 77 Stop(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 // static | 80 // static |
| 80 bool LocalTestServer::GetTestServerDirectory(FilePath* directory) { | 81 bool LocalTestServer::GetTestServerDirectory(FilePath* directory) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 // number out over a pipe that this TestServer object will read from. Once | 146 // number out over a pipe that this TestServer object will read from. Once |
| 146 // that is complete, the host port pair will contain the actual port. | 147 // that is complete, the host port pair will contain the actual port. |
| 147 DCHECK(!GetPort()); | 148 DCHECK(!GetPort()); |
| 148 process_handle_ = base::kNullProcessHandle; | 149 process_handle_ = base::kNullProcessHandle; |
| 149 | 150 |
| 150 FilePath src_dir; | 151 FilePath src_dir; |
| 151 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) | 152 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) |
| 152 return false; | 153 return false; |
| 153 SetResourcePath(src_dir.Append(document_root), | 154 SetResourcePath(src_dir.Append(document_root), |
| 154 src_dir.AppendASCII("net") | 155 src_dir.AppendASCII("net") |
| 155 .AppendASCII("data") | 156 .AppendASCII("data") |
| 156 .AppendASCII("ssl") | 157 .AppendASCII("ssl") |
| 157 .AppendASCII("certificates")); | 158 .AppendASCII("certificates")); |
| 158 return true; | 159 return true; |
| 159 } | 160 } |
| 160 | 161 |
| 161 // static | 162 // static |
| 162 bool LocalTestServer::SetPythonPath() { | 163 bool LocalTestServer::SetPythonPath() { |
| 163 FilePath third_party_dir; | 164 FilePath third_party_dir; |
| 164 if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { | 165 if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { |
| 165 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; | 166 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; |
| 166 return false; | 167 return false; |
| 167 } | 168 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 return false; | 220 return false; |
| 220 } | 221 } |
| 221 } | 222 } |
| 222 | 223 |
| 223 // Append the appropriate server type argument. | 224 // Append the appropriate server type argument. |
| 224 switch (type()) { | 225 switch (type()) { |
| 225 case TYPE_HTTP: | 226 case TYPE_HTTP: |
| 226 case TYPE_HTTPS: | 227 case TYPE_HTTPS: |
| 227 // The default type is HTTP, no argument required. | 228 // The default type is HTTP, no argument required. |
| 228 break; | 229 break; |
| 230 case TYPE_WS: | |
| 231 case TYPE_WSS: | |
| 232 // TODO(toyoshim): Handle correctly. See, http://crbug.com/137639 . | |
|
Paweł Hajdan Jr.
2012/08/30 08:56:34
NOTIMPLEMENTED() then.
Takashi Toyoshima
2012/09/01 09:07:30
I see.
But this line will be implemented in the su
| |
| 233 break; | |
| 229 case TYPE_FTP: | 234 case TYPE_FTP: |
| 230 command_line->AppendArg("-f"); | 235 command_line->AppendArg("-f"); |
| 231 break; | 236 break; |
| 232 case TYPE_SYNC: | 237 case TYPE_SYNC: |
| 233 command_line->AppendArg("--sync"); | 238 command_line->AppendArg("--sync"); |
| 234 break; | 239 break; |
| 235 case TYPE_TCP_ECHO: | 240 case TYPE_TCP_ECHO: |
| 236 command_line->AppendArg("--tcp-echo"); | 241 command_line->AppendArg("--tcp-echo"); |
| 237 break; | 242 break; |
| 238 case TYPE_UDP_ECHO: | 243 case TYPE_UDP_ECHO: |
| 239 command_line->AppendArg("--udp-echo"); | 244 command_line->AppendArg("--udp-echo"); |
| 240 break; | 245 break; |
| 241 case TYPE_GDATA: | 246 case TYPE_GDATA: |
| 242 command_line->AppendArg( | 247 command_line->AppendArg( |
| 243 std::string("--auth-token") + "=" + BaseTestServer::kGDataAuthToken); | 248 std::string("--auth-token") + "=" + BaseTestServer::kGDataAuthToken); |
| 244 break; | 249 break; |
| 245 default: | 250 default: |
| 246 NOTREACHED(); | 251 NOTREACHED(); |
| 247 return false; | 252 return false; |
| 248 } | 253 } |
| 249 | 254 |
| 250 return true; | 255 return true; |
| 251 } | 256 } |
| 252 | 257 |
| 253 } // namespace net | 258 } // namespace net |
| OLD | NEW |