| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 time_from_now); | 403 time_from_now); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void ResourcePool::EvictExpiredResources() { | 406 void ResourcePool::EvictExpiredResources() { |
| 407 evict_expired_resources_pending_ = false; | 407 evict_expired_resources_pending_ = false; |
| 408 base::TimeTicks current_time = base::TimeTicks::Now(); | 408 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 409 | 409 |
| 410 EvictResourcesNotUsedSince(current_time - resource_expiration_delay_); | 410 EvictResourcesNotUsedSince(current_time - resource_expiration_delay_); |
| 411 | 411 |
| 412 if (unused_resources_.empty() && busy_resources_.empty()) { | 412 if (unused_resources_.empty() && busy_resources_.empty()) { |
| 413 // Nothing is evictable. | 413 // If nothing is evictable, we have deleted one (and possibly more) |
| 414 // resources without any new activity. Flush to ensure these deletions are |
| 415 // processed. |
| 416 resource_provider_->FlushPendingDeletions(); |
| 414 return; | 417 return; |
| 415 } | 418 } |
| 416 | 419 |
| 417 // If we still have evictable resources, schedule a call to | 420 // If we still have evictable resources, schedule a call to |
| 418 // EvictExpiredResources at the time when the LRU buffer expires. | 421 // EvictExpiredResources at the time when the LRU buffer expires. |
| 419 ScheduleEvictExpiredResourcesIn(GetUsageTimeForLRUResource() + | 422 ScheduleEvictExpiredResourcesIn(GetUsageTimeForLRUResource() + |
| 420 resource_expiration_delay_ - current_time); | 423 resource_expiration_delay_ - current_time); |
| 421 } | 424 } |
| 422 | 425 |
| 423 void ResourcePool::EvictResourcesNotUsedSince(base::TimeTicks time_limit) { | 426 void ResourcePool::EvictResourcesNotUsedSince(base::TimeTicks time_limit) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // Release all resources, regardless of how recently they were used. | 493 // Release all resources, regardless of how recently they were used. |
| 491 EvictResourcesNotUsedSince(base::TimeTicks() + base::TimeDelta::Max()); | 494 EvictResourcesNotUsedSince(base::TimeTicks() + base::TimeDelta::Max()); |
| 492 break; | 495 break; |
| 493 case base::MemoryState::UNKNOWN: | 496 case base::MemoryState::UNKNOWN: |
| 494 // NOT_REACHED. | 497 // NOT_REACHED. |
| 495 break; | 498 break; |
| 496 } | 499 } |
| 497 } | 500 } |
| 498 | 501 |
| 499 } // namespace cc | 502 } // namespace cc |
| OLD | NEW |