OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/memory.h" | 5 #include "base/process/memory.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <mach/mach.h> | 9 #include <mach/mach.h> |
10 #include <mach/mach_vm.h> | 10 #include <mach/mach_vm.h> |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 431 |
432 // === C++ operator new === | 432 // === C++ operator new === |
433 | 433 |
434 void oom_killer_new() { | 434 void oom_killer_new() { |
435 debug::BreakDebugger(); | 435 debug::BreakDebugger(); |
436 } | 436 } |
437 | 437 |
438 // === Core Foundation CFAllocators === | 438 // === Core Foundation CFAllocators === |
439 | 439 |
440 bool CanGetContextForCFAllocator() { | 440 bool CanGetContextForCFAllocator() { |
441 return !base::mac::IsOSLaterThanMavericks_DontCallThis(); | 441 return !base::mac::IsOSYosemiteOrLater(); |
442 } | 442 } |
443 | 443 |
444 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { | 444 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { |
445 if (base::mac::IsOSSnowLeopard()) { | 445 if (base::mac::IsOSSnowLeopard()) { |
446 ChromeCFAllocatorLeopards* our_allocator = | 446 ChromeCFAllocatorLeopards* our_allocator = |
447 const_cast<ChromeCFAllocatorLeopards*>( | 447 const_cast<ChromeCFAllocatorLeopards*>( |
448 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); | 448 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); |
449 return &our_allocator->_context; | 449 return &our_allocator->_context; |
450 } else if (base::mac::IsOSLion() || | 450 } else if (base::mac::IsOSLion() || |
451 base::mac::IsOSMountainLion() || | 451 base::mac::IsOSMountainLion() || |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 @selector(allocWithZone:)); | 740 @selector(allocWithZone:)); |
741 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( | 741 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( |
742 method_getImplementation(orig_method)); | 742 method_getImplementation(orig_method)); |
743 CHECK(g_old_allocWithZone) | 743 CHECK(g_old_allocWithZone) |
744 << "Failed to get allocWithZone allocation function."; | 744 << "Failed to get allocWithZone allocation function."; |
745 method_setImplementation(orig_method, | 745 method_setImplementation(orig_method, |
746 reinterpret_cast<IMP>(oom_killer_allocWithZone)); | 746 reinterpret_cast<IMP>(oom_killer_allocWithZone)); |
747 } | 747 } |
748 | 748 |
749 } // namespace base | 749 } // namespace base |
OLD | NEW |