| Index: cc/resources/resource_pool.cc
|
| diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc
|
| index 469f790f28c0ecdc40447f11cbd06a765366c896..6eeccf22f4b9a1db3a4ff43af88d3c7598fbb981 100644
|
| --- a/cc/resources/resource_pool.cc
|
| +++ b/cc/resources/resource_pool.cc
|
| @@ -211,14 +211,28 @@ Resource* ResourcePool::TryAcquireResourceForPartialRaster(
|
| return nullptr;
|
| }
|
|
|
| +void ResourcePool::ReleaseResourceIfFound(ResourceId resource_id) {
|
| + auto it = in_use_resources_.find(resource_id);
|
| + if (it == in_use_resources_.end())
|
| + return;
|
| + ReleaseResource(resource_id);
|
| +}
|
| +
|
| void ResourcePool::ReleaseResource(Resource* resource) {
|
| // Ensure that the provided resource is valid.
|
| // TODO(ericrk): Remove this once we've investigated further.
|
| // crbug.com/598286.
|
| CHECK(resource);
|
| - CHECK(resource->id());
|
| + ReleaseResource(resource->id());
|
| +}
|
| +
|
| +void ResourcePool::ReleaseResource(ResourceId resource_id) {
|
| + // Ensure that the provided resource is valid.
|
| + // TODO(ericrk): Remove this once we've investigated further.
|
| + // crbug.com/598286.
|
| + CHECK(resource_id);
|
|
|
| - auto it = in_use_resources_.find(resource->id());
|
| + auto it = in_use_resources_.find(resource_id);
|
| if (it == in_use_resources_.end()) {
|
| // We should never hit this. Do some digging to try to determine the cause.
|
| // TODO(ericrk): Remove this once we've investigated further.
|
| @@ -228,16 +242,16 @@ void ResourcePool::ReleaseResource(Resource* resource) {
|
| // list.
|
| auto found_busy = std::find_if(
|
| busy_resources_.begin(), busy_resources_.end(),
|
| - [resource](const std::unique_ptr<PoolResource>& busy_resource) {
|
| - return busy_resource->id() == resource->id();
|
| + [resource_id](const std::unique_ptr<PoolResource>& busy_resource) {
|
| + return busy_resource->id() == resource_id;
|
| });
|
| CHECK(found_busy == busy_resources_.end());
|
|
|
| // Also check if the resource exists in our unused resources list.
|
| auto found_unused = std::find_if(
|
| unused_resources_.begin(), unused_resources_.end(),
|
| - [resource](const std::unique_ptr<PoolResource>& pool_resource) {
|
| - return pool_resource->id() == resource->id();
|
| + [resource_id](const std::unique_ptr<PoolResource>& pool_resource) {
|
| + return pool_resource->id() == resource_id;
|
| });
|
| CHECK(found_unused == unused_resources_.end());
|
|
|
|
|