Chromium Code Reviews| 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..813e064e65249fadc36ba72195daafe1e3aa71bd 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. |
| + MEMORY_PRESSURE_THRESHOLD_DEFAULT = 0, |
| + // Try to keep as much content in memory as possible. |
| + MEMORY_PRESSURE_THRESHOLD_CONSERVATIVE = 1, |
| + // Discard caches earlier, allowing to keep more tabs in memory. |
| + MEMORY_PRESSURE_THRESHOLD_AGGRESSIVE_CACHE_DISCARD = 2, |
| + // Discard tabs earlier, allowing the system to get faster. |
| + MEMORY_PRESSURE_THRESHOLD_AGGRESSIVE_TAB_DISCARD = 3, |
| + // Discard caches and tabs earlier to allow the system to be faster. |
| + MEMORY_PRESSURE_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. |
|
James Cook
2015/01/21 21:24:25
nit: What are the units? Percent?
Mr4D (OOO till 08-26)
2015/01/21 21:54:34
Done.
|
| + const int moderate_pressure_threshold_; |
| + const int critical_pressure_threshold_; |
| + |
| base::WeakPtrFactory<MemoryPressureObserverChromeOS> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(MemoryPressureObserverChromeOS); |