OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 5 #include <string> |
6 #include <algorithm> | 6 #include <algorithm> |
7 | 7 |
8 #include "net/socket/ssl_test_util.h" | 8 #include "net/socket/ssl_test_util.h" |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 | 11 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 // static | 130 // static |
131 const char TestServerLauncher::kHostName[] = "127.0.0.1"; | 131 const char TestServerLauncher::kHostName[] = "127.0.0.1"; |
132 const char TestServerLauncher::kMismatchedHostName[] = "localhost"; | 132 const char TestServerLauncher::kMismatchedHostName[] = "localhost"; |
133 const int TestServerLauncher::kOKHTTPSPort = 9443; | 133 const int TestServerLauncher::kOKHTTPSPort = 9443; |
134 const int TestServerLauncher::kBadHTTPSPort = 9666; | 134 const int TestServerLauncher::kBadHTTPSPort = 9666; |
135 | 135 |
136 // The issuer name of the cert that should be trusted for the test to work. | 136 // The issuer name of the cert that should be trusted for the test to work. |
137 const wchar_t TestServerLauncher::kCertIssuerName[] = L"Test CA"; | 137 const wchar_t TestServerLauncher::kCertIssuerName[] = L"Test CA"; |
138 | 138 |
139 TestServerLauncher::TestServerLauncher() : process_handle_(NULL), | 139 TestServerLauncher::TestServerLauncher() : process_handle_( |
| 140 base::kNullProcessHandle), |
140 forking_(false), | 141 forking_(false), |
141 connection_attempts_(10), | 142 connection_attempts_(10), |
142 connection_timeout_(1000) | 143 connection_timeout_(1000) |
143 #if defined(OS_LINUX) | 144 #if defined(OS_LINUX) |
144 , cert_(NULL) | 145 , cert_(NULL) |
145 #endif | 146 #endif |
146 { | 147 { |
147 InitCertPath(); | 148 InitCertPath(); |
148 } | 149 } |
149 | 150 |
150 TestServerLauncher::TestServerLauncher(int connection_attempts, | 151 TestServerLauncher::TestServerLauncher(int connection_attempts, |
151 int connection_timeout) | 152 int connection_timeout) |
152 : process_handle_(NULL), | 153 : process_handle_(base::kNullProcessHandle), |
153 forking_(false), | 154 forking_(false), |
154 connection_attempts_(connection_attempts), | 155 connection_attempts_(connection_attempts), |
155 connection_timeout_(connection_timeout) | 156 connection_timeout_(connection_timeout) |
156 #if defined(OS_LINUX) | 157 #if defined(OS_LINUX) |
157 , cert_(NULL) | 158 , cert_(NULL) |
158 #endif | 159 #endif |
159 { | 160 { |
160 InitCertPath(); | 161 InitCertPath(); |
161 } | 162 } |
162 | 163 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 return rv == net::OK; | 325 return rv == net::OK; |
325 } | 326 } |
326 | 327 |
327 bool TestServerLauncher::WaitToFinish(int timeout_ms) { | 328 bool TestServerLauncher::WaitToFinish(int timeout_ms) { |
328 if (!process_handle_) | 329 if (!process_handle_) |
329 return true; | 330 return true; |
330 | 331 |
331 bool ret = base::WaitForSingleProcess(process_handle_, timeout_ms); | 332 bool ret = base::WaitForSingleProcess(process_handle_, timeout_ms); |
332 if (ret) { | 333 if (ret) { |
333 base::CloseProcessHandle(process_handle_); | 334 base::CloseProcessHandle(process_handle_); |
334 process_handle_ = NULL; | 335 process_handle_ = base::kNullProcessHandle; |
335 LOG(INFO) << "Finished."; | 336 LOG(INFO) << "Finished."; |
336 } else { | 337 } else { |
337 LOG(INFO) << "Timed out."; | 338 LOG(INFO) << "Timed out."; |
338 } | 339 } |
339 return ret; | 340 return ret; |
340 } | 341 } |
341 | 342 |
342 bool TestServerLauncher::Stop() { | 343 bool TestServerLauncher::Stop() { |
343 if (!process_handle_) | 344 if (!process_handle_) |
344 return true; | 345 return true; |
345 | 346 |
346 bool ret = base::KillProcess(process_handle_, 1, true); | 347 bool ret = base::KillProcess(process_handle_, 1, true); |
347 if (ret) { | 348 if (ret) { |
348 base::CloseProcessHandle(process_handle_); | 349 base::CloseProcessHandle(process_handle_); |
349 process_handle_ = NULL; | 350 process_handle_ = base::kNullProcessHandle; |
350 LOG(INFO) << "Stopped."; | 351 LOG(INFO) << "Stopped."; |
351 } else { | 352 } else { |
352 LOG(INFO) << "Kill failed?"; | 353 LOG(INFO) << "Kill failed?"; |
353 } | 354 } |
354 | 355 |
355 return ret; | 356 return ret; |
356 } | 357 } |
357 | 358 |
358 TestServerLauncher::~TestServerLauncher() { | 359 TestServerLauncher::~TestServerLauncher() { |
359 #if defined(OS_LINUX) | 360 #if defined(OS_LINUX) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 "certificate to your trusted roots for this test to work. " | 433 "certificate to your trusted roots for this test to work. " |
433 "For more info visit:\n" | 434 "For more info visit:\n" |
434 "http://dev.chromium.org/developers/testing\n"; | 435 "http://dev.chromium.org/developers/testing\n"; |
435 return false; | 436 return false; |
436 } | 437 } |
437 #endif | 438 #endif |
438 return true; | 439 return true; |
439 } | 440 } |
440 | 441 |
441 } // namespace net | 442 } // namespace net |
OLD | NEW |