OLD | NEW |
| (Empty) |
1 // Copyright 2013 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. | |
4 | |
5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ | |
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ | |
7 | |
8 #include "base/memory/discardable_memory.h" | |
9 | |
10 #include "base/memory/discardable_memory_manager.h" | |
11 | |
12 namespace base { | |
13 namespace internal { | |
14 | |
15 class DiscardableMemoryEmulated | |
16 : public DiscardableMemory, | |
17 public internal::DiscardableMemoryManagerAllocation { | |
18 public: | |
19 explicit DiscardableMemoryEmulated(size_t bytes); | |
20 ~DiscardableMemoryEmulated() override; | |
21 | |
22 static bool ReduceMemoryUsage(); | |
23 | |
24 // TODO(reveman): Remove this as it is breaking the discardable memory design | |
25 // principle that implementations should not rely on information this is | |
26 // unavailable in kernel space. crbug.com/400423 | |
27 BASE_EXPORT static void ReduceMemoryUsageUntilWithinLimit(size_t bytes); | |
28 | |
29 bool Initialize(); | |
30 | |
31 // Overridden from DiscardableMemory: | |
32 DiscardableMemoryLockStatus Lock() override; | |
33 void Unlock() override; | |
34 void* Memory() const override; | |
35 | |
36 // Overridden from internal::DiscardableMemoryManagerAllocation: | |
37 bool AllocateAndAcquireLock() override; | |
38 void ReleaseLock() override {} | |
39 void Purge() override; | |
40 | |
41 private: | |
42 const size_t bytes_; | |
43 scoped_ptr<uint8[]> memory_; | |
44 bool is_locked_; | |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryEmulated); | |
47 }; | |
48 | |
49 } // namespace internal | |
50 } // namespace base | |
51 | |
52 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_EMULATED_H_ | |
OLD | NEW |