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
3 // found in the LICENSE file.
5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_
8 #include "base/memory/discardable_memory.h"
10 #include "base/macros.h"
11 #include "base/memory/discardable_memory_manager.h"
16 class DiscardableAshmemChunk
;
17 class DiscardableMemoryAshmemAllocator
;
18 class DiscardableMemoryManager
;
20 class DiscardableMemoryAshmem
21 : public DiscardableMemory
,
22 public internal::DiscardableMemoryManagerAllocation
{
24 explicit DiscardableMemoryAshmem(size_t bytes
,
25 DiscardableMemoryAshmemAllocator
* allocator
,
26 DiscardableMemoryManager
* manager
);
28 virtual ~DiscardableMemoryAshmem();
32 // Overridden from DiscardableMemory:
33 virtual DiscardableMemoryLockStatus
Lock() OVERRIDE
;
34 virtual void Unlock() OVERRIDE
;
35 virtual void* Memory() const OVERRIDE
;
37 // Overridden from internal::DiscardableMemoryManagerAllocation:
38 virtual bool AllocateAndAcquireLock() OVERRIDE
;
39 virtual void ReleaseLock() OVERRIDE
;
40 virtual void Purge() OVERRIDE
;
44 DiscardableMemoryAshmemAllocator
* const allocator_
;
45 DiscardableMemoryManager
* const manager_
;
47 scoped_ptr
<DiscardableAshmemChunk
> ashmem_chunk_
;
49 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryAshmem
);
52 } // namespace internal
55 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_