OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MALLOC_H_ | 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_ |
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_MALLOC_H_ | 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_ |
7 | 7 |
8 #include "base/memory/discardable_memory.h" | 8 #include "base/memory/discardable_memory.h" |
9 | 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/discardable_memory_manager.h" |
| 13 |
10 namespace base { | 14 namespace base { |
11 namespace internal { | 15 namespace internal { |
12 | 16 |
13 class DiscardableMemoryMalloc : public DiscardableMemory { | 17 class DiscardableMemoryAshmem : public DiscardableMemory { |
14 public: | 18 public: |
15 explicit DiscardableMemoryMalloc(size_t size); | 19 DiscardableMemoryAshmem(DiscardableMemoryManager* manager, size_t size); |
16 virtual ~DiscardableMemoryMalloc(); | 20 virtual ~DiscardableMemoryAshmem(); |
17 | 21 |
18 bool Initialize(); | 22 bool Initialize(); |
19 | 23 |
20 // Overridden from DiscardableMemory: | 24 // DiscardableMemory: |
21 virtual DiscardableMemoryLockStatus Lock() OVERRIDE; | 25 virtual DiscardableMemoryLockStatus Lock() OVERRIDE; |
22 virtual void Unlock() OVERRIDE; | 26 virtual void Unlock() OVERRIDE; |
23 virtual void* Memory() const OVERRIDE; | 27 virtual void* Memory() const OVERRIDE; |
24 | 28 |
25 private: | 29 private: |
26 scoped_ptr<uint8, FreeDeleter> memory_; | 30 DiscardableMemoryManager* const manager_; |
27 const size_t size_; | 31 const DiscardableMemoryManager::AllocationId allocation_id_; |
| 32 void* memory_; |
28 | 33 |
29 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryMalloc); | 34 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryAshmem); |
30 }; | 35 }; |
31 | 36 |
32 } // namespace internal | 37 } // namespace internal |
33 } // namespace base | 38 } // namespace base |
34 | 39 |
35 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MALLOC_H_ | 40 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_ |
OLD | NEW |