Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: base/memory/discardable_memory_manager.h

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/memory/discardable_memory_mach.cc ('k') | base/memory/discardable_memory_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MANAGER_H_ 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/containers/mru_cache.h" 10 #include "base/containers/mru_cache.h"
(...skipping 13 matching lines...) Expand all
24 virtual bool AllocateAndAcquireLock() = 0; 24 virtual bool AllocateAndAcquireLock() = 0;
25 25
26 // Release a previously acquired lock on the allocation so that it can be 26 // Release a previously acquired lock on the allocation so that it can be
27 // purged by the system. 27 // purged by the system.
28 virtual void ReleaseLock() = 0; 28 virtual void ReleaseLock() = 0;
29 29
30 // Explicitly purge this allocation. It is illegal to call this while a lock 30 // Explicitly purge this allocation. It is illegal to call this while a lock
31 // is acquired on the allocation. 31 // is acquired on the allocation.
32 virtual void Purge() = 0; 32 virtual void Purge() = 0;
33 33
34 // Check if allocated memory is still resident. It is illegal to call this
35 // while a lock is acquired on the allocation.
36 virtual bool IsMemoryResident() const = 0;
37
38 protected: 34 protected:
39 virtual ~DiscardableMemoryManagerAllocation() {} 35 virtual ~DiscardableMemoryManagerAllocation() {}
40 }; 36 };
41 37
42 } // namespace internal 38 } // namespace internal
43 } // namespace base 39 } // namespace base
44 40
45 namespace base { 41 namespace base {
46 namespace internal { 42 namespace internal {
47 43
(...skipping 17 matching lines...) Expand all
65 void SetMemoryLimit(size_t bytes); 61 void SetMemoryLimit(size_t bytes);
66 62
67 // The number of bytes of memory that may be allocated but unused for the hard 63 // The number of bytes of memory that may be allocated but unused for the hard
68 // limit expiration time without getting purged. 64 // limit expiration time without getting purged.
69 void SetSoftMemoryLimit(size_t bytes); 65 void SetSoftMemoryLimit(size_t bytes);
70 66
71 // Sets the memory usage cutoff time for hard memory limit. 67 // Sets the memory usage cutoff time for hard memory limit.
72 void SetHardMemoryLimitExpirationTime( 68 void SetHardMemoryLimitExpirationTime(
73 TimeDelta hard_memory_limit_expiration_time); 69 TimeDelta hard_memory_limit_expiration_time);
74 70
75 // This will make sure that all purged memory is released to the OS.
76 void ReleaseFreeMemory();
77
78 // This will attempt to reduce memory footprint until within soft memory 71 // This will attempt to reduce memory footprint until within soft memory
79 // limit. Returns true if there's no need to call this again until allocations 72 // limit. Returns true if there's no need to call this again until allocations
80 // have been used. 73 // have been used.
81 bool ReduceMemoryUsage(); 74 bool ReduceMemoryUsage();
82 75
83 // This can be called to attempt to reduce memory footprint until within 76 // This can be called to attempt to reduce memory footprint until within
84 // limit for bytes to keep under moderate pressure. 77 // limit for bytes to keep under moderate pressure.
85 void ReduceMemoryUsageUntilWithinLimit(size_t bytes); 78 void ReduceMemoryUsageUntilWithinLimit(size_t bytes);
86 79
87 // Adds the given allocation to the manager's collection. 80 // Adds the given allocation to the manager's collection.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // |soft_memory_limit_|. 157 // |soft_memory_limit_|.
165 TimeDelta hard_memory_limit_expiration_time_; 158 TimeDelta hard_memory_limit_expiration_time_;
166 159
167 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager); 160 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager);
168 }; 161 };
169 162
170 } // namespace internal 163 } // namespace internal
171 } // namespace base 164 } // namespace base
172 165
173 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ 166 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_mach.cc ('k') | base/memory/discardable_memory_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698