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

Unified Diff: cc/resources/resource_pool.cc

Issue 2367953002: Implement OnMemoryStateChange for Various CC Classes (Closed)
Patch Set: Created 4 years, 3 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/resources/resource_pool.cc
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc
index 5e6e426871cf63229841e7e75d4b94f731a39033..05591c3b3d7122ae740c2a64f34474b38b7beab9 100644
--- a/cc/resources/resource_pool.cc
+++ b/cc/resources/resource_pool.cc
@@ -469,8 +469,15 @@ void ResourcePool::OnMemoryStateChange(base::MemoryState state) {
// save memory usage.
break;
case base::MemoryState::SUSPENDED:
- // TODO(tasak): free this component's caches as much as possible before
- // suspending renderer.
+ // We are only ever SUSPENDED while in the background. While in the
+ // background, ResourcePool already has zero memory limits and should not
+ // be holding any resources that aren't actively in use.
+ DCHECK_EQ(0, unused_resources_.size());
vmpstr 2016/09/23 20:59:10 Are we guaranteed that we receive this signal afte
ericrk 2016/09/23 21:26:15 My understanding was that we are only suspended wh
+
+ // The following call will drop additional busy resources. There is no
+ // negative to this other than temporary incorrect accounting, and it
+ // ensures the resource is freed as soon as possible.
+ EvictResourcesNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
break;
case base::MemoryState::UNKNOWN:
// NOT_REACHED.

Powered by Google App Engine
This is Rietveld 408576698