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

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

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 Stop(); 114 Stop();
115 return false; 115 return false;
116 } 116 }
117 117
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_handle_) 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 bool ret = base::WaitForSingleProcess(process_.Handle(), base::TimeDelta());
129 if (!ret) { 129 if (!ret) {
130 ret = base::KillProcess(process_handle_, 1, true); 130 ret = base::KillProcess(process_.Handle(), 1, true);
131 } 131 }
132 132
133 if (ret) { 133 if (ret) {
134 base::CloseProcessHandle(process_handle_); 134 process_.Close();
135 process_handle_ = base::kNullProcessHandle;
136 } else { 135 } else {
137 VLOG(1) << "Kill failed?"; 136 VLOG(1) << "Kill failed?";
138 } 137 }
139 138
140 return ret; 139 return ret;
141 } 140 }
142 141
143 bool LocalTestServer::Init(const base::FilePath& document_root) { 142 bool LocalTestServer::Init(const base::FilePath& document_root) {
144 if (document_root.IsAbsolute()) 143 if (document_root.IsAbsolute())
145 return false; 144 return false;
146 145
147 // At this point, the port that the test server will listen on is unknown. 146 // At this point, the port that the test server will listen on is unknown.
148 // The test server will listen on an ephemeral port, and write the port 147 // The test server will listen on an ephemeral port, and write the port
149 // number out over a pipe that this TestServer object will read from. Once 148 // number out over a pipe that this TestServer object will read from. Once
150 // that is complete, the host port pair will contain the actual port. 149 // that is complete, the host port pair will contain the actual port.
151 DCHECK(!GetPort()); 150 DCHECK(!GetPort());
152 process_handle_ = base::kNullProcessHandle;
153 151
154 base::FilePath src_dir; 152 base::FilePath src_dir;
155 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) 153 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
156 return false; 154 return false;
157 SetResourcePath(src_dir.Append(document_root), 155 SetResourcePath(src_dir.Append(document_root),
158 src_dir.AppendASCII("net") 156 src_dir.AppendASCII("net")
159 .AppendASCII("data") 157 .AppendASCII("data")
160 .AppendASCII("ssl") 158 .AppendASCII("ssl")
161 .AppendASCII("certificates")); 159 .AppendASCII("certificates"));
162 return true; 160 return true;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 break; 243 break;
246 default: 244 default:
247 NOTREACHED(); 245 NOTREACHED();
248 return false; 246 return false;
249 } 247 }
250 248
251 return true; 249 return true;
252 } 250 }
253 251
254 } // namespace net 252 } // namespace net
OLDNEW
« no previous file with comments | « net/test/spawned_test_server/local_test_server.h ('k') | net/test/spawned_test_server/local_test_server_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698