• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 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 
5 #ifndef BASE_TEST_TEST_DISCARDABLE_MEMORY_ALLOCATOR_H_
6 #define BASE_TEST_TEST_DISCARDABLE_MEMORY_ALLOCATOR_H_
7 
8 #include <stddef.h>
9 
10 #include "base/macros.h"
11 #include "base/memory/discardable_memory_allocator.h"
12 
13 namespace base {
14 
15 // TestDiscardableMemoryAllocator is a simple DiscardableMemoryAllocator
16 // implementation that can be used for testing. It allocates one-shot
17 // DiscardableMemory instances backed by heap memory.
18 class TestDiscardableMemoryAllocator : public DiscardableMemoryAllocator {
19  public:
20   constexpr TestDiscardableMemoryAllocator() = default;
21 
22   // Overridden from DiscardableMemoryAllocator:
23   std::unique_ptr<DiscardableMemory> AllocateLockedDiscardableMemory(
24       size_t size) override;
25 
26  private:
27   DISALLOW_COPY_AND_ASSIGN(TestDiscardableMemoryAllocator);
28 };
29 
30 }  // namespace base
31 
32 #endif  // BASE_TEST_TEST_DISCARDABLE_MEMORY_ALLOCATOR_H_
33