Chromium Code Reviews| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 | 239 |
| 240 void oom_killer_new() { | 240 void oom_killer_new() { |
| 241 TerminateBecauseOutOfMemory(0); | 241 TerminateBecauseOutOfMemory(0); |
| 242 } | 242 } |
| 243 | 243 |
| 244 #if !defined(ADDRESS_SANITIZER) | 244 #if !defined(ADDRESS_SANITIZER) |
| 245 | 245 |
| 246 // === Core Foundation CFAllocators === | 246 // === Core Foundation CFAllocators === |
| 247 | 247 |
| 248 bool CanGetContextForCFAllocator() { | 248 bool CanGetContextForCFAllocator() { |
| 249 return !base::mac::IsOSLaterThanYosemite_DontCallThis(); | 249 return !base::mac::IsOSLaterThanElCapitan_DontCallThis(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { | 252 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { |
| 253 if (base::mac::IsOSSnowLeopard()) { | 253 if (base::mac::IsOSSnowLeopard()) { |
| 254 ChromeCFAllocatorLeopards* our_allocator = | 254 ChromeCFAllocatorLeopards* our_allocator = |
| 255 const_cast<ChromeCFAllocatorLeopards*>( | 255 const_cast<ChromeCFAllocatorLeopards*>( |
| 256 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); | 256 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); |
| 257 return &our_allocator->_context; | 257 return &our_allocator->_context; |
| 258 } else if (base::mac::IsOSLion() || | 258 } else if (base::mac::IsOSLion() || |
| 259 base::mac::IsOSMountainLion() || | 259 base::mac::IsOSMountainLion() || |
| 260 base::mac::IsOSMavericks() || | 260 base::mac::IsOSMavericks() || |
| 261 base::mac::IsOSYosemite()) { | 261 base::mac::IsOSYosemite() || |
| 262 base::mac::IsOSElCapitan()) { | |
|
Robert Sesek
2015/07/15 21:44:45
This usually has to be manually verified by Avi.
Andre
2015/07/15 21:49:17
+Avi.
| |
| 262 ChromeCFAllocatorLions* our_allocator = | 263 ChromeCFAllocatorLions* our_allocator = |
| 263 const_cast<ChromeCFAllocatorLions*>( | 264 const_cast<ChromeCFAllocatorLions*>( |
| 264 reinterpret_cast<const ChromeCFAllocatorLions*>(allocator)); | 265 reinterpret_cast<const ChromeCFAllocatorLions*>(allocator)); |
| 265 return &our_allocator->_context; | 266 return &our_allocator->_context; |
| 266 } else { | 267 } else { |
| 267 return NULL; | 268 return NULL; |
| 268 } | 269 } |
| 269 } | 270 } |
| 270 | 271 |
| 271 CFAllocatorAllocateCallBack g_old_cfallocator_system_default; | 272 CFAllocatorAllocateCallBack g_old_cfallocator_system_default; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 @selector(allocWithZone:)); | 553 @selector(allocWithZone:)); |
| 553 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( | 554 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( |
| 554 method_getImplementation(orig_method)); | 555 method_getImplementation(orig_method)); |
| 555 CHECK(g_old_allocWithZone) | 556 CHECK(g_old_allocWithZone) |
| 556 << "Failed to get allocWithZone allocation function."; | 557 << "Failed to get allocWithZone allocation function."; |
| 557 method_setImplementation(orig_method, | 558 method_setImplementation(orig_method, |
| 558 reinterpret_cast<IMP>(oom_killer_allocWithZone)); | 559 reinterpret_cast<IMP>(oom_killer_allocWithZone)); |
| 559 } | 560 } |
| 560 | 561 |
| 561 } // namespace base | 562 } // namespace base |
| OLD | NEW |