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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 // === C++ operator new === | 429 // === C++ operator new === |
430 | 430 |
431 void oom_killer_new() { | 431 void oom_killer_new() { |
432 debug::BreakDebugger(); | 432 debug::BreakDebugger(); |
433 } | 433 } |
434 | 434 |
435 // === Core Foundation CFAllocators === | 435 // === Core Foundation CFAllocators === |
436 | 436 |
437 bool CanGetContextForCFAllocator() { | 437 bool CanGetContextForCFAllocator() { |
438 return !base::mac::IsOSLaterThanMavericks_DontCallThis(); | 438 return !base::mac::IsOSYosemiteOrLater(); |
439 } | 439 } |
440 | 440 |
441 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { | 441 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { |
442 if (base::mac::IsOSSnowLeopard()) { | 442 if (base::mac::IsOSSnowLeopard()) { |
443 ChromeCFAllocatorLeopards* our_allocator = | 443 ChromeCFAllocatorLeopards* our_allocator = |
444 const_cast<ChromeCFAllocatorLeopards*>( | 444 const_cast<ChromeCFAllocatorLeopards*>( |
445 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); | 445 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); |
446 return &our_allocator->_context; | 446 return &our_allocator->_context; |
447 } else if (base::mac::IsOSLion() || | 447 } else if (base::mac::IsOSLion() || |
448 base::mac::IsOSMountainLion() || | 448 base::mac::IsOSMountainLion() || |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 @selector(allocWithZone:)); | 737 @selector(allocWithZone:)); |
738 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( | 738 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( |
739 method_getImplementation(orig_method)); | 739 method_getImplementation(orig_method)); |
740 CHECK(g_old_allocWithZone) | 740 CHECK(g_old_allocWithZone) |
741 << "Failed to get allocWithZone allocation function."; | 741 << "Failed to get allocWithZone allocation function."; |
742 method_setImplementation(orig_method, | 742 method_setImplementation(orig_method, |
743 reinterpret_cast<IMP>(oom_killer_allocWithZone)); | 743 reinterpret_cast<IMP>(oom_killer_allocWithZone)); |
744 } | 744 } |
745 | 745 |
746 } // namespace base | 746 } // namespace base |
OLD | NEW |