Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1023)

Unified Diff: content/common/host_discardable_shared_memory_manager.cc

Issue 2357603002: Make HostDiscardableSharedMemoryManager a client of memory coordinator (Closed)
Patch Set: Remove comments that indicated TODOs in a different component Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/host_discardable_shared_memory_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « content/common/host_discardable_shared_memory_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698