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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 | 415 |
416 // === C++ operator new === | 416 // === C++ operator new === |
417 | 417 |
418 void oom_killer_new() { | 418 void oom_killer_new() { |
419 debug::BreakDebugger(); | 419 debug::BreakDebugger(); |
420 } | 420 } |
421 | 421 |
422 // === Core Foundation CFAllocators === | 422 // === Core Foundation CFAllocators === |
423 | 423 |
424 bool CanGetContextForCFAllocator() { | 424 bool CanGetContextForCFAllocator() { |
425 return !base::mac::IsOSLaterThanMountainLion_DontCallThis(); | 425 return !base::mac::IsOSMavericksOrLater(); |
426 } | 426 } |
427 | 427 |
428 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { | 428 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { |
429 if (base::mac::IsOSSnowLeopard()) { | 429 if (base::mac::IsOSSnowLeopard()) { |
430 ChromeCFAllocatorLeopards* our_allocator = | 430 ChromeCFAllocatorLeopards* our_allocator = |
431 const_cast<ChromeCFAllocatorLeopards*>( | 431 const_cast<ChromeCFAllocatorLeopards*>( |
432 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); | 432 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); |
433 return &our_allocator->_context; | 433 return &our_allocator->_context; |
434 } else if (base::mac::IsOSLion() || base::mac::IsOSMountainLion()) { | 434 } else if (base::mac::IsOSLion() || base::mac::IsOSMountainLion()) { |
435 ChromeCFAllocatorLions* our_allocator = | 435 ChromeCFAllocatorLions* our_allocator = |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 @selector(allocWithZone:)); | 695 @selector(allocWithZone:)); |
696 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( | 696 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( |
697 method_getImplementation(orig_method)); | 697 method_getImplementation(orig_method)); |
698 CHECK(g_old_allocWithZone) | 698 CHECK(g_old_allocWithZone) |
699 << "Failed to get allocWithZone allocation function."; | 699 << "Failed to get allocWithZone allocation function."; |
700 method_setImplementation(orig_method, | 700 method_setImplementation(orig_method, |
701 reinterpret_cast<IMP>(oom_killer_allocWithZone)); | 701 reinterpret_cast<IMP>(oom_killer_allocWithZone)); |
702 } | 702 } |
703 | 703 |
704 } // namespace base | 704 } // namespace base |
OLD | NEW |