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

Unified Diff: base/memory/discardable_memory_manager.h

Issue 448173002: Re-land: base: Introduce an explicit call for reducing emulated discardable memory usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable EmulatedDiscardableMemoryDiscardedWhenWidgetsHidden with lsan Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/discardable_memory_mac.cc ('k') | base/memory/discardable_memory_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_memory_manager.h
diff --git a/base/memory/discardable_memory_manager.h b/base/memory/discardable_memory_manager.h
index a61f141c43034ecb5f1cfcec5033b8d431d884d8..94b3c55108f22715b0afcbfca019ffe92b357e9f 100644
--- a/base/memory/discardable_memory_manager.h
+++ b/base/memory/discardable_memory_manager.h
@@ -8,7 +8,6 @@
#include "base/base_export.h"
#include "base/containers/hash_tables.h"
#include "base/containers/mru_cache.h"
-#include "base/memory/memory_pressure_listener.h"
#include "base/synchronization/lock.h"
#include "base/time/time.h"
@@ -60,27 +59,15 @@ namespace internal {
// of all allocation instances (in case they need to be purged), and the total
// amount of allocated memory (in case this forces a purge). When memory usage
// reaches the limit, the manager purges the LRU memory.
-//
-// When notified of memory pressure, the manager either purges the LRU memory --
-// if the pressure is moderate -- or all discardable memory if the pressure is
-// critical.
class BASE_EXPORT_PRIVATE DiscardableMemoryManager {
public:
typedef DiscardableMemoryManagerAllocation Allocation;
DiscardableMemoryManager(size_t memory_limit,
size_t soft_memory_limit,
- size_t bytes_to_keep_under_moderate_pressure,
TimeDelta hard_memory_limit_expiration_time);
virtual ~DiscardableMemoryManager();
- // Call this to register memory pressure listener. Must be called on a thread
- // with a MessageLoop current.
- void RegisterMemoryPressureListener();
-
- // Call this to unregister memory pressure listener.
- void UnregisterMemoryPressureListener();
-
// The maximum number of bytes of memory that may be allocated before we force
// a purge.
void SetMemoryLimit(size_t bytes);
@@ -89,9 +76,6 @@ class BASE_EXPORT_PRIVATE DiscardableMemoryManager {
// limit expiration time without getting purged.
void SetSoftMemoryLimit(size_t bytes);
- // Sets the amount of memory to keep when we're under moderate pressure.
- void SetBytesToKeepUnderModeratePressure(size_t bytes);
-
// Sets the memory usage cutoff time for hard memory limit.
void SetHardMemoryLimitExpirationTime(
TimeDelta hard_memory_limit_expiration_time);
@@ -101,6 +85,10 @@ class BASE_EXPORT_PRIVATE DiscardableMemoryManager {
// have been used.
bool ReduceMemoryUsage();
+ // This can be called to attempt to reduce memory footprint until within
+ // limit for bytes to keep under moderate pressure.
+ void ReduceMemoryUsageUntilWithinLimit(size_t bytes);
+
// Adds the given allocation to the manager's collection.
void Register(Allocation* allocation, size_t bytes);
@@ -141,14 +129,6 @@ class BASE_EXPORT_PRIVATE DiscardableMemoryManager {
};
typedef HashingMRUCache<Allocation*, AllocationInfo> AllocationMap;
- // This can be called as a hint that the system is under memory pressure.
- void OnMemoryPressure(
- MemoryPressureListener::MemoryPressureLevel pressure_level);
-
- // Purges memory until usage is less or equal to
- // |bytes_to_keep_under_moderate_pressure_|.
- void PurgeUntilWithinBytesToKeepUnderModeratePressure();
-
// Purges memory not used since |hard_memory_limit_expiration_time_| before
// "right now" until usage is less or equal to |soft_memory_limit_|.
// Returns true if total amount of memory is less or equal to soft memory
@@ -185,14 +165,6 @@ class BASE_EXPORT_PRIVATE DiscardableMemoryManager {
// notification.
size_t soft_memory_limit_;
- // Under moderate memory pressure, we will purge memory until usage is within
- // this limit.
- size_t bytes_to_keep_under_moderate_pressure_;
-
- // Allows us to be respond when the system reports that it is under memory
- // pressure.
- scoped_ptr<MemoryPressureListener> memory_pressure_listener_;
-
// Amount of time it takes for an allocation to become affected by
// |soft_memory_limit_|.
TimeDelta hard_memory_limit_expiration_time_;
« no previous file with comments | « base/memory/discardable_memory_mac.cc ('k') | base/memory/discardable_memory_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698