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 <windows.h> | 7 #include <windows.h> |
8 #include <wincrypt.h> | 8 #include <wincrypt.h> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
17 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
20 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
22 #include "base/win/scoped_handle.h" | 22 #include "base/win/scoped_handle.h" |
| 23 #include "net/test/python_utils.h" |
23 | 24 |
24 #pragma comment(lib, "crypt32.lib") | 25 #pragma comment(lib, "crypt32.lib") |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // Writes |size| bytes to |handle| and sets |*unblocked| to true. | 29 // Writes |size| bytes to |handle| and sets |*unblocked| to true. |
29 // Used as a crude timeout mechanism by ReadData(). | 30 // Used as a crude timeout mechanism by ReadData(). |
30 void UnblockPipe(HANDLE handle, DWORD size, bool* unblocked) { | 31 void UnblockPipe(HANDLE handle, DWORD size, bool* unblocked) { |
31 std::string unblock_data(size, '\0'); | 32 std::string unblock_data(size, '\0'); |
32 // Unblock the ReadFile in LocalTestServer::WaitToStart by writing to the | 33 // Unblock the ReadFile in LocalTestServer::WaitToStart by writing to the |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 79 } |
79 | 80 |
80 return true; | 81 return true; |
81 } | 82 } |
82 | 83 |
83 } // namespace | 84 } // namespace |
84 | 85 |
85 namespace net { | 86 namespace net { |
86 | 87 |
87 bool LocalTestServer::LaunchPython(const FilePath& testserver_path) { | 88 bool LocalTestServer::LaunchPython(const FilePath& testserver_path) { |
88 FilePath python_exe; | 89 CommandLine python_command(CommandLine::NO_PROGRAM); |
89 if (!PathService::Get(base::DIR_SOURCE_ROOT, &python_exe)) | 90 if (!GetPythonCommand(&python_command)) |
90 return false; | 91 return false; |
91 python_exe = python_exe | |
92 .Append(FILE_PATH_LITERAL("third_party")) | |
93 .Append(FILE_PATH_LITERAL("python_26")) | |
94 .Append(FILE_PATH_LITERAL("python.exe")); | |
95 | 92 |
96 CommandLine python_command(python_exe); | |
97 python_command.AppendArgPath(testserver_path); | 93 python_command.AppendArgPath(testserver_path); |
98 if (!AddCommandLineArguments(&python_command)) | 94 if (!AddCommandLineArguments(&python_command)) |
99 return false; | 95 return false; |
100 | 96 |
101 HANDLE child_read = NULL; | 97 HANDLE child_read = NULL; |
102 HANDLE child_write = NULL; | 98 HANDLE child_write = NULL; |
103 if (!CreatePipe(&child_read, &child_write, NULL, 0)) { | 99 if (!CreatePipe(&child_read, &child_write, NULL, 0)) { |
104 PLOG(ERROR) << "Failed to create pipe"; | 100 PLOG(ERROR) << "Failed to create pipe"; |
105 return false; | 101 return false; |
106 } | 102 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 if (!ParseServerData(server_data)) { | 166 if (!ParseServerData(server_data)) { |
171 LOG(ERROR) << "Could not parse server_data: " << server_data; | 167 LOG(ERROR) << "Could not parse server_data: " << server_data; |
172 return false; | 168 return false; |
173 } | 169 } |
174 | 170 |
175 return true; | 171 return true; |
176 } | 172 } |
177 | 173 |
178 } // namespace net | 174 } // namespace net |
179 | 175 |
OLD | NEW |