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..bca4e99010465dde00a3a517f0164d4ecdca1f33 100644 |
--- a/cc/tiles/software_image_decode_controller.cc |
+++ b/cc/tiles/software_image_decode_controller.cc |
@@ -13,6 +13,7 @@ |
#include "base/format_macros.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/metrics/histogram_macros.h" |
#include "base/strings/stringprintf.h" |
@@ -180,6 +181,8 @@ SoftwareImageDecodeController::SoftwareImageDecodeController( |
this, "cc::SoftwareImageDecodeController", |
base::ThreadTaskRunnerHandle::Get()); |
} |
+ // Register this component with base::MemoryCoordinatorClientRegistry. |
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); |
} |
SoftwareImageDecodeController::~SoftwareImageDecodeController() { |
@@ -189,6 +192,8 @@ 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. |
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); |
} |
bool SoftwareImageDecodeController::GetTaskForImageAndRef( |
@@ -1078,4 +1083,24 @@ size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() |
return current_usage_bytes_.ValueOrDie(); |
} |
+void SoftwareImageDecodeController::OnMemoryStateChange( |
+ base::MemoryState state) { |
+ switch (state) { |
+ case base::MemoryState::NORMAL: |
+ // TODO(tasak): go back to normal state. |
+ break; |
+ case base::MemoryState::THROTTLED: |
+ // TODO(tasak): make the limits of this component's caches smaller to |
+ // save memory usage. |
+ break; |
+ case base::MemoryState::SUSPENDED: |
+ // TODO(tasak): free this component's caches as much as possible before |
+ // suspending renderer. |
+ break; |
+ case base::MemoryState::UNKNOWN: |
+ // NOT_REACHED. |
+ break; |
+ } |
+} |
+ |
} // namespace cc |