| 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 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // Clients should free up any memory that is used as an optimization but | 31 // Clients should free up any memory that is used as an optimization but |
| 32 // that is not necessary for the process to run (e.g. caches). | 32 // that is not necessary for the process to run (e.g. caches). |
| 33 THROTTLED = 1, | 33 THROTTLED = 1, |
| 34 // Still resident in memory but core processing logic has been suspended. | 34 // Still resident in memory but core processing logic has been suspended. |
| 35 // Clients should free up any memory that is used as an optimization, or | 35 // Clients should free up any memory that is used as an optimization, or |
| 36 // any memory whose contents can be reproduced when transitioning out of | 36 // any memory whose contents can be reproduced when transitioning out of |
| 37 // the suspended state (e.g. parsed resource that can be reloaded from disk). | 37 // the suspended state (e.g. parsed resource that can be reloaded from disk). |
| 38 SUSPENDED = 2, | 38 SUSPENDED = 2, |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Returns a string representation of MemoryState. |
| 42 BASE_EXPORT const char* MemoryStateToString(MemoryState state); |
| 43 |
| 41 // This is an interface for components which can respond to memory status | 44 // This is an interface for components which can respond to memory status |
| 42 // changes. An initial state is NORMAL. See MemoryCoordinatorClientRegistry for | 45 // changes. An initial state is NORMAL. See MemoryCoordinatorClientRegistry for |
| 43 // threading guarantees and ownership management. | 46 // threading guarantees and ownership management. |
| 44 class BASE_EXPORT MemoryCoordinatorClient { | 47 class BASE_EXPORT MemoryCoordinatorClient { |
| 45 public: | 48 public: |
| 46 // Called when memory state has changed. Any transition can occur except for | 49 // Called when memory state has changed. Any transition can occur except for |
| 47 // UNKNOWN. General guidelines are: | 50 // UNKNOWN. General guidelines are: |
| 48 // * NORMAL: Restore the default settings for memory allocation/usage if | 51 // * NORMAL: Restore the default settings for memory allocation/usage if |
| 49 // it has changed. | 52 // it has changed. |
| 50 // * THROTTLED: Use smaller limits for memory allocations and caches. | 53 // * THROTTLED: Use smaller limits for memory allocations and caches. |
| 51 // * SUSPENDED: Purge memory. | 54 // * SUSPENDED: Purge memory. |
| 52 virtual void OnMemoryStateChange(MemoryState state) = 0; | 55 virtual void OnMemoryStateChange(MemoryState state) = 0; |
| 53 | 56 |
| 54 protected: | 57 protected: |
| 55 virtual ~MemoryCoordinatorClient() {} | 58 virtual ~MemoryCoordinatorClient() {} |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 } // namespace base | 61 } // namespace base |
| 59 | 62 |
| 60 #endif // BASE_MEMORY_MEMORY_COORDINATOR_CLIENT_H_ | 63 #endif // BASE_MEMORY_MEMORY_COORDINATOR_CLIENT_H_ |
| OLD | NEW |