| 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 COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAGER_
H_ | 5 #ifndef COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAGER_
H_ |
| 6 #define COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAGER_
H_ | 6 #define COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAGER_
H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 static bool CompareMemoryUsageTime(const scoped_refptr<MemorySegment>& a, | 102 static bool CompareMemoryUsageTime(const scoped_refptr<MemorySegment>& a, |
| 103 const scoped_refptr<MemorySegment>& b) { | 103 const scoped_refptr<MemorySegment>& b) { |
| 104 // In this system, LRU memory segment is evicted first. | 104 // In this system, LRU memory segment is evicted first. |
| 105 return a->memory()->last_known_usage() > b->memory()->last_known_usage(); | 105 return a->memory()->last_known_usage() > b->memory()->last_known_usage(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // base::MemoryCoordinatorClient implementation: | 108 // base::MemoryCoordinatorClient implementation: |
| 109 void OnMemoryStateChange(base::MemoryState state) override; | 109 void OnMemoryStateChange(base::MemoryState state) override; |
| 110 void OnPurgeMemory() override; |
| 110 | 111 |
| 111 void AllocateLockedDiscardableSharedMemory( | 112 void AllocateLockedDiscardableSharedMemory( |
| 112 int client_id, | 113 int client_id, |
| 113 size_t size, | 114 size_t size, |
| 114 int32_t id, | 115 int32_t id, |
| 115 base::SharedMemoryHandle* shared_memory_handle); | 116 base::SharedMemoryHandle* shared_memory_handle); |
| 116 void DeletedDiscardableSharedMemory(int32_t id, int client_id); | 117 void DeletedDiscardableSharedMemory(int32_t id, int client_id); |
| 117 void OnMemoryPressure( | 118 void OnMemoryPressure( |
| 118 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); | 119 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 119 void ReduceMemoryUsageUntilWithinMemoryLimit(); | 120 void ReduceMemoryUsageUntilWithinMemoryLimit(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 145 base::Closure enforce_memory_policy_callback_; | 146 base::Closure enforce_memory_policy_callback_; |
| 146 bool enforce_memory_policy_pending_; | 147 bool enforce_memory_policy_pending_; |
| 147 base::WeakPtrFactory<DiscardableSharedMemoryManager> weak_ptr_factory_; | 148 base::WeakPtrFactory<DiscardableSharedMemoryManager> weak_ptr_factory_; |
| 148 | 149 |
| 149 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryManager); | 150 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryManager); |
| 150 }; | 151 }; |
| 151 | 152 |
| 152 } // namespace discardable_memory | 153 } // namespace discardable_memory |
| 153 | 154 |
| 154 #endif // COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAG
ER_H_ | 155 #endif // COMPONENTS_DISCARDABLE_MEMORY_SERVICE_DISCARDABLE_SHARED_MEMORY_MANAG
ER_H_ |
| OLD | NEW |