| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 cacheEntry->incrementUseCount(); | 75 cacheEntry->incrementUseCount(); |
| 76 *decoder = cacheEntry->cachedDecoder(); | 76 *decoder = cacheEntry->cachedDecoder(); |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ImageDecodingStore::unlockDecoder(const ImageFrameGenerator* generator, | 80 void ImageDecodingStore::unlockDecoder(const ImageFrameGenerator* generator, |
| 81 const ImageDecoder* decoder) { | 81 const ImageDecoder* decoder) { |
| 82 MutexLocker lock(m_mutex); | 82 MutexLocker lock(m_mutex); |
| 83 DecoderCacheMap::iterator iter = m_decoderCacheMap.find( | 83 DecoderCacheMap::iterator iter = m_decoderCacheMap.find( |
| 84 DecoderCacheEntry::makeCacheKey(generator, decoder)); | 84 DecoderCacheEntry::makeCacheKey(generator, decoder)); |
| 85 ASSERT_WITH_SECURITY_IMPLICATION(iter != m_decoderCacheMap.end()); | 85 SECURITY_DCHECK(iter != m_decoderCacheMap.end()); |
| 86 | 86 |
| 87 CacheEntry* cacheEntry = iter->value.get(); | 87 CacheEntry* cacheEntry = iter->value.get(); |
| 88 cacheEntry->decrementUseCount(); | 88 cacheEntry->decrementUseCount(); |
| 89 | 89 |
| 90 // Put the entry to the end of list. | 90 // Put the entry to the end of list. |
| 91 m_orderedCacheList.remove(cacheEntry); | 91 m_orderedCacheList.remove(cacheEntry); |
| 92 m_orderedCacheList.append(cacheEntry); | 92 m_orderedCacheList.append(cacheEntry); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void ImageDecodingStore::insertDecoder(const ImageFrameGenerator* generator, | 95 void ImageDecodingStore::insertDecoder(const ImageFrameGenerator* generator, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 106 &m_decoderCacheKeyMap); | 106 &m_decoderCacheKeyMap); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ImageDecodingStore::removeDecoder(const ImageFrameGenerator* generator, | 109 void ImageDecodingStore::removeDecoder(const ImageFrameGenerator* generator, |
| 110 const ImageDecoder* decoder) { | 110 const ImageDecoder* decoder) { |
| 111 Vector<std::unique_ptr<CacheEntry>> cacheEntriesToDelete; | 111 Vector<std::unique_ptr<CacheEntry>> cacheEntriesToDelete; |
| 112 { | 112 { |
| 113 MutexLocker lock(m_mutex); | 113 MutexLocker lock(m_mutex); |
| 114 DecoderCacheMap::iterator iter = m_decoderCacheMap.find( | 114 DecoderCacheMap::iterator iter = m_decoderCacheMap.find( |
| 115 DecoderCacheEntry::makeCacheKey(generator, decoder)); | 115 DecoderCacheEntry::makeCacheKey(generator, decoder)); |
| 116 ASSERT_WITH_SECURITY_IMPLICATION(iter != m_decoderCacheMap.end()); | 116 SECURITY_DCHECK(iter != m_decoderCacheMap.end()); |
| 117 | 117 |
| 118 CacheEntry* cacheEntry = iter->value.get(); | 118 CacheEntry* cacheEntry = iter->value.get(); |
| 119 ASSERT(cacheEntry->useCount()); | 119 ASSERT(cacheEntry->useCount()); |
| 120 cacheEntry->decrementUseCount(); | 120 cacheEntry->decrementUseCount(); |
| 121 | 121 |
| 122 // Delete only one decoder cache entry. Ownership of the cache entry | 122 // Delete only one decoder cache entry. Ownership of the cache entry |
| 123 // is transfered to cacheEntriesToDelete such that object can be deleted | 123 // is transfered to cacheEntriesToDelete such that object can be deleted |
| 124 // outside of the lock. | 124 // outside of the lock. |
| 125 removeFromCacheInternal(cacheEntry, &cacheEntriesToDelete); | 125 removeFromCacheInternal(cacheEntry, &cacheEntriesToDelete); |
| 126 | 126 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 void ImageDecodingStore::removeFromCacheListInternal( | 299 void ImageDecodingStore::removeFromCacheListInternal( |
| 300 const Vector<std::unique_ptr<CacheEntry>>& deletionList) { | 300 const Vector<std::unique_ptr<CacheEntry>>& deletionList) { |
| 301 for (size_t i = 0; i < deletionList.size(); ++i) | 301 for (size_t i = 0; i < deletionList.size(); ++i) |
| 302 m_orderedCacheList.remove(deletionList[i].get()); | 302 m_orderedCacheList.remove(deletionList[i].get()); |
| 303 } | 303 } |
| 304 | 304 |
| 305 } // namespace blink | 305 } // namespace blink |
| OLD | NEW |