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/spawned_test_server/local_test_server.h" | 5 #include "net/test/spawned_test_server/local_test_server.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/environment.h" | 12 #include "base/environment.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
| 16 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/test/test_timeouts.h" | 20 #include "base/test/test_timeouts.h" |
20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
21 #include "base/win/scoped_handle.h" | 22 #include "base/win/scoped_handle.h" |
22 #include "net/test/python_utils.h" | 23 #include "net/test/python_utils.h" |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
(...skipping 18 matching lines...) Expand all Loading... |
44 bool ReadData(HANDLE read_fd, | 45 bool ReadData(HANDLE read_fd, |
45 HANDLE write_fd, | 46 HANDLE write_fd, |
46 DWORD bytes_max, | 47 DWORD bytes_max, |
47 uint8_t* buffer) { | 48 uint8_t* buffer) { |
48 base::Thread thread("test_server_watcher"); | 49 base::Thread thread("test_server_watcher"); |
49 if (!thread.Start()) | 50 if (!thread.Start()) |
50 return false; | 51 return false; |
51 | 52 |
52 // Prepare a timeout in case the server fails to start. | 53 // Prepare a timeout in case the server fails to start. |
53 bool unblocked = false; | 54 bool unblocked = false; |
54 thread.message_loop()->PostDelayedTask( | 55 thread.task_runner()->PostDelayedTask( |
55 FROM_HERE, base::Bind(UnblockPipe, write_fd, bytes_max, &unblocked), | 56 FROM_HERE, base::Bind(UnblockPipe, write_fd, bytes_max, &unblocked), |
56 TestTimeouts::action_max_timeout()); | 57 TestTimeouts::action_max_timeout()); |
57 | 58 |
58 DWORD bytes_read = 0; | 59 DWORD bytes_read = 0; |
59 while (bytes_read < bytes_max) { | 60 while (bytes_read < bytes_max) { |
60 DWORD num_bytes; | 61 DWORD num_bytes; |
61 if (!ReadFile(read_fd, buffer + bytes_read, bytes_max - bytes_read, | 62 if (!ReadFile(read_fd, buffer + bytes_read, bytes_max - bytes_read, |
62 &num_bytes, NULL)) { | 63 &num_bytes, NULL)) { |
63 PLOG(ERROR) << "ReadFile failed"; | 64 PLOG(ERROR) << "ReadFile failed"; |
64 return false; | 65 return false; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (!ParseServerData(server_data)) { | 158 if (!ParseServerData(server_data)) { |
158 LOG(ERROR) << "Could not parse server_data: " << server_data; | 159 LOG(ERROR) << "Could not parse server_data: " << server_data; |
159 return false; | 160 return false; |
160 } | 161 } |
161 | 162 |
162 return true; | 163 return true; |
163 } | 164 } |
164 | 165 |
165 } // namespace net | 166 } // namespace net |
166 | 167 |
OLD | NEW |