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

Side by Side Diff: sandbox/src/broker_services.cc

Issue 9960045: Add sandbox support for associating peer processes (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/src/broker_services.h ('k') | sandbox/src/handle_policy_test.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) 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
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
OLDNEW
« no previous file with comments | « sandbox/src/broker_services.h ('k') | sandbox/src/handle_policy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698