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

Unified Diff: cc/resources/resource_pool.cc

Issue 1410833005: Test multideque (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_evict_fix
Patch Set: Erased resource once found and updated test littlebit. Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/resources/resource_pool_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « no previous file | cc/resources/resource_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698