OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <mach/mach.h> | 10 #include <mach/mach.h> |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 615 |
616 // === C++ operator new === | 616 // === C++ operator new === |
617 | 617 |
618 void oom_killer_new() { | 618 void oom_killer_new() { |
619 debug::BreakDebugger(); | 619 debug::BreakDebugger(); |
620 } | 620 } |
621 | 621 |
622 // === Core Foundation CFAllocators === | 622 // === Core Foundation CFAllocators === |
623 | 623 |
624 bool CanGetContextForCFAllocator() { | 624 bool CanGetContextForCFAllocator() { |
625 // TODO(avi): remove at final release; http://crbug.com/74589 | |
626 if (base::mac::IsOSLion()) { | |
627 NSLog(@"Unsure about the internals of CFAllocator but going to patch them " | |
628 "anyway. Watch out for crashes inside of CFAllocatorAllocate."); | |
629 } | |
630 return !base::mac::IsOSLaterThanLion(); | 625 return !base::mac::IsOSLaterThanLion(); |
631 } | 626 } |
632 | 627 |
633 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { | 628 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { |
634 if (base::mac::IsOSLeopard() || base::mac::IsOSSnowLeopard()) { | 629 if (base::mac::IsOSLeopard() || base::mac::IsOSSnowLeopard()) { |
635 ChromeCFAllocatorLeopards* our_allocator = | 630 ChromeCFAllocatorLeopards* our_allocator = |
636 const_cast<ChromeCFAllocatorLeopards*>( | 631 const_cast<ChromeCFAllocatorLeopards*>( |
637 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); | 632 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); |
638 return &our_allocator->_context; | 633 return &our_allocator->_context; |
639 } else if (base::mac::IsOSLion()) { | 634 } else if (base::mac::IsOSLion()) { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 if (sysctl(mib, 4, &info, &length, NULL, 0) < 0) { | 892 if (sysctl(mib, 4, &info, &length, NULL, 0) < 0) { |
898 PLOG(ERROR) << "sysctl"; | 893 PLOG(ERROR) << "sysctl"; |
899 return -1; | 894 return -1; |
900 } | 895 } |
901 if (length == 0) | 896 if (length == 0) |
902 return -1; | 897 return -1; |
903 return info.kp_eproc.e_ppid; | 898 return info.kp_eproc.e_ppid; |
904 } | 899 } |
905 | 900 |
906 } // namespace base | 901 } // namespace base |
OLD | NEW |