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

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

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
34 protected: 38 protected:
35 virtual ~DiscardableMemoryManagerAllocation() {} 39 virtual ~DiscardableMemoryManagerAllocation() {}
36 }; 40 };
37 41
38 } // namespace internal 42 } // namespace internal
39 } // namespace base 43 } // namespace base
40 44
41 namespace base { 45 namespace base {
42 namespace internal { 46 namespace internal {
43 47
(...skipping 17 matching lines...) Expand all
61 void SetMemoryLimit(size_t bytes); 65 void SetMemoryLimit(size_t bytes);
62 66
63 // The number of bytes of memory that may be allocated but unused for the hard 67 // The number of bytes of memory that may be allocated but unused for the hard
64 // limit expiration time without getting purged. 68 // limit expiration time without getting purged.
65 void SetSoftMemoryLimit(size_t bytes); 69 void SetSoftMemoryLimit(size_t bytes);
66 70
67 // Sets the memory usage cutoff time for hard memory limit. 71 // Sets the memory usage cutoff time for hard memory limit.
68 void SetHardMemoryLimitExpirationTime( 72 void SetHardMemoryLimitExpirationTime(
69 TimeDelta hard_memory_limit_expiration_time); 73 TimeDelta hard_memory_limit_expiration_time);
70 74
75 // This will make sure that all purged memory is released to the OS.
76 void ReleaseFreeMemory();
77
71 // This will attempt to reduce memory footprint until within soft memory 78 // This will attempt to reduce memory footprint until within soft memory
72 // limit. Returns true if there's no need to call this again until allocations 79 // limit. Returns true if there's no need to call this again until allocations
73 // have been used. 80 // have been used.
74 bool ReduceMemoryUsage(); 81 bool ReduceMemoryUsage();
75 82
76 // This can be called to attempt to reduce memory footprint until within 83 // This can be called to attempt to reduce memory footprint until within
77 // limit for bytes to keep under moderate pressure. 84 // limit for bytes to keep under moderate pressure.
78 void ReduceMemoryUsageUntilWithinLimit(size_t bytes); 85 void ReduceMemoryUsageUntilWithinLimit(size_t bytes);
79 86
80 // Adds the given allocation to the manager's collection. 87 // Adds the given allocation to the manager's collection.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // |soft_memory_limit_|. 164 // |soft_memory_limit_|.
158 TimeDelta hard_memory_limit_expiration_time_; 165 TimeDelta hard_memory_limit_expiration_time_;
159 166
160 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager); 167 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager);
161 }; 168 };
162 169
163 } // namespace internal 170 } // namespace internal
164 } // namespace base 171 } // namespace base
165 172
166 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ 173 #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