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

Unified Diff: cc/raster/staging_buffer_pool.cc

Issue 2130683002: [Experiment] purge-and-suspend Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 5 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
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();
esprehn 2016/08/05 23:00:57 is this is very strange inside the cc/raster code.
tasak 2016/08/08 04:47:36 Acknowledged. Yeah, I agree that MemoryCoordinato
+}
+
void StagingBufferPool::AddStagingBuffer(const StagingBuffer* staging_buffer,
ResourceFormat format) {
lock_.AssertAcquired();

Powered by Google App Engine
This is Rietveld 408576698