summaryrefslogtreecommitdiffstats
path: root/sandbox/src/broker_services.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/src/broker_services.cc')
-rw-r--r--sandbox/src/broker_services.cc76
1 files changed, 2 insertions, 74 deletions
diff --git a/sandbox/src/broker_services.cc b/sandbox/src/broker_services.cc
index 2d8698b..d361c2e 100644
--- a/sandbox/src/broker_services.cc
+++ b/sandbox/src/broker_services.cc
@@ -45,25 +45,7 @@ enum {
THREAD_CTRL_LAST
};
-// Helper structure that allows the Broker to associate a job notification
-// with a job object and with a policy.
-struct JobTracker {
- HANDLE job;
- sandbox::PolicyBase* policy;
- JobTracker(HANDLE cjob, sandbox::PolicyBase* cpolicy)
- : job(cjob), policy(cpolicy) {
- }
-};
-
-// Helper structure that allows the broker to track peer processes
-struct PeerTracker {
- HANDLE wait_object_;
- base::win::ScopedHandle process_;
- PeerTracker() : wait_object_(NULL) {
- }
-};
-
-} // namespace
+}
namespace sandbox {
@@ -103,17 +85,6 @@ BrokerServicesBase::~BrokerServicesBase() {
// If there is no port Init() was never called successfully.
if (!job_port_)
return;
-
- { // Cancel the wait events for all the peers.
- AutoLock lock(&lock_);
- for (PeerTrackerMap::iterator it = peer_map_.begin();
- it != peer_map_.end(); ++it) {
- ::UnregisterWaitEx(it->second->wait_object_, NULL);
- delete it->second;
- }
- peer_map_.clear();
- }
-
// Closing the port causes, that no more Job notifications are delivered to
// the worker thread and also causes the thread to exit. This is what we
// want to do since we are going to close all outstanding Jobs and notifying
@@ -341,50 +312,7 @@ ResultCode BrokerServicesBase::WaitForAllTargets() {
bool BrokerServicesBase::IsActiveTarget(DWORD process_id) {
AutoLock lock(&lock_);
- return child_process_ids_.find(process_id) != child_process_ids_.end() ||
- peer_map_.find(process_id) != peer_map_.end();
-}
-
-VOID CALLBACK BrokerServicesBase::RemovePeerData(PVOID parameter, BOOLEAN) {
- DWORD process_id = reinterpret_cast<DWORD>(parameter);
- BrokerServicesBase* broker = BrokerServicesBase::GetInstance();
-
- AutoLock lock(&broker->lock_);
- PeerTrackerMap::iterator it = broker->peer_map_.find(process_id);
- // Failure means we're shutting down, and the destructor will clean up.
- if (::UnregisterWaitEx(it->second->wait_object_, NULL)) {
- broker->peer_map_.erase(it);
- delete it->second;
- }
-}
-
-ResultCode BrokerServicesBase::AddTargetPeer(HANDLE peer_process) {
- DWORD process_id = ::GetProcessId(peer_process);
- if (!process_id)
- return SBOX_ERROR_GENERIC;
-
- scoped_ptr<PeerTracker> peer(new PeerTracker);
- if (!::DuplicateHandle(::GetCurrentProcess(), peer_process,
- ::GetCurrentProcess(), peer->process_.Receive(),
- SYNCHRONIZE, FALSE, 0)) {
- return SBOX_ERROR_GENERIC;
- }
-
- AutoLock lock(&lock_);
- if (!peer_map_.insert(std::make_pair(process_id, peer.get())).second)
- return SBOX_ERROR_BAD_PARAMS;
-
- if (!::RegisterWaitForSingleObject(&peer->wait_object_,
- peer->process_, RemovePeerData,
- reinterpret_cast<void*>(process_id),
- INFINITE, WT_EXECUTEONLYONCE)) {
- peer_map_.erase(process_id);
- return SBOX_ERROR_GENERIC;
- }
-
- // Leak the pointer since it will be cleaned up by the callback.
- peer.release();
- return SBOX_ALL_OK;
+ return child_process_ids_.find(process_id) != child_process_ids_.end();
}
} // namespace sandbox