Index: third_party/WebKit/Source/platform/graphics/ImageDecodingStore.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/ImageDecodingStore.cpp b/third_party/WebKit/Source/platform/graphics/ImageDecodingStore.cpp |
index 54ab435049c973ce1514b63221ce44e45ebbd55e..a181e9e3f101c22bb26ce0b904cdda73a2cca782 100644 |
--- a/third_party/WebKit/Source/platform/graphics/ImageDecodingStore.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/ImageDecodingStore.cpp |
@@ -28,6 +28,7 @@ |
#include "platform/TraceEvent.h" |
#include "platform/graphics/ImageFrameGenerator.h" |
#include "wtf/Threading.h" |
+#include <memory> |
namespace blink { |
@@ -55,7 +56,7 @@ ImageDecodingStore::~ImageDecodingStore() |
ImageDecodingStore& ImageDecodingStore::instance() |
{ |
- DEFINE_THREAD_SAFE_STATIC_LOCAL(ImageDecodingStore, store, ImageDecodingStore::create().leakPtr()); |
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(ImageDecodingStore, store, ImageDecodingStore::create().release()); |
return store; |
} |
@@ -91,12 +92,12 @@ void ImageDecodingStore::unlockDecoder(const ImageFrameGenerator* generator, con |
m_orderedCacheList.append(cacheEntry); |
} |
-void ImageDecodingStore::insertDecoder(const ImageFrameGenerator* generator, PassOwnPtr<ImageDecoder> decoder) |
+void ImageDecodingStore::insertDecoder(const ImageFrameGenerator* generator, std::unique_ptr<ImageDecoder> decoder) |
{ |
// Prune old cache entries to give space for the new one. |
prune(); |
- OwnPtr<DecoderCacheEntry> newCacheEntry = DecoderCacheEntry::create(generator, std::move(decoder)); |
+ std::unique_ptr<DecoderCacheEntry> newCacheEntry = DecoderCacheEntry::create(generator, std::move(decoder)); |
MutexLocker lock(m_mutex); |
ASSERT(!m_decoderCacheMap.contains(newCacheEntry->cacheKey())); |
@@ -105,7 +106,7 @@ void ImageDecodingStore::insertDecoder(const ImageFrameGenerator* generator, Pas |
void ImageDecodingStore::removeDecoder(const ImageFrameGenerator* generator, const ImageDecoder* decoder) |
{ |
- Vector<OwnPtr<CacheEntry>> cacheEntriesToDelete; |
+ Vector<std::unique_ptr<CacheEntry>> cacheEntriesToDelete; |
{ |
MutexLocker lock(m_mutex); |
DecoderCacheMap::iterator iter = m_decoderCacheMap.find(DecoderCacheEntry::makeCacheKey(generator, decoder)); |
@@ -127,7 +128,7 @@ void ImageDecodingStore::removeDecoder(const ImageFrameGenerator* generator, con |
void ImageDecodingStore::removeCacheIndexedByGenerator(const ImageFrameGenerator* generator) |
{ |
- Vector<OwnPtr<CacheEntry>> cacheEntriesToDelete; |
+ Vector<std::unique_ptr<CacheEntry>> cacheEntriesToDelete; |
{ |
MutexLocker lock(m_mutex); |
@@ -182,7 +183,7 @@ void ImageDecodingStore::prune() |
{ |
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.image_decoding"), "ImageDecodingStore::prune"); |
- Vector<OwnPtr<CacheEntry>> cacheEntriesToDelete; |
+ Vector<std::unique_ptr<CacheEntry>> cacheEntriesToDelete; |
{ |
MutexLocker lock(m_mutex); |
@@ -208,7 +209,7 @@ void ImageDecodingStore::prune() |
} |
template<class T, class U, class V> |
-void ImageDecodingStore::insertCacheInternal(PassOwnPtr<T> cacheEntry, U* cacheMap, V* identifierMap) |
+void ImageDecodingStore::insertCacheInternal(std::unique_ptr<T> cacheEntry, U* cacheMap, V* identifierMap) |
{ |
const size_t cacheEntryBytes = cacheEntry->memoryUsageInBytes(); |
m_heapMemoryUsageInBytes += cacheEntryBytes; |
@@ -227,7 +228,7 @@ void ImageDecodingStore::insertCacheInternal(PassOwnPtr<T> cacheEntry, U* cacheM |
} |
template<class T, class U, class V> |
-void ImageDecodingStore::removeFromCacheInternal(const T* cacheEntry, U* cacheMap, V* identifierMap, Vector<OwnPtr<CacheEntry>>* deletionList) |
+void ImageDecodingStore::removeFromCacheInternal(const T* cacheEntry, U* cacheMap, V* identifierMap, Vector<std::unique_ptr<CacheEntry>>* deletionList) |
{ |
const size_t cacheEntryBytes = cacheEntry->memoryUsageInBytes(); |
ASSERT(m_heapMemoryUsageInBytes >= cacheEntryBytes); |
@@ -247,7 +248,7 @@ void ImageDecodingStore::removeFromCacheInternal(const T* cacheEntry, U* cacheMa |
TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink.image_decoding"), "ImageDecodingStoreNumOfDecoders", m_decoderCacheMap.size()); |
} |
-void ImageDecodingStore::removeFromCacheInternal(const CacheEntry* cacheEntry, Vector<OwnPtr<CacheEntry>>* deletionList) |
+void ImageDecodingStore::removeFromCacheInternal(const CacheEntry* cacheEntry, Vector<std::unique_ptr<CacheEntry>>* deletionList) |
{ |
if (cacheEntry->type() == CacheEntry::TypeDecoder) { |
removeFromCacheInternal(static_cast<const DecoderCacheEntry*>(cacheEntry), &m_decoderCacheMap, &m_decoderCacheKeyMap, deletionList); |
@@ -257,7 +258,7 @@ void ImageDecodingStore::removeFromCacheInternal(const CacheEntry* cacheEntry, V |
} |
template<class U, class V> |
-void ImageDecodingStore::removeCacheIndexedByGeneratorInternal(U* cacheMap, V* identifierMap, const ImageFrameGenerator* generator, Vector<OwnPtr<CacheEntry>>* deletionList) |
+void ImageDecodingStore::removeCacheIndexedByGeneratorInternal(U* cacheMap, V* identifierMap, const ImageFrameGenerator* generator, Vector<std::unique_ptr<CacheEntry>>* deletionList) |
{ |
typename V::iterator iter = identifierMap->find(generator); |
if (iter == identifierMap->end()) |
@@ -270,13 +271,13 @@ void ImageDecodingStore::removeCacheIndexedByGeneratorInternal(U* cacheMap, V* i |
// For each cache identifier find the corresponding CacheEntry and remove it. |
for (size_t i = 0; i < cacheIdentifierList.size(); ++i) { |
ASSERT(cacheMap->contains(cacheIdentifierList[i])); |
- const typename U::MappedType::PtrType cacheEntry = cacheMap->get(cacheIdentifierList[i]); |
+ const auto& cacheEntry = cacheMap->get(cacheIdentifierList[i]); |
ASSERT(!cacheEntry->useCount()); |
removeFromCacheInternal(cacheEntry, cacheMap, identifierMap, deletionList); |
} |
} |
-void ImageDecodingStore::removeFromCacheListInternal(const Vector<OwnPtr<CacheEntry>>& deletionList) |
+void ImageDecodingStore::removeFromCacheListInternal(const Vector<std::unique_ptr<CacheEntry>>& deletionList) |
{ |
for (size_t i = 0; i < deletionList.size(); ++i) |
m_orderedCacheList.remove(deletionList[i].get()); |