Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: base/process_util_mac.mm

Issue 9701031: Add preliminary OOM support for Mountain Lion. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweak comments Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/mac/mac_util_unittest.mm ('k') | base/process_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <errno.h> 10 #include <errno.h>
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 711
712 // === C++ operator new === 712 // === C++ operator new ===
713 713
714 void oom_killer_new() { 714 void oom_killer_new() {
715 debug::BreakDebugger(); 715 debug::BreakDebugger();
716 } 716 }
717 717
718 // === Core Foundation CFAllocators === 718 // === Core Foundation CFAllocators ===
719 719
720 bool CanGetContextForCFAllocator() { 720 bool CanGetContextForCFAllocator() {
721 // TODO(rsesek|avi): See mac_util.h:153 for removing/updating this. 721 // TODO(avi): remove at final release; http://crbug.com/117476
722 return !base::mac::IsOSLaterThanLion(); 722 if (base::mac::IsOSMountainLion()) {
723 NSLog(@"Unsure about the internals of CFAllocator but going to patch them "
724 "anyway. If there is a crash inside of CFAllocatorAllocate, please "
725 "report it at http://crbug.com/117476 . If there is a crash and it "
726 "is NOT inside of CFAllocatorAllocate, it is NOT RELATED. DO NOT "
727 "REPORT IT THERE but rather FILE A NEW BUG.");
728 }
729 return !base::mac::
730 IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement();
723 } 731 }
724 732
725 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { 733 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) {
726 if (base::mac::IsOSLeopard() || base::mac::IsOSSnowLeopard()) { 734 if (base::mac::IsOSLeopard() || base::mac::IsOSSnowLeopard()) {
727 ChromeCFAllocatorLeopards* our_allocator = 735 ChromeCFAllocatorLeopards* our_allocator =
728 const_cast<ChromeCFAllocatorLeopards*>( 736 const_cast<ChromeCFAllocatorLeopards*>(
729 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator)); 737 reinterpret_cast<const ChromeCFAllocatorLeopards*>(allocator));
730 return &our_allocator->_context; 738 return &our_allocator->_context;
731 } else if (base::mac::IsOSLion()) { 739 } else if (base::mac::IsOSLion() || base::mac::IsOSMountainLion()) {
732 ChromeCFAllocatorLion* our_allocator = 740 ChromeCFAllocatorLions* our_allocator =
733 const_cast<ChromeCFAllocatorLion*>( 741 const_cast<ChromeCFAllocatorLions*>(
734 reinterpret_cast<const ChromeCFAllocatorLion*>(allocator)); 742 reinterpret_cast<const ChromeCFAllocatorLions*>(allocator));
735 return &our_allocator->_context; 743 return &our_allocator->_context;
736 } else { 744 } else {
737 return NULL; 745 return NULL;
738 } 746 }
739 } 747 }
740 748
741 CFAllocatorAllocateCallBack g_old_cfallocator_system_default; 749 CFAllocatorAllocateCallBack g_old_cfallocator_system_default;
742 CFAllocatorAllocateCallBack g_old_cfallocator_malloc; 750 CFAllocatorAllocateCallBack g_old_cfallocator_malloc;
743 CFAllocatorAllocateCallBack g_old_cfallocator_malloc_zone; 751 CFAllocatorAllocateCallBack g_old_cfallocator_malloc_zone;
744 752
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } 1152 }
1145 } 1153 }
1146 1154
1147 } // namespace 1155 } // namespace
1148 1156
1149 void EnsureProcessTerminated(ProcessHandle process) { 1157 void EnsureProcessTerminated(ProcessHandle process) {
1150 WaitForChildToDie(process, kWaitBeforeKillSeconds); 1158 WaitForChildToDie(process, kWaitBeforeKillSeconds);
1151 } 1159 }
1152 1160
1153 } // namespace base 1161 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/mac_util_unittest.mm ('k') | base/process_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698