Infer appropriate GNU_STACK alignment for a shared library.
[chromium-blink-merge.git] / base / memory / discardable_memory_ashmem.h
blob100655beff5ccba46a3a6fde1c7cae4ed13fb60a
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"
13 namespace base {
14 namespace internal {
16 class DiscardableAshmemChunk;
17 class DiscardableMemoryAshmemAllocator;
18 class DiscardableMemoryManager;
20 class DiscardableMemoryAshmem
21 : public DiscardableMemory,
22 public internal::DiscardableMemoryManagerAllocation {
23 public:
24 explicit DiscardableMemoryAshmem(size_t bytes,
25 DiscardableMemoryAshmemAllocator* allocator,
26 DiscardableMemoryManager* manager);
28 ~DiscardableMemoryAshmem() override;
30 bool Initialize();
32 // Overridden from DiscardableMemory:
33 DiscardableMemoryLockStatus Lock() override;
34 void Unlock() override;
35 void* Memory() const override;
37 // Overridden from internal::DiscardableMemoryManagerAllocation:
38 bool AllocateAndAcquireLock() override;
39 void ReleaseLock() override;
40 void Purge() override;
41 bool IsMemoryResident() const override;
43 private:
44 const size_t bytes_;
45 DiscardableMemoryAshmemAllocator* const allocator_;
46 DiscardableMemoryManager* const manager_;
47 bool is_locked_;
48 scoped_ptr<DiscardableAshmemChunk> ashmem_chunk_;
50 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryAshmem);
53 } // namespace internal
54 } // namespace base
56 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ASHMEM_H_