| 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 "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
| 11 | 12 |
| 12 namespace athena { | 13 namespace athena { |
| 13 | 14 |
| 14 class MemoryPressureNotifierImpl; | 15 class MemoryPressureNotifierImpl; |
| 15 class ResourceManagerDelegate; | 16 class ResourceManagerDelegate; |
| 16 | 17 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 26 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 //////////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////////// |
| 46 // MemoryPressureNotifier | 47 // MemoryPressureNotifier |
| 47 // | 48 // |
| 48 // Class to handle the observation of our free memory. It notifies the owner of | 49 // Class to handle the observation of our free memory. It notifies the owner of |
| 49 // memory fill level changes, so that it can take action to reduce memory by | 50 // memory fill level changes, so that it can take action to reduce memory by |
| 50 // reducing active activities. | 51 // reducing active activities. |
| 51 // | 52 // |
| 52 // The observer will use 3 different fill levels: 50% full, 75% full and 90% | 53 // The observer will use 3 different fill levels: 50% full, 75% full and 90% |
| 53 // full. | 54 // full. |
| 54 class MemoryPressureNotifier { | 55 class ATHENA_EXPORT MemoryPressureNotifier { |
| 55 public: | 56 public: |
| 56 // The creator gets the |listener| object. Note that the ownership of the | 57 // The creator gets the |listener| object. Note that the ownership of the |
| 57 // listener object remains with the creator. | 58 // listener object remains with the creator. |
| 58 explicit MemoryPressureNotifier(MemoryPressureObserver* listener); | 59 explicit MemoryPressureNotifier(MemoryPressureObserver* listener); |
| 59 ~MemoryPressureNotifier(); | 60 ~MemoryPressureNotifier(); |
| 60 | 61 |
| 61 // Stop observing the memory fill level. | 62 // Stop observing the memory fill level. |
| 62 // May be safely called if StartObserving has not been called. | 63 // May be safely called if StartObserving has not been called. |
| 63 void StopObserving(); | 64 void StopObserving(); |
| 64 | 65 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 83 | 84 |
| 84 // Our current memory pressure. | 85 // Our current memory pressure. |
| 85 MemoryPressureObserver::MemoryPressure current_pressure_; | 86 MemoryPressureObserver::MemoryPressure current_pressure_; |
| 86 | 87 |
| 87 DISALLOW_COPY_AND_ASSIGN(MemoryPressureNotifier); | 88 DISALLOW_COPY_AND_ASSIGN(MemoryPressureNotifier); |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 } // namespace athena | 91 } // namespace athena |
| 91 | 92 |
| 92 #endif // ATHENA_RESOURCE_MANAGER_MEMORY_PRESSURE_NOTIFIER_H_ | 93 #endif // ATHENA_RESOURCE_MANAGER_MEMORY_PRESSURE_NOTIFIER_H_ |
| OLD | NEW |