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

Unified Diff: cc/resources/resource_pool.cc

Issue 2286583002: Make cc::SoftwareImageDecodeController, cc::ResourcePool, and cc::StagingBufferPoo… (Closed)
Patch Set: Patch for landing 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 | « cc/resources/resource_pool.h ('k') | cc/tiles/gpu_image_decode_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_pool.cc
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc
index f4523d448f981d568bd229626fcb0fb1f284b3cd..5e6e426871cf63229841e7e75d4b94f731a39033 100644
--- a/cc/resources/resource_pool.cc
+++ b/cc/resources/resource_pool.cc
@@ -11,6 +11,7 @@
#include <utility>
#include "base/format_macros.h"
+#include "base/memory/memory_coordinator_client_registry.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/memory_dump_manager.h"
@@ -71,11 +72,16 @@ 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 base::MemoryCoordinatorClientRegistry.
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
}
ResourcePool::~ResourcePool() {
base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
this);
+ // Unregister this component with memory_coordinator::ClientRegistry.
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
DCHECK_EQ(0u, in_use_resources_.size());
@@ -453,4 +459,23 @@ bool ResourcePool::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
return true;
}
+void ResourcePool::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
« no previous file with comments | « cc/resources/resource_pool.h ('k') | cc/tiles/gpu_image_decode_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698