diff options
author | limasdf <limasdf@gmail.com> | 2015-11-24 03:32:11 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-24 11:33:01 +0000 |
commit | cdbfa816b2cae37df31701d0415bac84f414e616 (patch) | |
tree | b140a31ebc4f1358e23865d63e655945e1ae5e13 /cc | |
parent | 0d32d6d30fec43e2ad159193c65ace6636537b23 (diff) | |
download | chromium_src-cdbfa816b2cae37df31701d0415bac84f414e616.zip chromium_src-cdbfa816b2cae37df31701d0415bac84f414e616.tar.gz chromium_src-cdbfa816b2cae37df31701d0415bac84f414e616.tar.bz2 |
Remove ScopedPtrMap from /cc
C++ 11 enables containers that contain move-only type, scoped_ptr.
So, Use std::map<key, scoped_ptr<Foo>> instead of ScopedPtrMap.
BUG=554291
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1462763002
Cr-Commit-Position: refs/heads/master@{#361315}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/resources/resource_pool.cc | 11 | ||||
-rw-r--r-- | cc/resources/resource_pool.h | 5 |
2 files changed, 8 insertions, 8 deletions
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc index ddf71cf..778ddbe 100644 --- a/cc/resources/resource_pool.cc +++ b/cc/resources/resource_pool.cc @@ -106,7 +106,7 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size, continue; // Transfer resource to |in_use_resources_|. - in_use_resources_.set(resource->id(), it->Pass()); + in_use_resources_[resource->id()] = std::move(*it); unused_resources_.erase(it); in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( resource->size(), resource->format()); @@ -130,7 +130,7 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size, ++total_resource_count_; Resource* resource = pool_resource.get(); - in_use_resources_.set(resource->id(), std::move(pool_resource)); + in_use_resources_[resource->id()] = std::move(pool_resource); in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( resource->size(), resource->format()); return resource; @@ -151,7 +151,7 @@ Resource* ResourcePool::TryAcquireResourceWithContentId(uint64_t content_id) { DCHECK(resource_provider_->CanLockForWrite(resource->id())); // Transfer resource to |in_use_resources_|. - in_use_resources_.set(resource->id(), it->Pass()); + in_use_resources_[resource->id()] = std::move(*it); unused_resources_.erase(it); in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( resource->size(), resource->format()); @@ -162,12 +162,13 @@ void ResourcePool::ReleaseResource(Resource* resource, uint64_t content_id) { auto it = in_use_resources_.find(resource->id()); DCHECK(it != in_use_resources_.end()); - PoolResource* pool_resource = it->second; + PoolResource* pool_resource = it->second.get(); pool_resource->set_content_id(content_id); pool_resource->set_last_usage(base::TimeTicks::Now()); // Transfer resource to |busy_resources_|. - busy_resources_.push_front(in_use_resources_.take_and_erase(it)); + busy_resources_.push_front(std::move(it->second)); + in_use_resources_.erase(it); in_use_memory_usage_bytes_ -= ResourceUtil::UncheckedSizeInBytes<size_t>( pool_resource->size(), pool_resource->format()); diff --git a/cc/resources/resource_pool.h b/cc/resources/resource_pool.h index e5a2166..e17032b 100644 --- a/cc/resources/resource_pool.h +++ b/cc/resources/resource_pool.h @@ -6,8 +6,8 @@ #define CC_RESOURCES_RESOURCE_POOL_H_ #include <deque> +#include <map> -#include "base/containers/scoped_ptr_map.h" #include "base/memory/scoped_ptr.h" #include "base/trace_event/memory_dump_provider.h" #include "cc/base/cc_export.h" @@ -120,8 +120,7 @@ class CC_EXPORT ResourcePool : public base::trace_event::MemoryDumpProvider { ResourceDeque unused_resources_; ResourceDeque busy_resources_; - using ResourceMap = base::ScopedPtrMap<ResourceId, scoped_ptr<PoolResource>>; - ResourceMap in_use_resources_; + std::map<ResourceId, scoped_ptr<PoolResource>> in_use_resources_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_; bool evict_expired_resources_pending_; |