Index: cc/tiles/gpu_image_decode_controller.cc |
diff --git a/cc/tiles/gpu_image_decode_controller.cc b/cc/tiles/gpu_image_decode_controller.cc |
index cd3240b0d876727a7c7629b8014fd95ccd3137b5..6e6f94d3a59c0d076caf1cf1dcb8b788612bada9 100644 |
--- a/cc/tiles/gpu_image_decode_controller.cc |
+++ b/cc/tiles/gpu_image_decode_controller.cc |
@@ -18,6 +18,7 @@ |
#include "cc/raster/tile_task.h" |
#include "cc/resources/resource_format_utils.h" |
#include "cc/tiles/mipmap_util.h" |
+#include "components/memory_coordinator/common/client_registry.h" |
#include "gpu/command_buffer/client/context_support.h" |
#include "gpu/command_buffer/client/gles2_interface.h" |
#include "gpu_image_decode_controller.h" |
@@ -348,6 +349,11 @@ GpuImageDecodeController::GpuImageDecodeController(ContextProvider* context, |
this, "cc::GpuImageDecodeController", |
base::ThreadTaskRunnerHandle::Get()); |
} |
+ // Register this component with memory_coordinator::ClientRegistry. |
+ memory_coordinator::ClientRegistry* registry = |
+ memory_coordinator::ClientRegistry::GetInstance(); |
+ if (registry) |
+ registry->RegisterClient(this); |
} |
GpuImageDecodeController::~GpuImageDecodeController() { |
@@ -358,6 +364,11 @@ GpuImageDecodeController::~GpuImageDecodeController() { |
// It is safe to unregister, even if we didn't register in the constructor. |
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); |
} |
bool GpuImageDecodeController::GetTaskForImageAndRef( |
@@ -1125,4 +1136,24 @@ bool GpuImageDecodeController::DiscardableIsLockedForTesting( |
return image_data->decode.is_locked(); |
} |
+void GpuImageDecodeController::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 |