Index: cc/resources/resource_pool.cc |
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc |
index f4523d448f981d568bd229626fcb0fb1f284b3cd..509f16a66421bc78ddfb9d3ccdeea98033ccfe80 100644 |
--- a/cc/resources/resource_pool.cc |
+++ b/cc/resources/resource_pool.cc |
@@ -18,6 +18,7 @@ |
#include "cc/resources/resource_provider.h" |
#include "cc/resources/resource_util.h" |
#include "cc/resources/scoped_resource.h" |
+#include "components/memory_coordinator/common/client_registry.h" |
namespace cc { |
base::TimeDelta ResourcePool::kDefaultExpirationDelay = |
@@ -71,11 +72,22 @@ ResourcePool::ResourcePool(ResourceProvider* resource_provider, |
weak_ptr_factory_(this) { |
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
this, "cc::ResourcePool", task_runner_.get()); |
+ |
+ // Register this component with memory_coordinator::ClientRegistry. |
+ memory_coordinator::ClientRegistry* registry = |
+ memory_coordinator::ClientRegistry::GetInstance(); |
+ if (registry) |
+ registry->RegisterClient(this); |
} |
ResourcePool::~ResourcePool() { |
base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
this); |
+ // Unregister this component with memory_coordinator::ClientRegistry. |
+ memory_coordinator::ClientRegistry* registry = |
+ memory_coordinator::ClientRegistry::GetInstance(); |
+ if (registry) |
+ registry->UnregisterClient(this); |
DCHECK_EQ(0u, in_use_resources_.size()); |
@@ -453,4 +465,24 @@ bool ResourcePool::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
return true; |
} |
+void ResourcePool::OnMemoryStateChange( |
+ memory_coordinator::mojom::MemoryState state) { |
+ switch (state) { |
+ case memory_coordinator::mojom::MemoryState::NORMAL: |
+ // TODO(tasak): go back to normal state. |
+ break; |
+ case memory_coordinator::mojom::MemoryState::THROTTLED: |
+ // TODO(tasak): make the limits of this component's caches smaller to |
+ // save memory usage. |
+ break; |
+ case memory_coordinator::mojom::MemoryState::SUSPENDED: |
+ // TODO(tasak): free this component's caches as much as possible before |
+ // suspending renderer. |
+ break; |
+ default: |
+ // NOT_REACHED. |
+ break; |
+ } |
+} |
+ |
} // namespace cc |