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

Unified Diff: sandbox/tests/common/controller.cc

Issue 9838083: Add a sandbox API for broker handle duplication (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« sandbox/tests/common/controller.h ('K') | « sandbox/tests/common/controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/tests/common/controller.cc
===================================================================
--- sandbox/tests/common/controller.cc (revision 128951)
+++ sandbox/tests/common/controller.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -81,11 +81,13 @@
}
TestRunner::TestRunner(JobLevel job_level, TokenLevel startup_token,
- TokenLevel main_token) : is_init_(false) {
+ TokenLevel main_token)
+ : is_init_(false), is_async_(false), target_process_id_(0) {
Init(job_level, startup_token, main_token);
}
-TestRunner::TestRunner() : is_init_(false) {
+TestRunner::TestRunner()
+ : is_init_(false), is_async_(false), target_process_id_(0) {
Init(JOB_LOCKDOWN, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN);
}
@@ -95,6 +97,9 @@
policy_ = NULL;
timeout_ = kDefaultTimeout;
state_ = AFTER_REVERT;
+ is_async_= false;
+ target_process_.Close();
rvargas (doing something else) 2012/03/27 00:35:33 ?
jschuh 2012/03/27 01:36:19 Done.
+ target_process_id_ = 0;
broker_ = GetBroker();
if (!broker_)
@@ -115,6 +120,9 @@
}
TestRunner::~TestRunner() {
+ if (broker_ && broker_->IsActiveTarget(target_process_id_))
rvargas (doing something else) 2012/03/27 00:35:33 why not always?
jschuh 2012/03/27 01:36:19 The process ID could get reused. Probably just par
rvargas (doing something else) 2012/03/27 02:30:59 But we have a handle, there's no need to worry abo
+ ::TerminateProcess(target_process_, 0);
+
if (policy_)
policy_->Release();
}
@@ -177,6 +185,14 @@
if (!is_init_)
return SBOX_TEST_FAILED_TO_RUN_TEST;
+ // For simplicity TestRunner supports only one process per instance.
+ if (target_process_) {
+ if (broker_ && broker_->IsActiveTarget(target_process_id_))
rvargas (doing something else) 2012/03/27 00:35:33 We should be able to do this within this class (wi
jschuh 2012/03/27 01:36:19 I originally had it with GetExitCodeProcess, but t
rvargas (doing something else) 2012/03/27 02:30:59 But this only cares about creating two targets, th
+ return SBOX_TEST_FAILED_TO_RUN_TEST;
+ target_process_.Close();
+ target_process_id_ = 0;
+ }
+
// Get the path to the sandboxed process.
wchar_t prog_name[MAX_PATH];
GetModuleFileNameW(NULL, prog_name, MAX_PATH);
@@ -198,6 +214,14 @@
::ResumeThread(target.hThread);
+ // For an asynchronous run we don't bother waiting.
+ if (is_async_) {
+ target_process_.Set(target.hProcess);
+ target_process_id_ = target.dwProcessId;
+ ::CloseHandle(target.hThread);
+ return SBOX_TEST_SUCCEEDED;
+ }
+
if (::IsDebuggerPresent()) {
// Don't kill the target process on a time-out while we are debugging.
timeout_ = INFINITE;
« sandbox/tests/common/controller.h ('K') | « sandbox/tests/common/controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698