| Index: cc/raster/staging_buffer_pool.cc
|
| diff --git a/cc/raster/staging_buffer_pool.cc b/cc/raster/staging_buffer_pool.cc
|
| index 99fb43843105ece60a3ac000cbd3236ce601c003..5885394c9fa939f7bb76da8c26e881d0cdba484d 100644
|
| --- a/cc/raster/staging_buffer_pool.cc
|
| +++ b/cc/raster/staging_buffer_pool.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <memory>
|
|
|
| +#include "base/allocator/allocator_extension.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| @@ -141,6 +142,9 @@ StagingBufferPool::StagingBufferPool(base::SequencedTaskRunner* task_runner,
|
| this, "cc::StagingBufferPool", base::ThreadTaskRunnerHandle::Get());
|
| reduce_memory_usage_callback_ = base::Bind(
|
| &StagingBufferPool::ReduceMemoryUsage, weak_ptr_factory_.GetWeakPtr());
|
| +
|
| + memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind(
|
| + &StagingBufferPool::OnMemoryPressure, base::Unretained(this))));
|
| }
|
|
|
| StagingBufferPool::~StagingBufferPool() {
|
| @@ -186,6 +190,16 @@ bool StagingBufferPool::OnMemoryDump(
|
| return true;
|
| }
|
|
|
| +void StagingBufferPool::OnMemoryPressure(
|
| + base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
|
| + base::AutoLock lock(lock_);
|
| + if (buffers_.empty())
|
| + return;
|
| +
|
| + ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
|
| + base::allocator::ReleaseFreeMemory();
|
| +}
|
| +
|
| void StagingBufferPool::AddStagingBuffer(const StagingBuffer* staging_buffer,
|
| ResourceFormat format) {
|
| lock_.AssertAcquired();
|
|
|