Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file/namespace contains utility functions for enumerating, ending and | 5 // This file/namespace contains utility functions for enumerating, ending and |
| 6 // computing statistics of processes. | 6 // computing statistics of processes. |
| 7 | 7 |
| 8 #ifndef BASE_PROCESS_UTIL_H_ | 8 #ifndef BASE_PROCESS_UTIL_H_ |
| 9 #define BASE_PROCESS_UTIL_H_ | 9 #define BASE_PROCESS_UTIL_H_ |
| 10 | 10 |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 // Note: Returns true on Windows 2000 without doing anything. | 824 // Note: Returns true on Windows 2000 without doing anything. |
| 825 BASE_EXPORT bool EnableLowFragmentationHeap(); | 825 BASE_EXPORT bool EnableLowFragmentationHeap(); |
| 826 | 826 |
| 827 // Enables 'terminate on heap corruption' flag. Helps protect against heap | 827 // Enables 'terminate on heap corruption' flag. Helps protect against heap |
| 828 // overflow. Has no effect if the OS doesn't provide the necessary facility. | 828 // overflow. Has no effect if the OS doesn't provide the necessary facility. |
| 829 BASE_EXPORT void EnableTerminationOnHeapCorruption(); | 829 BASE_EXPORT void EnableTerminationOnHeapCorruption(); |
| 830 | 830 |
| 831 // Turns on process termination if memory runs out. | 831 // Turns on process termination if memory runs out. |
| 832 BASE_EXPORT void EnableTerminationOnOutOfMemory(); | 832 BASE_EXPORT void EnableTerminationOnOutOfMemory(); |
| 833 | 833 |
| 834 #if defined(OS_MACOSX) | |
| 835 // Exposed for testing. | |
| 836 BASE_EXPORT malloc_zone_t* GetPurgeableZone(); | |
| 837 #endif // defined(OS_MACOSX) | |
| 838 | |
| 839 // Enables stack dump to console output on exception and signals. | 834 // Enables stack dump to console output on exception and signals. |
| 840 // When enabled, the process will quit immediately. This is meant to be used in | 835 // When enabled, the process will quit immediately. This is meant to be used in |
| 841 // unit_tests only! This is not thread-safe: only call from main thread. | 836 // unit_tests only! This is not thread-safe: only call from main thread. |
| 842 BASE_EXPORT bool EnableInProcessStackDumping(); | 837 BASE_EXPORT bool EnableInProcessStackDumping(); |
| 843 | 838 |
| 844 // If supported on the platform, and the user has sufficent rights, increase | 839 // If supported on the platform, and the user has sufficent rights, increase |
| 845 // the current process's scheduling priority to a high priority. | 840 // the current process's scheduling priority to a high priority. |
| 846 BASE_EXPORT void RaiseProcessToHighPriority(); | 841 BASE_EXPORT void RaiseProcessToHighPriority(); |
| 847 | 842 |
| 848 #if defined(OS_MACOSX) | 843 #if defined(OS_MACOSX) |
| 849 // Restore the default exception handler, setting it to Apple Crash Reporter | 844 // Restore the default exception handler, setting it to Apple Crash Reporter |
| 850 // (ReportCrash). When forking and execing a new process, the child will | 845 // (ReportCrash). When forking and execing a new process, the child will |
| 851 // inherit the parent's exception ports, which may be set to the Breakpad | 846 // inherit the parent's exception ports, which may be set to the Breakpad |
| 852 // instance running inside the parent. The parent's Breakpad instance should | 847 // instance running inside the parent. The parent's Breakpad instance should |
| 853 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 848 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
| 854 // in the child after forking will restore the standard exception handler. | 849 // in the child after forking will restore the standard exception handler. |
| 855 // See http://crbug.com/20371/ for more details. | 850 // See http://crbug.com/20371/ for more details. |
| 856 void RestoreDefaultExceptionHandler(); | 851 void RestoreDefaultExceptionHandler(); |
| 857 #endif // defined(OS_MACOSX) | 852 #endif // defined(OS_MACOSX) |
| 858 | 853 |
| 854 #if defined(OS_MACOSX) | |
| 855 // Very large images or svg canvases can cause huge mallocs. Skia | |
| 856 // does tricks on tcmalloc-based systems to allow malloc to fail with | |
| 857 // a NULL rather than hit the oom crasher. This replicates that for | |
| 858 // OSX. | |
| 859 // | |
| 860 // IF YOU USE THIS WITHOUT CONSULTING YOUR FRIENDLY OSX DEVELOPER, | |
| 861 // YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU. | |
| 862 // | |
| 863 // TODO(shess): Weird place to put it, but this is where the OOM | |
| 864 // killer currently lives. | |
| 865 BASE_EXPORT void* unchecked_malloc(size_t size); | |
|
Robert Sesek
2012/09/13 23:18:15
I only wonder if this should be named UncheckedMal
Mark Mentovai
2012/09/17 18:28:11
UncheckedMalloc.
Or UnsafeUncheckedMalloc.
| |
| 866 #endif // defined(OS_MACOSX) | |
| 867 | |
| 859 } // namespace base | 868 } // namespace base |
| 860 | 869 |
| 861 #endif // BASE_PROCESS_UTIL_H_ | 870 #endif // BASE_PROCESS_UTIL_H_ |
| OLD | NEW |