Index: cc/tiles/software_image_decode_controller.cc |
diff --git a/cc/tiles/software_image_decode_controller.cc b/cc/tiles/software_image_decode_controller.cc |
index 34f5f7244d70ebcd28852495799ad852493b46d2..5656344f33d88813116c97ee2a58940fda227acf 100644 |
--- a/cc/tiles/software_image_decode_controller.cc |
+++ b/cc/tiles/software_image_decode_controller.cc |
@@ -22,6 +22,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 "third_party/skia/include/core/SkCanvas.h" |
#include "third_party/skia/include/core/SkImage.h" |
#include "third_party/skia/include/core/SkPixmap.h" |
@@ -180,6 +181,11 @@ SoftwareImageDecodeController::SoftwareImageDecodeController( |
this, "cc::SoftwareImageDecodeController", |
base::ThreadTaskRunnerHandle::Get()); |
} |
+ // Register this component with memory_coordinator::ClientRegistry. |
+ memory_coordinator::ClientRegistry* registry = |
+ memory_coordinator::ClientRegistry::GetInstance(); |
+ if (registry) |
+ registry->RegisterClient(this); |
} |
SoftwareImageDecodeController::~SoftwareImageDecodeController() { |
@@ -189,6 +195,11 @@ SoftwareImageDecodeController::~SoftwareImageDecodeController() { |
// 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 SoftwareImageDecodeController::GetTaskForImageAndRef( |
@@ -1078,4 +1089,24 @@ size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() |
return current_usage_bytes_.ValueOrDie(); |
} |
+void SoftwareImageDecodeController::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 |