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

Side by Side Diff: sandbox/tests/common/controller.h

Issue 9838083: Add a sandbox API for broker handle duplication (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/src/target_services.cc ('k') | sandbox/tests/common/controller.cc » ('j') | 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) 2006-2010 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 #ifndef SANDBOX_TESTS_COMMON_CONTROLLER_H_ 5 #ifndef SANDBOX_TESTS_COMMON_CONTROLLER_H_
6 #define SANDBOX_TESTS_COMMON_CONTROLLER_H__ 6 #define SANDBOX_TESTS_COMMON_CONTROLLER_H__
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/win/scoped_handle.h"
11 #include "sandbox/src/sandbox.h" 12 #include "sandbox/src/sandbox.h"
12 13
13 namespace sandbox { 14 namespace sandbox {
14 15
15 // See winerror.h for details. 16 // See winerror.h for details.
16 #define SEVERITY_INFO_FLAGS 0x40000000 17 #define SEVERITY_INFO_FLAGS 0x40000000
17 #define SEVERITY_ERROR_FLAGS 0xC0000000 18 #define SEVERITY_ERROR_FLAGS 0xC0000000
18 #define CUSTOMER_CODE 0x20000000 19 #define CUSTOMER_CODE 0x20000000
19 #define SBOX_TESTS_FACILITY 0x05B10000 20 #define SBOX_TESTS_FACILITY 0x05B10000
20 21
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // succeeds. 85 // succeeds.
85 bool AddFsRule(TargetPolicy::Semantics semantics, const wchar_t* pattern); 86 bool AddFsRule(TargetPolicy::Semantics semantics, const wchar_t* pattern);
86 87
87 // Starts a child process in the sandbox and ask it to run |command|. Returns 88 // Starts a child process in the sandbox and ask it to run |command|. Returns
88 // a SboxTestResult. By default, the test runs AFTER_REVERT. 89 // a SboxTestResult. By default, the test runs AFTER_REVERT.
89 int RunTest(const wchar_t* command); 90 int RunTest(const wchar_t* command);
90 91
91 // Sets the timeout value for the child to run the command and return. 92 // Sets the timeout value for the child to run the command and return.
92 void SetTimeout(DWORD timeout_ms); 93 void SetTimeout(DWORD timeout_ms);
93 94
95 // Sets TestRunner to return without waiting for the process to exit.
96 void SetAsynchronous(bool is_async) { is_async_ = is_async; }
97
94 // Sets the desired state for the test to run. 98 // Sets the desired state for the test to run.
95 void SetTestState(SboxTestsState desired_state); 99 void SetTestState(SboxTestsState desired_state);
96 100
97 // Returns the pointers to the policy object. It can be used to modify 101 // Returns the pointers to the policy object. It can be used to modify
98 // the policy manually. 102 // the policy manually.
99 TargetPolicy* GetPolicy(); 103 TargetPolicy* GetPolicy();
100 104
105 // Return the process handle for an asynchronous test.
106 HANDLE process() { return target_process_; }
107
108 // Return the process ID for an asynchronous test.
109 DWORD process_id() { return target_process_id_; }
110
101 private: 111 private:
102 // Initializes the data in the object. Sets is_init_ to tree if the 112 // Initializes the data in the object. Sets is_init_ to tree if the
103 // function succeeds. This is meant to be called from the constructor. 113 // function succeeds. This is meant to be called from the constructor.
104 void Init(JobLevel job_level, TokenLevel startup_token, 114 void Init(JobLevel job_level, TokenLevel startup_token,
105 TokenLevel main_token); 115 TokenLevel main_token);
106 116
107 // The actual runner. 117 // The actual runner.
108 int InternalRunTest(const wchar_t* command); 118 int InternalRunTest(const wchar_t* command);
109 119
110 BrokerServices* broker_; 120 BrokerServices* broker_;
111 TargetPolicy* policy_; 121 TargetPolicy* policy_;
112 DWORD timeout_; 122 DWORD timeout_;
113 SboxTestsState state_; 123 SboxTestsState state_;
114 bool is_init_; 124 bool is_init_;
125 bool is_async_;
126 base::win::ScopedHandle target_process_;
127 DWORD target_process_id_;
115 }; 128 };
116 129
117 // Returns the broker services. 130 // Returns the broker services.
118 BrokerServices* GetBroker(); 131 BrokerServices* GetBroker();
119 132
120 // Constructs a full path to a file inside the system32 (or syswow64) folder. 133 // Constructs a full path to a file inside the system32 (or syswow64) folder.
121 std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path); 134 std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path);
122 135
123 // Runs the given test on the target process. 136 // Runs the given test on the target process.
124 int DispatchCall(int argc, wchar_t **argv); 137 int DispatchCall(int argc, wchar_t **argv);
125 138
126 } // namespace sandbox 139 } // namespace sandbox
127 140
128 #endif // SANDBOX_TESTS_COMMON_CONTROLLER_H_ 141 #endif // SANDBOX_TESTS_COMMON_CONTROLLER_H_
OLDNEW
« no previous file with comments | « sandbox/src/target_services.cc ('k') | sandbox/tests/common/controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698