OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_SRC_BROKER_SERVICES_H__ | 5 #ifndef SANDBOX_SRC_BROKER_SERVICES_H__ |
6 #define SANDBOX_SRC_BROKER_SERVICES_H__ | 6 #define SANDBOX_SRC_BROKER_SERVICES_H__ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <set> | |
9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
10 #include "sandbox/src/crosscall_server.h" | 11 #include "sandbox/src/crosscall_server.h" |
11 #include "sandbox/src/job.h" | 12 #include "sandbox/src/job.h" |
12 #include "sandbox/src/sandbox.h" | 13 #include "sandbox/src/sandbox.h" |
13 #include "sandbox/src/sharedmem_ipc_server.h" | 14 #include "sandbox/src/sharedmem_ipc_server.h" |
14 #include "sandbox/src/win2k_threadpool.h" | 15 #include "sandbox/src/win2k_threadpool.h" |
15 #include "sandbox/src/win_utils.h" | 16 #include "sandbox/src/win_utils.h" |
16 | 17 |
17 namespace sandbox { | 18 namespace sandbox { |
18 | 19 |
19 class PolicyBase; | 20 class PolicyBase; |
20 | 21 |
21 // BrokerServicesBase --------------------------------------------------------- | 22 // BrokerServicesBase --------------------------------------------------------- |
22 // Broker implementation version 0 | 23 // Broker implementation version 0 |
23 // | 24 // |
24 // This is an implementation of the interface BrokerServices and | 25 // This is an implementation of the interface BrokerServices and |
25 // of the associated TargetProcess interface. In this implementation | 26 // of the associated TargetProcess interface. In this implementation |
26 // TargetProcess is a friend of BrokerServices where the later manages a | 27 // TargetProcess is a friend of BrokerServices where the later manages a |
27 // collection of the former. | 28 // collection of the former. |
28 class BrokerServicesBase : public BrokerServices, | 29 class BrokerServicesBase : public BrokerServices, |
29 public SingletonBase<BrokerServicesBase> { | 30 public SingletonBase<BrokerServicesBase> { |
30 public: | 31 public: |
31 BrokerServicesBase(); | 32 BrokerServicesBase(); |
32 | 33 |
33 ~BrokerServicesBase(); | 34 ~BrokerServicesBase(); |
34 | 35 |
35 // The next four methods are the BrokerServices interface | 36 // The next five methods are the BrokerServices interface |
nsylvain
2012/03/28 13:11:46
you can just remove "five"
jschuh
2012/03/28 22:09:29
Done.
| |
36 virtual ResultCode Init(); | 37 virtual ResultCode Init(); |
37 | 38 |
38 virtual TargetPolicy* CreatePolicy(); | 39 virtual TargetPolicy* CreatePolicy(); |
39 | 40 |
40 virtual ResultCode SpawnTarget(const wchar_t* exe_path, | 41 virtual ResultCode SpawnTarget(const wchar_t* exe_path, |
41 const wchar_t* command_line, | 42 const wchar_t* command_line, |
42 TargetPolicy* policy, | 43 TargetPolicy* policy, |
43 PROCESS_INFORMATION* target); | 44 PROCESS_INFORMATION* target); |
44 | 45 |
45 virtual ResultCode WaitForAllTargets(); | 46 virtual ResultCode WaitForAllTargets(); |
46 | 47 |
48 virtual bool IsActiveTarget(DWORD process_id); | |
49 | |
47 private: | 50 private: |
48 // Helper structure that allows the Broker to associate a job notification | 51 // Helper structure that allows the Broker to associate a job notification |
49 // with a job object and with a policy. | 52 // with a job object and with a policy. |
50 struct JobTracker { | 53 struct JobTracker { |
51 HANDLE job; | 54 HANDLE job; |
52 PolicyBase* policy; | 55 PolicyBase* policy; |
53 JobTracker(HANDLE cjob, PolicyBase* cpolicy) | 56 JobTracker(HANDLE cjob, PolicyBase* cpolicy) |
54 : job(cjob), policy(cpolicy) { | 57 : job(cjob), policy(cpolicy) { |
55 } | 58 } |
56 }; | 59 }; |
(...skipping 21 matching lines...) Expand all Loading... | |
78 // threads at the same time. | 81 // threads at the same time. |
79 CRITICAL_SECTION lock_; | 82 CRITICAL_SECTION lock_; |
80 | 83 |
81 // provides a pool of threads that are used to wait on the IPC calls. | 84 // provides a pool of threads that are used to wait on the IPC calls. |
82 ThreadProvider* thread_pool_; | 85 ThreadProvider* thread_pool_; |
83 | 86 |
84 // List of the trackers for closing and cleanup purposes. | 87 // List of the trackers for closing and cleanup purposes. |
85 typedef std::list<JobTracker*> JobTrackerList; | 88 typedef std::list<JobTracker*> JobTrackerList; |
86 JobTrackerList tracker_list_; | 89 JobTrackerList tracker_list_; |
87 | 90 |
91 // Provides a fast lookup to identify sandboxed processes. | |
92 std::set<DWORD> child_process_ids_; | |
93 | |
88 DISALLOW_COPY_AND_ASSIGN(BrokerServicesBase); | 94 DISALLOW_COPY_AND_ASSIGN(BrokerServicesBase); |
89 }; | 95 }; |
90 | 96 |
91 } // namespace sandbox | 97 } // namespace sandbox |
92 | 98 |
93 | 99 |
94 #endif // SANDBOX_SRC_BROKER_SERVICES_H__ | 100 #endif // SANDBOX_SRC_BROKER_SERVICES_H__ |
OLD | NEW |