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

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

Issue 2648323005: memory coordinator: Add MemoryCoordinatorClient::OnPurgeMemory() (Closed)
Patch Set: Created 3 years, 11 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 for (const auto& resource : busy_resources_) { 473 for (const auto& resource : busy_resources_) {
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::OnPurgeMemory() {
484 switch (state) { 484 // Release all resources, regardless of how recently they were used.
485 case base::MemoryState::NORMAL: 485 EvictResourcesNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
486 // TODO(tasak): go back to normal state.
487 break;
488 case base::MemoryState::THROTTLED:
489 // TODO(tasak): make the limits of this component's caches smaller to
490 // save memory usage.
491 break;
492 case base::MemoryState::SUSPENDED:
493 // Release all resources, regardless of how recently they were used.
494 EvictResourcesNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
495 break;
496 case base::MemoryState::UNKNOWN:
497 // NOT_REACHED.
498 break;
499 }
500 } 486 }
501 487
502 } // namespace cc 488 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698