OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/software_image_decode_cache.h" | 5 #include "cc/tiles/software_image_decode_cache.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 it = decoded_images_.Erase(it); | 811 it = decoded_images_.Erase(it); |
812 --num_to_remove; | 812 --num_to_remove; |
813 } | 813 } |
814 } | 814 } |
815 | 815 |
816 void SoftwareImageDecodeCache::ReduceCacheUsage() { | 816 void SoftwareImageDecodeCache::ReduceCacheUsage() { |
817 base::AutoLock lock(lock_); | 817 base::AutoLock lock(lock_); |
818 ReduceCacheUsageUntilWithinLimit(max_items_in_cache_); | 818 ReduceCacheUsageUntilWithinLimit(max_items_in_cache_); |
819 } | 819 } |
820 | 820 |
| 821 void SoftwareImageDecodeCache::ClearCache() { |
| 822 base::AutoLock lock(lock_); |
| 823 ReduceCacheUsageUntilWithinLimit(0); |
| 824 } |
| 825 |
821 void SoftwareImageDecodeCache::RemovePendingTask(const ImageKey& key, | 826 void SoftwareImageDecodeCache::RemovePendingTask(const ImageKey& key, |
822 DecodeTaskType task_type) { | 827 DecodeTaskType task_type) { |
823 base::AutoLock lock(lock_); | 828 base::AutoLock lock(lock_); |
824 switch (task_type) { | 829 switch (task_type) { |
825 case DecodeTaskType::USE_IN_RASTER_TASKS: | 830 case DecodeTaskType::USE_IN_RASTER_TASKS: |
826 pending_in_raster_image_tasks_.erase(key); | 831 pending_in_raster_image_tasks_.erase(key); |
827 break; | 832 break; |
828 case DecodeTaskType::USE_OUT_OF_RASTER_TASKS: | 833 case DecodeTaskType::USE_OUT_OF_RASTER_TASKS: |
829 pending_out_of_raster_image_tasks_.erase(key); | 834 pending_out_of_raster_image_tasks_.erase(key); |
830 break; | 835 break; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 } | 1182 } |
1178 } | 1183 } |
1179 } | 1184 } |
1180 | 1185 |
1181 void SoftwareImageDecodeCache::OnPurgeMemory() { | 1186 void SoftwareImageDecodeCache::OnPurgeMemory() { |
1182 base::AutoLock lock(lock_); | 1187 base::AutoLock lock(lock_); |
1183 ReduceCacheUsageUntilWithinLimit(0); | 1188 ReduceCacheUsageUntilWithinLimit(0); |
1184 } | 1189 } |
1185 | 1190 |
1186 } // namespace cc | 1191 } // namespace cc |
OLD | NEW |