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

Side by Side Diff: base/process_util_mac.mm

Issue 11188003: Fix some potential Mach port leaks from mach_host_self using a new ScopedMachPort class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 8 years, 2 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 | « base/mac/scoped_mach_port.cc ('k') | base/sys_info_ios.mm » ('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 "base/process_util.h" 5 #include "base/process_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <crt_externs.h> 8 #include <crt_externs.h>
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 16 matching lines...) Expand all
27 #include <new> 27 #include <new>
28 #include <string> 28 #include <string>
29 29
30 #include "base/debug/debugger.h" 30 #include "base/debug/debugger.h"
31 #include "base/eintr_wrapper.h" 31 #include "base/eintr_wrapper.h"
32 #include "base/file_util.h" 32 #include "base/file_util.h"
33 #include "base/hash_tables.h" 33 #include "base/hash_tables.h"
34 #include "base/lazy_instance.h" 34 #include "base/lazy_instance.h"
35 #include "base/logging.h" 35 #include "base/logging.h"
36 #include "base/mac/mac_util.h" 36 #include "base/mac/mac_util.h"
37 #include "base/mac/scoped_mach_port.h"
37 #include "base/string_util.h" 38 #include "base/string_util.h"
38 #include "base/sys_info.h" 39 #include "base/sys_info.h"
39 #include "base/threading/thread_local.h" 40 #include "base/threading/thread_local.h"
40 #include "third_party/apple_apsl/CFBase.h" 41 #include "third_party/apple_apsl/CFBase.h"
41 #include "third_party/apple_apsl/malloc.h" 42 #include "third_party/apple_apsl/malloc.h"
42 #include "third_party/mach_override/mach_override.h" 43 #include "third_party/mach_override/mach_override.h"
43 44
44 namespace base { 45 namespace base {
45 46
46 void RestoreDefaultExceptionHandler() { 47 void RestoreDefaultExceptionHandler() {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 task = port_provider_->TaskForPid(process_); 462 task = port_provider_->TaskForPid(process_);
462 if (task == MACH_PORT_NULL && process_ == getpid()) 463 if (task == MACH_PORT_NULL && process_ == getpid())
463 task = mach_task_self(); 464 task = mach_task_self();
464 return task; 465 return task;
465 } 466 }
466 467
467 // ------------------------------------------------------------------------ 468 // ------------------------------------------------------------------------
468 469
469 // Bytes committed by the system. 470 // Bytes committed by the system.
470 size_t GetSystemCommitCharge() { 471 size_t GetSystemCommitCharge() {
471 host_name_port_t host = mach_host_self(); 472 base::mac::ScopedMachPort host(mach_host_self());
472 mach_msg_type_number_t count = HOST_VM_INFO_COUNT; 473 mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
473 vm_statistics_data_t data; 474 vm_statistics_data_t data;
474 kern_return_t kr = host_statistics(host, HOST_VM_INFO, 475 kern_return_t kr = host_statistics(host, HOST_VM_INFO,
475 reinterpret_cast<host_info_t>(&data), 476 reinterpret_cast<host_info_t>(&data),
476 &count); 477 &count);
477 if (kr) { 478 if (kr) {
478 DLOG(WARNING) << "Failed to fetch host statistics."; 479 DLOG(WARNING) << "Failed to fetch host statistics.";
479 return 0; 480 return 0;
480 } 481 }
481 482
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 } 1239 }
1239 } 1240 }
1240 1241
1241 } // namespace 1242 } // namespace
1242 1243
1243 void EnsureProcessTerminated(ProcessHandle process) { 1244 void EnsureProcessTerminated(ProcessHandle process) {
1244 WaitForChildToDie(process, kWaitBeforeKillSeconds); 1245 WaitForChildToDie(process, kWaitBeforeKillSeconds);
1245 } 1246 }
1246 1247
1247 } // namespace base 1248 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/scoped_mach_port.cc ('k') | base/sys_info_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698