OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/test_server.h" | 5 #include "net/test/test_server.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 LOG(ERROR) << "Certificate path " << certificate_path.value() | 25 LOG(ERROR) << "Certificate path " << certificate_path.value() |
26 << " doesn't exist. Can't launch https server."; | 26 << " doesn't exist. Can't launch https server."; |
27 return false; | 27 return false; |
28 } | 28 } |
29 command_line.push_back("--https=" + certificate_path.value()); | 29 command_line.push_back("--https=" + certificate_path.value()); |
30 } | 30 } |
31 | 31 |
32 if (type_ == TYPE_HTTPS_CLIENT_AUTH) | 32 if (type_ == TYPE_HTTPS_CLIENT_AUTH) |
33 command_line.push_back("--ssl-client-auth"); | 33 command_line.push_back("--ssl-client-auth"); |
34 | 34 |
35 base::file_handle_mapping_vector no_mappings; | 35 int pipefd[2]; |
36 if (!base::LaunchApp(command_line, no_mappings, false, &process_handle_)) { | 36 if (pipe(pipefd) != 0) { |
| 37 PLOG(ERROR) << "Could not create pipe."; |
| 38 return false; |
| 39 } |
| 40 |
| 41 // Save the read half. The write half is sent to the child. |
| 42 child_fd_ = pipefd[0]; |
| 43 child_fd_closer_.reset(&child_fd_); |
| 44 file_util::ScopedFD write_closer(&pipefd[1]); |
| 45 base::file_handle_mapping_vector map_write_fd; |
| 46 map_write_fd.push_back(std::make_pair(pipefd[1], pipefd[1])); |
| 47 |
| 48 command_line.push_back("--startup-pipe=" + base::IntToString(pipefd[1])); |
| 49 |
| 50 if (!base::LaunchApp(command_line, map_write_fd, false, &process_handle_)) { |
37 LOG(ERROR) << "Failed to launch " << command_line[0] << " ..."; | 51 LOG(ERROR) << "Failed to launch " << command_line[0] << " ..."; |
38 return false; | 52 return false; |
39 } | 53 } |
40 | 54 |
41 return true; | 55 return true; |
42 } | 56 } |
43 | 57 |
| 58 bool TestServer::WaitToStart() { |
| 59 char buf[8]; |
| 60 ssize_t n = HANDLE_EINTR(read(child_fd_, buf, sizeof(buf))); |
| 61 // We don't need the FD anymore. |
| 62 child_fd_closer_.reset(NULL); |
| 63 return n > 0; |
| 64 } |
| 65 |
44 bool TestServer::CheckCATrusted() { | 66 bool TestServer::CheckCATrusted() { |
45 return true; | 67 return true; |
46 } | 68 } |
47 | 69 |
48 } // namespace net | 70 } // namespace net |
OLD | NEW |