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

Side by Side Diff: sandbox/src/broker_services.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/sandbox.gyp ('k') | sandbox/src/broker_services.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) 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
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 // Checks if the supplied process ID matches one of the broker's active
49 // target processes
50 // Returns:
51 // true if there is an active target process for this ID, otherwise false.
52 bool IsActiveTarget(DWORD process_id);
53
47 private: 54 private:
48 // Helper structure that allows the Broker to associate a job notification 55 // Helper structure that allows the Broker to associate a job notification
49 // with a job object and with a policy. 56 // with a job object and with a policy.
50 struct JobTracker { 57 struct JobTracker {
51 HANDLE job; 58 HANDLE job;
52 PolicyBase* policy; 59 PolicyBase* policy;
53 JobTracker(HANDLE cjob, PolicyBase* cpolicy) 60 JobTracker(HANDLE cjob, PolicyBase* cpolicy)
54 : job(cjob), policy(cpolicy) { 61 : job(cjob), policy(cpolicy) {
55 } 62 }
56 }; 63 };
(...skipping 21 matching lines...) Expand all
78 // threads at the same time. 85 // threads at the same time.
79 CRITICAL_SECTION lock_; 86 CRITICAL_SECTION lock_;
80 87
81 // provides a pool of threads that are used to wait on the IPC calls. 88 // provides a pool of threads that are used to wait on the IPC calls.
82 ThreadProvider* thread_pool_; 89 ThreadProvider* thread_pool_;
83 90
84 // List of the trackers for closing and cleanup purposes. 91 // List of the trackers for closing and cleanup purposes.
85 typedef std::list<JobTracker*> JobTrackerList; 92 typedef std::list<JobTracker*> JobTrackerList;
86 JobTrackerList tracker_list_; 93 JobTrackerList tracker_list_;
87 94
95 // Provides a fast lookup to identify sandboxed processes.
96 std::set<DWORD> child_process_ids_;
97
88 DISALLOW_COPY_AND_ASSIGN(BrokerServicesBase); 98 DISALLOW_COPY_AND_ASSIGN(BrokerServicesBase);
89 }; 99 };
90 100
91 } // namespace sandbox 101 } // namespace sandbox
92 102
93 103
94 #endif // SANDBOX_SRC_BROKER_SERVICES_H__ 104 #endif // SANDBOX_SRC_BROKER_SERVICES_H__
OLDNEW
« no previous file with comments | « sandbox/sandbox.gyp ('k') | sandbox/src/broker_services.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698