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

Unified Diff: cc/tiles/gpu_image_decode_cache.cc

Issue 2795803002: Clear Image Decode Cache on Navigation (Closed)
Patch Set: Created 3 years, 9 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/tiles/gpu_image_decode_cache.cc
diff --git a/cc/tiles/gpu_image_decode_cache.cc b/cc/tiles/gpu_image_decode_cache.cc
index 70216a376f1a91890b4520d57f45c9cc1697d844..ce20d8af2f07b98b0b323e6637c6bf74d10342ef 100644
--- a/cc/tiles/gpu_image_decode_cache.cc
+++ b/cc/tiles/gpu_image_decode_cache.cc
@@ -584,6 +584,26 @@ void GpuImageDecodeCache::SetShouldAggressivelyFreeResources(
}
}
+void GpuImageDecodeCache::ClearCache() {
+ base::AutoLock lock(lock_);
+ for (auto it = persistent_cache_.rbegin(); it != persistent_cache_.rend();) {
vmpstr 2017/04/03 18:46:10 Not that it matters, but can we make this loop for
ericrk 2017/04/04 00:26:03 yup - done.
+ if (it->second->decode.ref_count != 0 ||
+ it->second->upload.ref_count != 0) {
+ ++it;
+ continue;
+ }
+
+ if (it->second->upload.image()) {
+ bytes_used_ -= it->second->size;
+ images_pending_deletion_.push_back(it->second->upload.image());
+ it->second->upload.SetImage(nullptr);
+ it->second->upload.budgeted = false;
+ }
+
+ it = persistent_cache_.Erase(it);
+ }
+}
+
bool GpuImageDecodeCache::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {

Powered by Google App Engine
This is Rietveld 408576698