| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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_PUBLIC_RESOURCE_MANAGER_H_ | 5 #ifndef ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_ |
| 6 #define ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_ | 6 #define ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_ |
| 7 | 7 |
| 8 #include "athena/athena_export.h" | 8 #include "athena/athena_export.h" |
| 9 #include "athena/resource_manager/memory_pressure_notifier.h" | 9 #include "athena/resource_manager/memory_pressure_notifier.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 ResourceManager(); | 25 ResourceManager(); |
| 26 virtual ~ResourceManager(); | 26 virtual ~ResourceManager(); |
| 27 | 27 |
| 28 // Unit tests can simulate MemoryPressure changes with this call. | 28 // Unit tests can simulate MemoryPressure changes with this call. |
| 29 // Note: Even though the default unit test ResourceManagerDelegte | 29 // Note: Even though the default unit test ResourceManagerDelegte |
| 30 // implementation ensures that the MemoryPressure event will not go off, | 30 // implementation ensures that the MemoryPressure event will not go off, |
| 31 // this call will also explicitly stop the MemoryPressureNotifier. | 31 // this call will also explicitly stop the MemoryPressureNotifier. |
| 32 virtual void SetMemoryPressureAndStopMonitoring( | 32 virtual void SetMemoryPressureAndStopMonitoring( |
| 33 MemoryPressureObserver::MemoryPressure pressure) = 0; | 33 MemoryPressureObserver::MemoryPressure pressure) = 0; |
| 34 | 34 |
| 35 // Suspend the resource manager temporarily if |pause| is set. This can be |
| 36 // called before e.g. re-arranging the order of activities. Once called with |
| 37 // |pause| == false any queued operations will be performed and the resource |
| 38 // manager will continue its work. |
| 39 virtual void Pause(bool pause) = 0; |
| 40 |
| 35 private: | 41 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(ResourceManager); | 42 DISALLOW_COPY_AND_ASSIGN(ResourceManager); |
| 37 }; | 43 }; |
| 38 | 44 |
| 45 // Use this scoped object to pause/restart the resource manager. |
| 46 class ScopedPauseResourceManager { |
| 47 public: |
| 48 ScopedPauseResourceManager() { |
| 49 ResourceManager::Get()->Pause(true); |
| 50 } |
| 51 ~ScopedPauseResourceManager() { |
| 52 ResourceManager::Get()->Pause(false); |
| 53 } |
| 54 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(ScopedPauseResourceManager); |
| 56 }; |
| 57 |
| 39 } // namespace athena | 58 } // namespace athena |
| 40 | 59 |
| 41 #endif // ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_ | 60 #endif // ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_ |
| OLD | NEW |