| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ | 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ |
| 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ | 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/base_export.h" | 12 #include "base/base_export.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 class DiscardableMemory; | 15 class DiscardableMemory; |
| 15 | 16 |
| 16 class BASE_EXPORT DiscardableMemoryAllocator { | 17 class BASE_EXPORT DiscardableMemoryAllocator { |
| 17 public: | 18 public: |
| 18 // Returns the allocator instance. | 19 // Returns the allocator instance. |
| 19 static DiscardableMemoryAllocator* GetInstance(); | 20 static DiscardableMemoryAllocator* GetInstance(); |
| 20 | 21 |
| 21 // Sets the allocator instance. Can only be called once, e.g. on startup. | 22 // Sets the allocator instance. Can only be called once, e.g. on startup. |
| 22 // Ownership of |instance| remains with the caller. | 23 // Ownership of |instance| remains with the caller. |
| 23 static void SetInstance(DiscardableMemoryAllocator* allocator); | 24 static void SetInstance(DiscardableMemoryAllocator* allocator); |
| 24 | 25 |
| 25 virtual scoped_ptr<DiscardableMemory> AllocateLockedDiscardableMemory( | 26 virtual std::unique_ptr<DiscardableMemory> AllocateLockedDiscardableMemory( |
| 26 size_t size) = 0; | 27 size_t size) = 0; |
| 27 | 28 |
| 28 protected: | 29 protected: |
| 29 virtual ~DiscardableMemoryAllocator() {} | 30 virtual ~DiscardableMemoryAllocator() {} |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 } // namespace base | 33 } // namespace base |
| 33 | 34 |
| 34 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ | 35 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ |
| OLD | NEW |