| 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" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return SetupWhenServerStarted(); | 118 return SetupWhenServerStarted(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool LocalTestServer::Stop() { | 121 bool LocalTestServer::Stop() { |
| 122 CleanUpWhenStoppingServer(); | 122 CleanUpWhenStoppingServer(); |
| 123 | 123 |
| 124 if (!process_.IsValid()) | 124 if (!process_.IsValid()) |
| 125 return true; | 125 return true; |
| 126 | 126 |
| 127 // First check if the process has already terminated. | 127 // First check if the process has already terminated. |
| 128 bool ret = base::WaitForSingleProcess(process_.Handle(), base::TimeDelta()); | 128 int exit_code; |
| 129 if (!ret) { | 129 bool ret = process_.WaitForExitWithTimeout(base::TimeDelta(), &exit_code); |
| 130 if (!ret) |
| 130 ret = base::KillProcess(process_.Handle(), 1, true); | 131 ret = base::KillProcess(process_.Handle(), 1, true); |
| 131 } | |
| 132 | 132 |
| 133 if (ret) { | 133 if (ret) |
| 134 process_.Close(); | 134 process_.Close(); |
| 135 } else { | 135 else |
| 136 VLOG(1) << "Kill failed?"; | 136 VLOG(1) << "Kill failed?"; |
| 137 } | |
| 138 | 137 |
| 139 return ret; | 138 return ret; |
| 140 } | 139 } |
| 141 | 140 |
| 142 bool LocalTestServer::Init(const base::FilePath& document_root) { | 141 bool LocalTestServer::Init(const base::FilePath& document_root) { |
| 143 if (document_root.IsAbsolute()) | 142 if (document_root.IsAbsolute()) |
| 144 return false; | 143 return false; |
| 145 | 144 |
| 146 // At this point, the port that the test server will listen on is unknown. | 145 // At this point, the port that the test server will listen on is unknown. |
| 147 // The test server will listen on an ephemeral port, and write the port | 146 // The test server will listen on an ephemeral port, and write the port |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 break; | 242 break; |
| 244 default: | 243 default: |
| 245 NOTREACHED(); | 244 NOTREACHED(); |
| 246 return false; | 245 return false; |
| 247 } | 246 } |
| 248 | 247 |
| 249 return true; | 248 return true; |
| 250 } | 249 } |
| 251 | 250 |
| 252 } // namespace net | 251 } // namespace net |
| OLD | NEW |