OLD | NEW |
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 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 bool GpuImageDecodeCache::DiscardableIsLockedForTesting( | 1254 bool GpuImageDecodeCache::DiscardableIsLockedForTesting( |
1255 const DrawImage& image) { | 1255 const DrawImage& image) { |
1256 base::AutoLock lock(lock_); | 1256 base::AutoLock lock(lock_); |
1257 auto found = persistent_cache_.Peek(image.image()->uniqueID()); | 1257 auto found = persistent_cache_.Peek(image.image()->uniqueID()); |
1258 DCHECK(found != persistent_cache_.end()); | 1258 DCHECK(found != persistent_cache_.end()); |
1259 ImageData* image_data = found->second.get(); | 1259 ImageData* image_data = found->second.get(); |
1260 return image_data->decode.is_locked(); | 1260 return image_data->decode.is_locked(); |
1261 } | 1261 } |
1262 | 1262 |
1263 void GpuImageDecodeCache::OnMemoryStateChange(base::MemoryState state) { | 1263 void GpuImageDecodeCache::OnMemoryStateChange(base::MemoryState state) { |
1264 switch (state) { | 1264 memory_state_ = state; |
1265 case base::MemoryState::NORMAL: | 1265 } |
1266 memory_state_ = state; | |
1267 break; | |
1268 case base::MemoryState::THROTTLED: | |
1269 case base::MemoryState::SUSPENDED: { | |
1270 memory_state_ = state; | |
1271 | 1266 |
1272 // We've just changed our memory state to a (potentially) more | 1267 void GpuImageDecodeCache::OnPurgeMemory() { |
1273 // restrictive one. Re-enforce cache limits. | 1268 // We've just changed our memory state to a (potentially) more |
1274 base::AutoLock lock(lock_); | 1269 // restrictive one. Re-enforce cache limits. |
1275 EnsureCapacity(0); | 1270 base::AutoLock lock(lock_); |
1276 break; | 1271 EnsureCapacity(0); |
1277 } | |
1278 case base::MemoryState::UNKNOWN: | |
1279 // NOT_REACHED. | |
1280 break; | |
1281 } | |
1282 } | 1272 } |
1283 | 1273 |
1284 } // namespace cc | 1274 } // namespace cc |
OLD | NEW |