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

Unified Diff: cc/tiles/gpu_image_decode_cache.cc

Issue 2664703002: Move purging from OnMemoryState to OnPurgeMemory() in cc/ (Closed)
Patch Set: Don't call OnPurgeMemory() in OnStateChange() 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tiles/gpu_image_decode_cache.h ('k') | cc/tiles/gpu_image_decode_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 93cdd29158fe5a0c356f3f1782ef576a57e75254..1dcc40c471acd9fa494c86e0e73732d035fc2e35 100644
--- a/cc/tiles/gpu_image_decode_cache.cc
+++ b/cc/tiles/gpu_image_decode_cache.cc
@@ -6,6 +6,7 @@
#include <inttypes.h>
+#include "base/auto_reset.h"
#include "base/debug/alias.h"
#include "base/memory/discardable_memory_allocator.h"
#include "base/memory/memory_coordinator_client_registry.h"
@@ -1268,24 +1269,15 @@ bool GpuImageDecodeCache::IsInInUseCacheForTesting(
}
void GpuImageDecodeCache::OnMemoryStateChange(base::MemoryState state) {
- switch (state) {
- case base::MemoryState::NORMAL:
- memory_state_ = state;
- break;
- case base::MemoryState::THROTTLED:
- case base::MemoryState::SUSPENDED: {
- memory_state_ = state;
-
- // We've just changed our memory state to a (potentially) more
- // restrictive one. Re-enforce cache limits.
- base::AutoLock lock(lock_);
- EnsureCapacity(0);
- break;
- }
- case base::MemoryState::UNKNOWN:
- // NOT_REACHED.
- break;
- }
+ memory_state_ = state;
+}
+
+void GpuImageDecodeCache::OnPurgeMemory() {
+ base::AutoLock lock(lock_);
+ // Temporary changes |memory_state_| to free up cache as much as possible.
+ base::AutoReset<base::MemoryState> reset(&memory_state_,
+ base::MemoryState::SUSPENDED);
+ EnsureCapacity(0);
bashi 2017/02/07 00:58:59 It seems EnsureCapacity() changes its behavior bas
ericrk 2017/02/07 19:20:14 Does the coordinator call OnMemoryStateChange(SUSP
bashi 2017/02/09 00:46:18 Thanks. I wasn't aware of the race. Current order
ericrk 2017/02/09 18:36:30 I'm good re-visitng later - once we get to enablin
}
} // namespace cc
« no previous file with comments | « cc/tiles/gpu_image_decode_cache.h ('k') | cc/tiles/gpu_image_decode_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698