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); |