OLD | NEW |
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 #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 <set> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 virtual TargetPolicy* CreatePolicy(); | 39 virtual TargetPolicy* CreatePolicy(); |
40 | 40 |
41 virtual ResultCode SpawnTarget(const wchar_t* exe_path, | 41 virtual ResultCode SpawnTarget(const wchar_t* exe_path, |
42 const wchar_t* command_line, | 42 const wchar_t* command_line, |
43 TargetPolicy* policy, | 43 TargetPolicy* policy, |
44 PROCESS_INFORMATION* target); | 44 PROCESS_INFORMATION* target); |
45 | 45 |
46 virtual ResultCode WaitForAllTargets(); | 46 virtual ResultCode WaitForAllTargets(); |
47 | 47 |
| 48 virtual ResultCode AddTargetPeer(HANDLE peer_process); |
| 49 |
48 // Checks if the supplied process ID matches one of the broker's active | 50 // Checks if the supplied process ID matches one of the broker's active |
49 // target processes | 51 // target processes |
50 // Returns: | 52 // Returns: |
51 // true if there is an active target process for this ID, otherwise false. | 53 // true if there is an active target process for this ID, otherwise false. |
52 bool IsActiveTarget(DWORD process_id); | 54 bool IsActiveTarget(DWORD process_id); |
53 | 55 |
54 private: | 56 private: |
55 // Helper structure that allows the Broker to associate a job notification | 57 // Helper structure that allows the Broker to associate a job notification |
56 // with a job object and with a policy. | 58 // with a job object and with a policy. |
57 struct JobTracker { | 59 struct JobTracker { |
58 HANDLE job; | 60 HANDLE job; |
59 PolicyBase* policy; | 61 PolicyBase* policy; |
60 JobTracker(HANDLE cjob, PolicyBase* cpolicy) | 62 JobTracker(HANDLE cjob, PolicyBase* cpolicy) |
61 : job(cjob), policy(cpolicy) { | 63 : job(cjob), policy(cpolicy) { |
62 } | 64 } |
63 }; | 65 }; |
64 | 66 |
65 // Releases the Job and notifies the associated Policy object to its | 67 // Releases the Job and notifies the associated Policy object to its |
66 // resources as well. | 68 // resources as well. |
67 static void FreeResources(JobTracker* tracker); | 69 static void FreeResources(JobTracker* tracker); |
68 | 70 |
69 // The routine that the worker thread executes. It is in charge of | 71 // The routine that the worker thread executes. It is in charge of |
70 // notifications and cleanup-related tasks. | 72 // notifications and cleanup-related tasks. |
71 static DWORD WINAPI TargetEventsThread(PVOID param); | 73 static DWORD WINAPI TargetEventsThread(PVOID param); |
72 | 74 |
| 75 // Removes a target peer from the process list if it expires. |
| 76 static VOID CALLBACK RemovePeer(PVOID process, BOOLEAN); |
| 77 |
73 // The completion port used by the job objects to communicate events to | 78 // The completion port used by the job objects to communicate events to |
74 // the worker thread. | 79 // the worker thread. |
75 HANDLE job_port_; | 80 HANDLE job_port_; |
76 | 81 |
77 // Handle to a manual-reset event that is signaled when the total target | 82 // Handle to a manual-reset event that is signaled when the total target |
78 // process count reaches zero. | 83 // process count reaches zero. |
79 HANDLE no_targets_; | 84 HANDLE no_targets_; |
80 | 85 |
81 // Handle to the worker thread that reacts to job notifications. | 86 // Handle to the worker thread that reacts to job notifications. |
82 HANDLE job_thread_; | 87 HANDLE job_thread_; |
(...skipping 12 matching lines...) Expand all Loading... |
95 // Provides a fast lookup to identify sandboxed processes. | 100 // Provides a fast lookup to identify sandboxed processes. |
96 std::set<DWORD> child_process_ids_; | 101 std::set<DWORD> child_process_ids_; |
97 | 102 |
98 DISALLOW_COPY_AND_ASSIGN(BrokerServicesBase); | 103 DISALLOW_COPY_AND_ASSIGN(BrokerServicesBase); |
99 }; | 104 }; |
100 | 105 |
101 } // namespace sandbox | 106 } // namespace sandbox |
102 | 107 |
103 | 108 |
104 #endif // SANDBOX_SRC_BROKER_SERVICES_H__ | 109 #endif // SANDBOX_SRC_BROKER_SERVICES_H__ |
OLD | NEW |