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

Side by Side Diff: cc/tiles/gpu_image_decode_cache.cc

Issue 2664703002: Move purging from OnMemoryState to OnPurgeMemory() in cc/ (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/tiles/gpu_image_decode_cache.h" 5 #include "cc/tiles/gpu_image_decode_cache.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/memory/discardable_memory_allocator.h" 10 #include "base/memory/discardable_memory_allocator.h"
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 return image_data->decode.is_locked(); 1261 return image_data->decode.is_locked();
1262 } 1262 }
1263 1263
1264 bool GpuImageDecodeCache::IsInInUseCacheForTesting( 1264 bool GpuImageDecodeCache::IsInInUseCacheForTesting(
1265 const DrawImage& image) const { 1265 const DrawImage& image) const {
1266 auto found = in_use_cache_.find(GenerateInUseCacheKey(image)); 1266 auto found = in_use_cache_.find(GenerateInUseCacheKey(image));
1267 return found != in_use_cache_.end(); 1267 return found != in_use_cache_.end();
1268 } 1268 }
1269 1269
1270 void GpuImageDecodeCache::OnMemoryStateChange(base::MemoryState state) { 1270 void GpuImageDecodeCache::OnMemoryStateChange(base::MemoryState state) {
1271 switch (state) { 1271 memory_state_ = state;
1272 case base::MemoryState::NORMAL:
1273 memory_state_ = state;
1274 break;
1275 case base::MemoryState::THROTTLED:
1276 case base::MemoryState::SUSPENDED: {
1277 memory_state_ = state;
1278 1272
1279 // We've just changed our memory state to a (potentially) more 1273 // TODO(bashi): We are going to separate purging from state changes and we
1280 // restrictive one. Re-enforce cache limits. 1274 // shouldn't purge memory here (crbug.com/684287). Tentatively call
1281 base::AutoLock lock(lock_); 1275 // OnPurgeMemory() so that we don't break existing experiments.
1282 EnsureCapacity(0); 1276 // (i.e. purge+suspend experiment)
1283 break; 1277 if (state == base::MemoryState::SUSPENDED)
ericrk 2017/01/30 15:58:56 The previous logic handled THROTTLED as well, with
bashi 2017/01/31 19:30:56 The purpose of this CL is to separate purging cach
1284 } 1278 OnPurgeMemory();
1285 case base::MemoryState::UNKNOWN: 1279 }
1286 // NOT_REACHED. 1280
1287 break; 1281 void GpuImageDecodeCache::OnPurgeMemory() {
1288 } 1282 base::AutoLock lock(lock_);
1283 EnsureCapacity(0);
1289 } 1284 }
1290 1285
1291 } // namespace cc 1286 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698