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_SHMEM_H_ | 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_ |
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_ | 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_ |
7 | 7 |
8 #include "base/memory/discardable_memory.h" | 8 #include "base/memory/discardable_memory.h" |
9 | 9 |
10 #include "base/memory/discardable_memory_manager.h" | 10 #include "base/memory/discardable_memory_manager.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class DiscardableSharedMemory; | 13 class DiscardableSharedMemory; |
14 | 14 |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 class DiscardableMemoryShmem | 17 class DiscardableMemoryShmem |
18 : public DiscardableMemory, | 18 : public DiscardableMemory, |
19 public internal::DiscardableMemoryManagerAllocation { | 19 public internal::DiscardableMemoryManagerAllocation { |
20 public: | 20 public: |
21 explicit DiscardableMemoryShmem(size_t bytes); | 21 explicit DiscardableMemoryShmem(size_t bytes); |
22 virtual ~DiscardableMemoryShmem(); | 22 ~DiscardableMemoryShmem() override; |
23 | 23 |
24 static void ReleaseFreeMemory(); | 24 static void ReleaseFreeMemory(); |
25 | 25 |
26 static void PurgeForTesting(); | 26 static void PurgeForTesting(); |
27 | 27 |
28 bool Initialize(); | 28 bool Initialize(); |
29 | 29 |
30 // Overridden from DiscardableMemory: | 30 // Overridden from DiscardableMemory: |
31 virtual DiscardableMemoryLockStatus Lock() override; | 31 DiscardableMemoryLockStatus Lock() override; |
32 virtual void Unlock() override; | 32 void Unlock() override; |
33 virtual void* Memory() const override; | 33 void* Memory() const override; |
34 | 34 |
35 // Overridden from internal::DiscardableMemoryManagerAllocation: | 35 // Overridden from internal::DiscardableMemoryManagerAllocation: |
36 virtual bool AllocateAndAcquireLock() override; | 36 bool AllocateAndAcquireLock() override; |
37 virtual void ReleaseLock() override; | 37 void ReleaseLock() override; |
38 virtual void Purge() override; | 38 void Purge() override; |
39 virtual bool IsMemoryResident() const override; | 39 bool IsMemoryResident() const override; |
40 | 40 |
41 private: | 41 private: |
42 const size_t bytes_; | 42 const size_t bytes_; |
43 scoped_ptr<DiscardableSharedMemory> shared_memory_; | 43 scoped_ptr<DiscardableSharedMemory> shared_memory_; |
44 bool is_locked_; | 44 bool is_locked_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryShmem); | 46 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryShmem); |
47 }; | 47 }; |
48 | 48 |
49 } // namespace internal | 49 } // namespace internal |
50 } // namespace base | 50 } // namespace base |
51 | 51 |
52 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_ | 52 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_SHMEM_H_ |
OLD | NEW |