| Index: cc/tiles/software_image_decode_cache.cc
|
| diff --git a/cc/tiles/software_image_decode_cache.cc b/cc/tiles/software_image_decode_cache.cc
|
| index 53758c02552fe6e00642649291ca228f984df56b..13ed05129fc5ed5aa18d4b601f743689777f5e44 100644
|
| --- a/cc/tiles/software_image_decode_cache.cc
|
| +++ b/cc/tiles/software_image_decode_cache.cc
|
| @@ -797,12 +797,10 @@ void SoftwareImageDecodeCache::UnrefAtRasterImage(const ImageKey& key) {
|
| }
|
| }
|
|
|
| -void SoftwareImageDecodeCache::ReduceCacheUsage() {
|
| +void SoftwareImageDecodeCache::ReduceCacheUsageUntilWithinLimit(size_t limit) {
|
| TRACE_EVENT0("cc", "SoftwareImageDecodeCache::ReduceCacheUsage");
|
| - base::AutoLock lock(lock_);
|
| - size_t num_to_remove = (decoded_images_.size() > max_items_in_cache_)
|
| - ? (decoded_images_.size() - max_items_in_cache_)
|
| - : 0;
|
| + size_t num_to_remove =
|
| + (decoded_images_.size() > limit) ? (decoded_images_.size() - limit) : 0;
|
| for (auto it = decoded_images_.rbegin();
|
| num_to_remove != 0 && it != decoded_images_.rend();) {
|
| if (it->second->is_locked()) {
|
| @@ -815,6 +813,11 @@ void SoftwareImageDecodeCache::ReduceCacheUsage() {
|
| }
|
| }
|
|
|
| +void SoftwareImageDecodeCache::ReduceCacheUsage() {
|
| + base::AutoLock lock(lock_);
|
| + ReduceCacheUsageUntilWithinLimit(max_items_in_cache_);
|
| +}
|
| +
|
| void SoftwareImageDecodeCache::RemovePendingTask(const ImageKey& key,
|
| DecodeTaskType task_type) {
|
| base::AutoLock lock(lock_);
|
| @@ -1173,7 +1176,11 @@ void SoftwareImageDecodeCache::OnMemoryStateChange(base::MemoryState state) {
|
| return;
|
| }
|
| }
|
| - ReduceCacheUsage();
|
| +}
|
| +
|
| +void SoftwareImageDecodeCache::OnPurgeMemory() {
|
| + base::AutoLock lock(lock_);
|
| + ReduceCacheUsageUntilWithinLimit(0);
|
| }
|
|
|
| } // namespace cc
|
|
|