Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 BASE_MEMORY_MEMORY_COORDINATOR_CLIENT_H_ | 5 #ifndef BASE_MEMORY_MEMORY_COORDINATOR_CLIENT_H_ |
| 6 #define BASE_MEMORY_MEMORY_COORDINATOR_CLIENT_H_ | 6 #define BASE_MEMORY_MEMORY_COORDINATOR_CLIENT_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| 11 | 11 |
| 12 // OVERVIEW: | 12 // OVERVIEW: |
| 13 // | 13 // |
| 14 // MemoryCoordinatorClient is an interface which a component can implement to | 14 // MemoryCoordinatorClient is an interface which a component can implement to |
| 15 // adjust "future allocation" and "existing allocation". For "future allocation" | 15 // adjust "future allocation" and "existing allocation". For "future allocation" |
| 16 // it provides a callback to observe memory state changes, and for "existing | 16 // it provides a callback to observe memory state changes, and for "existing |
| 17 // allocation" it provides a callback to purge memory. | 17 // allocation" it provides a callback to purge memory. |
| 18 // | 18 // |
| 19 // Unlike MemoryPressureListener, memory state changes are stateful. State | 19 // Unlike MemoryPressureListener, memory state changes are stateful. State |
| 20 // transitions are throttled to avoid thrashing; the exact throttling period is | 20 // transitions are throttled to avoid thrashing; the exact throttling period is |
| 21 // platform dependent, but will be at least 5-10 seconds. When a state change | 21 // platform dependent, but will be at least 5-10 seconds. When a state change |
| 22 // notification is dispatched, clients are expected to update their allocation | 22 // notification is dispatched, clients are expected to update their allocation |
| 23 // policies (e.g. setting cache limit) that persist for the duration of the | 23 // policies (e.g. setting cache limit) that persist for the duration of the |
| 24 // memory state. Note that clients aren't expected to free up memory on memory | 24 // memory state. Note that clients aren't expected to free up memory on memory |
| 25 // state changes. Clients should wait for a separate purge request to free up | 25 // state changes. Clients should wait for a separate purge request to free up |
| 26 // memory. Purging requests will be throttled as well. | 26 // memory. Purging requests will be throttled as well. |
| 27 | 27 // |
| 28 // See //base/memory/memory_coordinator.md for the replacement plan. | |
|
Ryan Sleevi
2017/02/25 02:57:10
I don't think memory_coordinator.md is really "the
| |
| 29 // | |
| 28 // MemoryState is an indicator that processes can use to guide their memory | 30 // MemoryState is an indicator that processes can use to guide their memory |
| 29 // allocation policies. For example, a process that receives the throttled | 31 // allocation policies. For example, a process that receives the throttled |
| 30 // state can use that as as signal to decrease memory cache limits. | 32 // state can use that as as signal to decrease memory cache limits. |
| 31 // NOTE: This enum is used to back an UMA histogram, and therefore should be | 33 // NOTE: This enum is used to back an UMA histogram, and therefore should be |
| 32 // treated as append-only. | 34 // treated as append-only. |
| 33 enum class MemoryState : int { | 35 enum class MemoryState : int { |
| 34 // The state is unknown. | 36 // The state is unknown. |
| 35 UNKNOWN = -1, | 37 UNKNOWN = -1, |
| 36 // No memory constraints. | 38 // No memory constraints. |
| 37 NORMAL = 0, | 39 NORMAL = 0, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 // any memory whose contents can be reproduced. | 72 // any memory whose contents can be reproduced. |
| 71 virtual void OnPurgeMemory() {} | 73 virtual void OnPurgeMemory() {} |
| 72 | 74 |
| 73 protected: | 75 protected: |
| 74 virtual ~MemoryCoordinatorClient() {} | 76 virtual ~MemoryCoordinatorClient() {} |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 } // namespace base | 79 } // namespace base |
| 78 | 80 |
| 79 #endif // BASE_MEMORY_MEMORY_COORDINATOR_CLIENT_H_ | 81 #endif // BASE_MEMORY_MEMORY_COORDINATOR_CLIENT_H_ |
| OLD | NEW |