Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: net/test/spawned_test_server/local_test_server.cc

Issue 938453002: Remove base::WaitForSingleProcess (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl format :( Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_test_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ipc/ipc_test_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698