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

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

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