| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 ATHENA_RESOURCE_MANAGER_MEMORY_PRESSURE_NOTIFIER_H_ | 5 #ifndef ATHENA_RESOURCE_MANAGER_MEMORY_PRESSURE_NOTIFIER_H_ |
| 6 #define ATHENA_RESOURCE_MANAGER_MEMORY_PRESSURE_NOTIFIER_H_ | 6 #define ATHENA_RESOURCE_MANAGER_MEMORY_PRESSURE_NOTIFIER_H_ |
| 7 | 7 |
| 8 #include "athena/athena_export.h" | 8 #include "athena/athena_export.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // This observer gets informed once about a |MEMORY_PRESSURE_LOW|. When the | 21 // This observer gets informed once about a |MEMORY_PRESSURE_LOW|. When the |
| 22 // pressure exceeds, the observer will get polled until |MEMORY_PRESSURE_LOW| is | 22 // pressure exceeds, the observer will get polled until |MEMORY_PRESSURE_LOW| is |
| 23 // reached again to counter memory consumption. | 23 // reached again to counter memory consumption. |
| 24 class MemoryPressureObserver { | 24 class MemoryPressureObserver { |
| 25 public: | 25 public: |
| 26 MemoryPressureObserver() {} | 26 MemoryPressureObserver() {} |
| 27 virtual ~MemoryPressureObserver() {} | 27 virtual ~MemoryPressureObserver() {} |
| 28 | 28 |
| 29 // The reported memory pressure. Note: The value is intentionally abstracted | 29 // The reported memory pressure. Note: The value is intentionally abstracted |
| 30 // since the real amount of free memory is only estimated (due to e.g. zram). | 30 // since the real amount of free memory is only estimated (due to e.g. zram). |
| 31 // Note: The bigger the index of the pressure level, the more resources are |
| 32 // in use. |
| 31 enum MemoryPressure { | 33 enum MemoryPressure { |
| 32 MEMORY_PRESSURE_UNKNOWN, // The memory pressure cannot be determined. | 34 MEMORY_PRESSURE_UNKNOWN = 0, // The memory pressure cannot be determined. |
| 33 MEMORY_PRESSURE_LOW, // Single call if memory fill level is below 50%. | 35 MEMORY_PRESSURE_LOW, // Single call if fill level is below 50%. |
| 34 MEMORY_PRESSURE_MODERATE, // Polled for memory fill level of ~50 .. 75%. | 36 MEMORY_PRESSURE_MODERATE, // Polled for fill level of ~50 .. 75%. |
| 35 MEMORY_PRESSURE_HIGH, // Polled for memory fill level of ~75% .. 90%. | 37 MEMORY_PRESSURE_HIGH, // Polled for fill level of ~75% .. 90%. |
| 36 MEMORY_PRESSURE_CRITICAL, // Polled for memory fill level of above ~90%. | 38 MEMORY_PRESSURE_CRITICAL, // Polled for fill level of above ~90%. |
| 37 }; | 39 }; |
| 38 // The observer. | 40 // The observer. |
| 39 virtual void OnMemoryPressure(MemoryPressure pressure) = 0; | 41 virtual void OnMemoryPressure(MemoryPressure pressure) = 0; |
| 40 | 42 |
| 41 // OS system interface functions. The delegate remains owned by the Observer. | 43 // OS system interface functions. The delegate remains owned by the Observer. |
| 42 virtual ResourceManagerDelegate* GetDelegate() = 0; | 44 virtual ResourceManagerDelegate* GetDelegate() = 0; |
| 43 }; | 45 }; |
| 44 | 46 |
| 45 | 47 |
| 46 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 86 |
| 85 // Our current memory pressure. | 87 // Our current memory pressure. |
| 86 MemoryPressureObserver::MemoryPressure current_pressure_; | 88 MemoryPressureObserver::MemoryPressure current_pressure_; |
| 87 | 89 |
| 88 DISALLOW_COPY_AND_ASSIGN(MemoryPressureNotifier); | 90 DISALLOW_COPY_AND_ASSIGN(MemoryPressureNotifier); |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 } // namespace athena | 93 } // namespace athena |
| 92 | 94 |
| 93 #endif // ATHENA_RESOURCE_MANAGER_MEMORY_PRESSURE_NOTIFIER_H_ | 95 #endif // ATHENA_RESOURCE_MANAGER_MEMORY_PRESSURE_NOTIFIER_H_ |
| OLD | NEW |