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

Side by Side Diff: cc/resources/resource_pool.cc

Issue 2664703002: Move purging from OnMemoryState to OnPurgeMemory() in cc/ (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/resources/resource_pool.h" 5 #include "cc/resources/resource_pool.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); 474 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
475 } 475 }
476 for (const auto& entry : in_use_resources_) { 476 for (const auto& entry : in_use_resources_) {
477 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); 477 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
478 } 478 }
479 } 479 }
480 return true; 480 return true;
481 } 481 }
482 482
483 void ResourcePool::OnMemoryStateChange(base::MemoryState state) { 483 void ResourcePool::OnMemoryStateChange(base::MemoryState state) {
484 switch (state) { 484 // TODO(bashi): We are going to separate purging from state changes and we
485 case base::MemoryState::NORMAL: 485 // shouldn't purge memory here (crbug.com/684287). Tentatively call
486 // TODO(tasak): go back to normal state. 486 // OnPurgeMemory() so that we don't break existing experiments.
487 break; 487 // (i.e. purge+suspend experiment)
488 case base::MemoryState::THROTTLED: 488 if (state == base::MemoryState::SUSPENDED)
489 // TODO(tasak): make the limits of this component's caches smaller to 489 OnPurgeMemory();
490 // save memory usage. 490 }
491 break; 491
492 case base::MemoryState::SUSPENDED: 492 void ResourcePool::OnPurgeMemory() {
493 // Release all resources, regardless of how recently they were used. 493 // Release all resources, regardless of how recently they were used.
494 EvictResourcesNotUsedSince(base::TimeTicks() + base::TimeDelta::Max()); 494 EvictResourcesNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
495 break;
496 case base::MemoryState::UNKNOWN:
497 // NOT_REACHED.
498 break;
499 }
500 } 495 }
501 496
502 } // namespace cc 497 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698