| Index: cc/resources/resource_pool.cc
|
| diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc
|
| index 0ec24005a49e8e40af31fc771f559a69fbd83845..57a42b8c7dede44201d3571cf22ca4d105db7bed 100644
|
| --- a/cc/resources/resource_pool.cc
|
| +++ b/cc/resources/resource_pool.cc
|
| @@ -10,6 +10,7 @@
|
| #include <algorithm>
|
| #include <utility>
|
|
|
| +#include "base/allocator/allocator_extension.h"
|
| #include "base/format_macros.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| @@ -75,6 +76,9 @@ ResourcePool::ResourcePool(ResourceProvider* resource_provider,
|
| weak_ptr_factory_(this) {
|
| base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
|
| this, "cc::ResourcePool", task_runner_.get());
|
| +
|
| + memory_pressure_listener_.reset(new base::MemoryPressureListener(
|
| + base::Bind(&ResourcePool::OnMemoryPressure, base::Unretained(this))));
|
| }
|
|
|
| ResourcePool::~ResourcePool() {
|
| @@ -224,6 +228,13 @@ void ResourcePool::SetResourceUsageLimits(size_t max_memory_usage_bytes,
|
| ReduceResourceUsage();
|
| }
|
|
|
| +void ResourcePool::OnMemoryPressure(
|
| + base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
|
| + while (!unused_resources_.empty())
|
| + DeleteResource(PopBack(&unused_resources_));
|
| + base::allocator::ReleaseFreeMemory();
|
| +}
|
| +
|
| void ResourcePool::ReduceResourceUsage() {
|
| while (!unused_resources_.empty()) {
|
| if (!ResourceUsageTooHigh())
|
|
|