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

Unified Diff: base/chromeos/memory_pressure_observer_chromeos.h

Issue 863253002: Update from https://crrev.com/312600 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
Index: base/chromeos/memory_pressure_observer_chromeos.h
diff --git a/base/chromeos/memory_pressure_observer_chromeos.h b/base/chromeos/memory_pressure_observer_chromeos.h
index 23b6b3450d8cf2f9ef7f907be1aab144b69ff58f..739b795067e4e7202716760c5882b205a014a55b 100644
--- a/base/chromeos/memory_pressure_observer_chromeos.h
+++ b/base/chromeos/memory_pressure_observer_chromeos.h
@@ -27,7 +27,27 @@ class BASE_EXPORT MemoryPressureObserverChromeOS {
public:
using GetUsedMemoryInPercentCallback = int (*)();
- MemoryPressureObserverChromeOS();
+ // There are two memory pressure events:
+ // MODERATE - which will mainly release caches.
+ // CRITICAL - which will discard tabs.
+ // The |MemoryPressureThresholds| enum selects the strategy of firing these
+ // events: A conservative strategy will keep as much content in memory as
+ // possible (causing the system to swap to zram) and an aggressive strategy
+ // will release memory earlier to avoid swapping.
+ enum MemoryPressureThresholds {
+ // Use the system default.
+ THRESHOLD_DEFAULT = 0,
+ // Try to keep as much content in memory as possible.
+ THRESHOLD_CONSERVATIVE = 1,
+ // Discard caches earlier, allowing to keep more tabs in memory.
+ THRESHOLD_AGGRESSIVE_CACHE_DISCARD = 2,
+ // Discard tabs earlier, allowing the system to get faster.
+ THRESHOLD_AGGRESSIVE_TAB_DISCARD = 3,
+ // Discard caches and tabs earlier to allow the system to be faster.
+ THRESHOLD_AGGRESSIVE = 4
+ };
+
+ explicit MemoryPressureObserverChromeOS(MemoryPressureThresholds thresholds);
virtual ~MemoryPressureObserverChromeOS();
// Redo the memory pressure calculation soon and call again if a critical
@@ -71,6 +91,10 @@ class BASE_EXPORT MemoryPressureObserverChromeOS {
// gets used to count the number of events since the last event occured.
int moderate_pressure_repeat_count_;
+ // The thresholds for moderate and critical pressure.
+ const int moderate_pressure_threshold_percent_;
+ const int critical_pressure_threshold_percent_;
+
base::WeakPtrFactory<MemoryPressureObserverChromeOS> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(MemoryPressureObserverChromeOS);

Powered by Google App Engine
This is Rietveld 408576698