Index: cc/resources/resource_pool.cc |
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc |
index aa2ddc5de0f172f0a29de09378950b9ffdb897ea..b020497d089120945e804ec9a4666b9911d38803 100644 |
--- a/cc/resources/resource_pool.cc |
+++ b/cc/resources/resource_pool.cc |
@@ -94,21 +94,26 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size, |
// Finding resources in |unused_resources_| from MRU to LRU direction, touches |
// LRU resources only if needed, which increases possibility of expiring more |
// LRU resources within kResourceExpirationDelayMs. |
- for (ResourceDeque::iterator it = unused_resources_.begin(); |
- it != unused_resources_.end(); ++it) { |
- ScopedResource* resource = *it; |
- DCHECK(resource_provider_->CanLockForWrite(resource->id())); |
- |
- if (resource->format() != format) |
- continue; |
- if (resource->size() != size) |
- continue; |
- |
- // Transfer resource to |in_use_resources_|. |
- in_use_resources_.set(resource->id(), unused_resources_.take(it)); |
- in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( |
- resource->size(), resource->format()); |
- return resource; |
+ { |
+ TRACE_EVENT1("cc, pras", "ResourcePool::AcquireResource", "total_unused", |
+ unused_resources_.size()); |
+ |
+ for (ResourceDeque::iterator it = unused_resources_.begin(); |
+ it != unused_resources_.end(); ++it) { |
+ ScopedResource* resource = *it; |
+ DCHECK(resource_provider_->CanLockForWrite(resource->id())); |
+ |
+ if (resource->format() != format) |
+ continue; |
+ if (resource->size() != size) |
+ continue; |
+ |
+ // Transfer resource to |in_use_resources_|. |
+ in_use_resources_.set(resource->id(), unused_resources_.take(it)); |
+ in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( |
+ resource->size(), resource->format()); |
+ return resource; |
+ } |
} |
scoped_ptr<PoolResource> pool_resource = |
@@ -133,10 +138,16 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size, |
Resource* ResourcePool::TryAcquireResourceWithContentId(uint64_t content_id) { |
DCHECK(content_id); |
+ TRACE_EVENT_BEGIN1("cc, pras", "ResourcePool::TryAcquireResource", |
+ "total_unused", unused_resources_.size()); |
+ |
auto it = std::find_if(unused_resources_.begin(), unused_resources_.end(), |
[content_id](const PoolResource* pool_resource) { |
return pool_resource->content_id() == content_id; |
}); |
+ |
+ TRACE_EVENT_END0("cc, pras", "ResourcePool::TryAcquireResource"); |
+ |
if (it == unused_resources_.end()) |
return nullptr; |
@@ -224,6 +235,7 @@ void ResourcePool::CheckBusyResources() { |
} |
void ResourcePool::DidFinishUsingResource(scoped_ptr<PoolResource> resource) { |
+ TRACE_EVENT0("cc, pras", "ResourcePool::DidFinishUsingResource"); |
unused_resources_.push_front(resource.Pass()); |
} |