partition_oom.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // Holds functions for generating OOM errors from PartitionAlloc. This is
  5. // distinct from oom.h in that it is meant only for use in PartitionAlloc.
  6. #ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_OOM_H_
  7. #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_OOM_H_
  8. #include <stddef.h>
  9. #include "base/allocator/partition_allocator/partition_alloc_base/compiler_specific.h"
  10. #include "base/allocator/partition_allocator/partition_alloc_base/component_export.h"
  11. #include "build/build_config.h"
  12. namespace partition_alloc {
  13. using OomFunction = void (*)(size_t);
  14. namespace internal {
  15. // g_oom_handling_function is invoked when PartitionAlloc hits OutOfMemory.
  16. extern OomFunction g_oom_handling_function;
  17. [[noreturn]] PA_COMPONENT_EXPORT(PARTITION_ALLOC) PA_NOINLINE
  18. void PartitionExcessiveAllocationSize(size_t size);
  19. #if !defined(ARCH_CPU_64_BITS)
  20. [[noreturn]] PA_NOINLINE void PartitionOutOfMemoryWithLotsOfUncommitedPages(
  21. size_t size);
  22. [[noreturn]] PA_NOINLINE void PartitionOutOfMemoryWithLargeVirtualSize(
  23. size_t virtual_size);
  24. #endif
  25. } // namespace internal
  26. } // namespace partition_alloc
  27. #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_OOM_H_