OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/process/kill.h" | 11 #include "base/process/kill.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/test/test_timeouts.h" | |
14 #include "base/values.h" | 13 #include "base/values.h" |
15 #include "net/base/host_port_pair.h" | 14 #include "net/base/host_port_pair.h" |
16 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
17 #include "net/test/python_utils.h" | 16 #include "net/test/python_utils.h" |
18 #include "url/gurl.h" | 17 #include "url/gurl.h" |
19 | 18 |
20 namespace net { | 19 namespace net { |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 119 } |
121 | 120 |
122 bool LocalTestServer::Stop() { | 121 bool LocalTestServer::Stop() { |
123 CleanUpWhenStoppingServer(); | 122 CleanUpWhenStoppingServer(); |
124 | 123 |
125 if (!process_handle_) | 124 if (!process_handle_) |
126 return true; | 125 return true; |
127 | 126 |
128 #if defined(OS_WIN) | 127 #if defined(OS_WIN) |
129 // This kills all the processes in the job object. | 128 // This kills all the processes in the job object. |
130 TerminateJobObject(job_handle_.Get(), 1); | |
131 // This is done asynchronously so wait a bit for the processes to be killed. | |
132 WaitForSingleObject(job_handle_.Get(), | |
133 TestTimeouts::action_timeout().InMilliseconds()); | |
134 job_handle_.Close(); | 129 job_handle_.Close(); |
135 #endif | 130 #endif |
136 | 131 |
137 // First check if the process has already terminated. | 132 // First check if the process has already terminated. |
138 bool ret = base::WaitForSingleProcess(process_handle_, base::TimeDelta()); | 133 bool ret = base::WaitForSingleProcess(process_handle_, base::TimeDelta()); |
139 if (!ret) { | 134 if (!ret) { |
140 ret = base::KillProcess(process_handle_, 1, true); | 135 ret = base::KillProcess(process_handle_, 1, true); |
141 } | 136 } |
142 | 137 |
143 if (ret) { | 138 if (ret) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 break; | 250 break; |
256 default: | 251 default: |
257 NOTREACHED(); | 252 NOTREACHED(); |
258 return false; | 253 return false; |
259 } | 254 } |
260 | 255 |
261 return true; | 256 return true; |
262 } | 257 } |
263 | 258 |
264 } // namespace net | 259 } // namespace net |
OLD | NEW |