Chromium Code Reviews| 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 #include "sandbox/src/broker_services.h" | 5 #include "sandbox/src/broker_services.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 ResultCode BrokerServicesBase::WaitForAllTargets() { | 308 ResultCode BrokerServicesBase::WaitForAllTargets() { |
| 309 ::WaitForSingleObject(no_targets_, INFINITE); | 309 ::WaitForSingleObject(no_targets_, INFINITE); |
| 310 return SBOX_ALL_OK; | 310 return SBOX_ALL_OK; |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool BrokerServicesBase::IsActiveTarget(DWORD process_id) { | 313 bool BrokerServicesBase::IsActiveTarget(DWORD process_id) { |
| 314 AutoLock lock(&lock_); | 314 AutoLock lock(&lock_); |
| 315 return child_process_ids_.find(process_id) != child_process_ids_.end(); | 315 return child_process_ids_.find(process_id) != child_process_ids_.end(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 VOID CALLBACK BrokerServicesBase::RemovePeer(PVOID process, BOOLEAN) { | |
| 319 DWORD process_id = ::GetProcessId(process); | |
| 320 BrokerServicesBase* broker = BrokerServicesBase::GetInstance(); | |
| 321 | |
| 322 AutoLock lock(&broker->lock_); | |
| 323 broker->child_process_ids_.erase(process_id); | |
| 324 CloseHandle(process); | |
| 325 } | |
| 326 | |
| 327 ResultCode BrokerServicesBase::AddTargetPeer(HANDLE peer_process) { | |
| 328 DWORD peer_id = ::GetProcessId(peer_process); | |
| 329 base::win::ScopedHandle peer_handle; | |
| 330 if (!peer_id || !::DuplicateHandle(::GetCurrentProcess(), peer_process, | |
| 331 ::GetCurrentProcess(), | |
| 332 peer_handle.Receive(), | |
| 333 SYNCHRONIZE | PROCESS_QUERY_INFORMATION, | |
| 334 FALSE, 0)) { | |
|
cpu_(ooo_6.6-7.5)
2012/04/09 23:17:40
UnregisterWaitEx with some magic params.
jschuh
2012/04/10 00:10:11
Done.
| |
| 335 return SBOX_ERROR_GENERIC; | |
| 336 } | |
| 337 | |
| 338 HANDLE timer; | |
|
cpu_(ooo_6.6-7.5)
2012/04/09 23:17:40
wait_object
jschuh
2012/04/10 00:10:11
Done.
| |
| 339 AutoLock lock(&lock_); | |
| 340 if (!::RegisterWaitForSingleObject(&timer, peer_handle, RemovePeer, | |
| 341 peer_handle, INFINITE, | |
| 342 WT_EXECUTEONLYONCE)) { | |
| 343 return SBOX_ERROR_GENERIC; | |
| 344 } | |
| 345 if (!child_process_ids_.insert(peer_id).second) { | |
| 346 ::CancelWaitableTimer(timer); | |
|
cpu_(ooo_6.6-7.5)
2012/04/09 23:17:40
UnregisterWait
jschuh
2012/04/10 00:10:11
Done.
| |
| 347 return SBOX_ERROR_BAD_PARAMS; | |
| 348 } | |
| 349 | |
| 350 // Leak the handle because it gets closed by the callback. | |
| 351 peer_handle.Take(); | |
| 352 return SBOX_ALL_OK; | |
| 353 } | |
| 354 | |
| 318 } // namespace sandbox | 355 } // namespace sandbox |
| OLD | NEW |