| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 bool ReadData(HANDLE read_fd, HANDLE write_fd, | 46 bool ReadData(HANDLE read_fd, HANDLE write_fd, |
| 47 DWORD bytes_max, uint8* buffer) { | 47 DWORD bytes_max, uint8* buffer) { |
| 48 base::Thread thread("test_server_watcher"); | 48 base::Thread thread("test_server_watcher"); |
| 49 if (!thread.Start()) | 49 if (!thread.Start()) |
| 50 return false; | 50 return false; |
| 51 | 51 |
| 52 // Prepare a timeout in case the server fails to start. | 52 // Prepare a timeout in case the server fails to start. |
| 53 bool unblocked = false; | 53 bool unblocked = false; |
| 54 thread.message_loop()->PostDelayedTask( | 54 thread.message_loop()->PostDelayedTask( |
| 55 FROM_HERE, base::Bind(UnblockPipe, write_fd, bytes_max, &unblocked), | 55 FROM_HERE, base::Bind(UnblockPipe, write_fd, bytes_max, &unblocked), |
| 56 TestTimeouts::action_timeout_ms()); | 56 TestTimeouts::action_max_timeout_ms()); |
| 57 | 57 |
| 58 DWORD bytes_read = 0; | 58 DWORD bytes_read = 0; |
| 59 while (bytes_read < bytes_max) { | 59 while (bytes_read < bytes_max) { |
| 60 DWORD num_bytes; | 60 DWORD num_bytes; |
| 61 if (!ReadFile(read_fd, buffer + bytes_read, bytes_max - bytes_read, | 61 if (!ReadFile(read_fd, buffer + bytes_read, bytes_max - bytes_read, |
| 62 &num_bytes, NULL)) { | 62 &num_bytes, NULL)) { |
| 63 PLOG(ERROR) << "ReadFile failed"; | 63 PLOG(ERROR) << "ReadFile failed"; |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 if (num_bytes <= 0) { | 66 if (num_bytes <= 0) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 if (!ParseServerData(server_data)) { | 170 if (!ParseServerData(server_data)) { |
| 171 LOG(ERROR) << "Could not parse server_data: " << server_data; | 171 LOG(ERROR) << "Could not parse server_data: " << server_data; |
| 172 return false; | 172 return false; |
| 173 } | 173 } |
| 174 | 174 |
| 175 return true; | 175 return true; |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace net | 178 } // namespace net |
| OLD | NEW |