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

Side by Side Diff: sandbox/win/tests/common/controller.cc

Issue 606443002: Remove implicit HANDLE conversions from sandbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « sandbox/win/tests/common/controller.h ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sandbox/win/tests/common/controller.h" 5 #include "sandbox/win/tests/common/controller.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/process/process.h" 9 #include "base/process/process.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 policy_->SetTokenLevel(startup_token, main_token); 122 policy_->SetTokenLevel(startup_token, main_token);
123 123
124 is_init_ = true; 124 is_init_ = true;
125 } 125 }
126 126
127 TargetPolicy* TestRunner::GetPolicy() { 127 TargetPolicy* TestRunner::GetPolicy() {
128 return policy_; 128 return policy_;
129 } 129 }
130 130
131 TestRunner::~TestRunner() { 131 TestRunner::~TestRunner() {
132 if (target_process_ && kill_on_destruction_) 132 if (target_process_.IsValid() && kill_on_destruction_)
133 ::TerminateProcess(target_process_, 0); 133 ::TerminateProcess(target_process_.Get(), 0);
134 134
135 if (policy_) 135 if (policy_)
136 policy_->Release(); 136 policy_->Release();
137 } 137 }
138 138
139 bool TestRunner::AddRule(TargetPolicy::SubSystem subsystem, 139 bool TestRunner::AddRule(TargetPolicy::SubSystem subsystem,
140 TargetPolicy::Semantics semantics, 140 TargetPolicy::Semantics semantics,
141 const wchar_t* pattern) { 141 const wchar_t* pattern) {
142 if (!is_init_) 142 if (!is_init_)
143 return false; 143 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 full_command += command; 188 full_command += command;
189 189
190 return InternalRunTest(full_command.c_str()); 190 return InternalRunTest(full_command.c_str());
191 } 191 }
192 192
193 int TestRunner::InternalRunTest(const wchar_t* command) { 193 int TestRunner::InternalRunTest(const wchar_t* command) {
194 if (!is_init_) 194 if (!is_init_)
195 return SBOX_TEST_FAILED_TO_RUN_TEST; 195 return SBOX_TEST_FAILED_TO_RUN_TEST;
196 196
197 // For simplicity TestRunner supports only one process per instance. 197 // For simplicity TestRunner supports only one process per instance.
198 if (target_process_) { 198 if (target_process_.IsValid()) {
199 if (IsProcessRunning(target_process_)) 199 if (IsProcessRunning(target_process_.Get()))
200 return SBOX_TEST_FAILED_TO_RUN_TEST; 200 return SBOX_TEST_FAILED_TO_RUN_TEST;
201 target_process_.Close(); 201 target_process_.Close();
202 target_process_id_ = 0; 202 target_process_id_ = 0;
203 } 203 }
204 204
205 // Get the path to the sandboxed process. 205 // Get the path to the sandboxed process.
206 wchar_t prog_name[MAX_PATH]; 206 wchar_t prog_name[MAX_PATH];
207 GetModuleFileNameW(NULL, prog_name, MAX_PATH); 207 GetModuleFileNameW(NULL, prog_name, MAX_PATH);
208 208
209 // Launch the sandboxed process. 209 // Launch the sandboxed process.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 target->LowerToken(); 328 target->LowerToken();
329 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { 329 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) {
330 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 330 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
331 } 331 }
332 332
333 return command(argc - 4, argv + 4); 333 return command(argc - 4, argv + 4);
334 } 334 }
335 335
336 } // namespace sandbox 336 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/tests/common/controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698