| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |