Index: content/common/host_discardable_shared_memory_manager.cc |
diff --git a/content/common/host_discardable_shared_memory_manager.cc b/content/common/host_discardable_shared_memory_manager.cc |
index 9800dc6b394d3f502b7def7dbf242955e7dac7e0..aafd5d6376f80eeacd788307ae51efe6fcaaafdf 100644 |
--- a/content/common/host_discardable_shared_memory_manager.cc |
+++ b/content/common/host_discardable_shared_memory_manager.cc |
@@ -14,6 +14,7 @@ |
#include "base/lazy_instance.h" |
#include "base/macros.h" |
#include "base/memory/discardable_memory.h" |
+#include "base/memory/memory_coordinator_client_registry.h" |
#include "base/memory/ptr_util.h" |
#include "base/numerics/safe_math.h" |
#include "base/process/memory.h" |
@@ -179,6 +180,7 @@ HostDiscardableSharedMemoryManager::HostDiscardableSharedMemoryManager() |
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
this, "HostDiscardableSharedMemoryManager", |
base::ThreadTaskRunnerHandle::Get()); |
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); |
} |
HostDiscardableSharedMemoryManager::~HostDiscardableSharedMemoryManager() { |
@@ -346,6 +348,24 @@ size_t HostDiscardableSharedMemoryManager::GetBytesAllocated() { |
return bytes_allocated_; |
} |
+void HostDiscardableSharedMemoryManager::OnMemoryStateChange( |
+ base::MemoryState state) { |
+ switch (state) { |
+ case base::MemoryState::NORMAL: |
+ SetMemoryLimit(GetDefaultMemoryLimit()); |
+ break; |
+ case base::MemoryState::THROTTLED: |
+ SetMemoryLimit(0); |
+ break; |
+ case base::MemoryState::SUSPENDED: |
+ // Note that SUSPENDED never occurs in the main browser process so far. |
+ // Fall through. |
+ case base::MemoryState::UNKNOWN: |
+ NOTREACHED(); |
+ break; |
+ } |
+} |
+ |
void HostDiscardableSharedMemoryManager::AllocateLockedDiscardableSharedMemory( |
base::ProcessHandle process_handle, |
int client_process_id, |