| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 format); | 123 format); |
| 124 } | 124 } |
| 125 | 125 |
| 126 DCHECK(ResourceUtil::VerifySizeInBytes<size_t>(pool_resource->size(), | 126 DCHECK(ResourceUtil::VerifySizeInBytes<size_t>(pool_resource->size(), |
| 127 pool_resource->format())); | 127 pool_resource->format())); |
| 128 total_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( | 128 total_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( |
| 129 pool_resource->size(), pool_resource->format()); | 129 pool_resource->size(), pool_resource->format()); |
| 130 ++total_resource_count_; | 130 ++total_resource_count_; |
| 131 | 131 |
| 132 Resource* resource = pool_resource.get(); | 132 Resource* resource = pool_resource.get(); |
| 133 in_use_resources_.set(resource->id(), pool_resource.Pass()); | 133 in_use_resources_.set(resource->id(), std::move(pool_resource)); |
| 134 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( | 134 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( |
| 135 resource->size(), resource->format()); | 135 resource->size(), resource->format()); |
| 136 return resource; | 136 return resource; |
| 137 } | 137 } |
| 138 | 138 |
| 139 Resource* ResourcePool::TryAcquireResourceWithContentId(uint64_t content_id) { | 139 Resource* ResourcePool::TryAcquireResourceWithContentId(uint64_t content_id) { |
| 140 DCHECK(content_id); | 140 DCHECK(content_id); |
| 141 | 141 |
| 142 auto it = | 142 auto it = |
| 143 std::find_if(unused_resources_.begin(), unused_resources_.end(), | 143 std::find_if(unused_resources_.begin(), unused_resources_.end(), |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // Remove lost resources from pool. | 227 // Remove lost resources from pool. |
| 228 DeleteResource(it->Pass()); | 228 DeleteResource(it->Pass()); |
| 229 busy_resources_.erase(it); | 229 busy_resources_.erase(it); |
| 230 } else { | 230 } else { |
| 231 ++i; | 231 ++i; |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 void ResourcePool::DidFinishUsingResource(scoped_ptr<PoolResource> resource) { | 236 void ResourcePool::DidFinishUsingResource(scoped_ptr<PoolResource> resource) { |
| 237 unused_resources_.push_front(resource.Pass()); | 237 unused_resources_.push_front(std::move(resource)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void ResourcePool::ScheduleEvictExpiredResourcesIn( | 240 void ResourcePool::ScheduleEvictExpiredResourcesIn( |
| 241 base::TimeDelta time_from_now) { | 241 base::TimeDelta time_from_now) { |
| 242 if (evict_expired_resources_pending_) | 242 if (evict_expired_resources_pending_) |
| 243 return; | 243 return; |
| 244 | 244 |
| 245 evict_expired_resources_pending_ = true; | 245 evict_expired_resources_pending_ = true; |
| 246 | 246 |
| 247 task_runner_->PostDelayedTask(FROM_HERE, | 247 task_runner_->PostDelayedTask(FROM_HERE, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 for (const auto& resource : busy_resources_) { | 309 for (const auto& resource : busy_resources_) { |
| 310 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); | 310 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); |
| 311 } | 311 } |
| 312 for (const auto& entry : in_use_resources_) { | 312 for (const auto& entry : in_use_resources_) { |
| 313 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); | 313 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); |
| 314 } | 314 } |
| 315 return true; | 315 return true; |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace cc | 318 } // namespace cc |
| OLD | NEW |