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

Side by Side Diff: Source/platform/graphics/ImageDecodingStore.cpp

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add type check for initial value Created 5 years, 11 months 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 unified diff | Download patch
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 ImageDecodingStore::~ImageDecodingStore() 46 ImageDecodingStore::~ImageDecodingStore()
47 { 47 {
48 #if ENABLE(ASSERT) 48 #if ENABLE(ASSERT)
49 setCacheLimitInBytes(0); 49 setCacheLimitInBytes(0);
50 ASSERT(!m_decoderCacheMap.size()); 50 ASSERT(!m_decoderCacheMap.size());
51 ASSERT(!m_orderedCacheList.size()); 51 ASSERT(!m_orderedCacheList.size());
52 ASSERT(!m_decoderCacheKeyMap.size()); 52 ASSERT(!m_decoderCacheKeyMap.size());
53 #endif 53 #endif
54 } 54 }
55 55
56 ImageDecodingStore* ImageDecodingStore::instance() 56 ImageDecodingStore& ImageDecodingStore::instance()
57 { 57 {
58 AtomicallyInitializedStatic(ImageDecodingStore*, store = ImageDecodingStore: :create().leakPtr()); 58 AtomicallyInitializedStaticReference(ImageDecodingStore, store, ImageDecodin gStore::create().leakPtr());
59 return store; 59 return store;
60 } 60 }
61 61
62 bool ImageDecodingStore::lockDecoder(const ImageFrameGenerator* generator, const SkISize& scaledSize, ImageDecoder** decoder) 62 bool ImageDecodingStore::lockDecoder(const ImageFrameGenerator* generator, const SkISize& scaledSize, ImageDecoder** decoder)
63 { 63 {
64 ASSERT(decoder); 64 ASSERT(decoder);
65 65
66 MutexLocker lock(m_mutex); 66 MutexLocker lock(m_mutex);
67 DecoderCacheMap::iterator iter = m_decoderCacheMap.find(DecoderCacheEntry::m akeCacheKey(generator, scaledSize)); 67 DecoderCacheMap::iterator iter = m_decoderCacheMap.find(DecoderCacheEntry::m akeCacheKey(generator, scaledSize));
68 if (iter == m_decoderCacheMap.end()) 68 if (iter == m_decoderCacheMap.end())
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 282 }
283 } 283 }
284 284
285 void ImageDecodingStore::removeFromCacheListInternal(const Vector<OwnPtr<CacheEn try>>& deletionList) 285 void ImageDecodingStore::removeFromCacheListInternal(const Vector<OwnPtr<CacheEn try>>& deletionList)
286 { 286 {
287 for (size_t i = 0; i < deletionList.size(); ++i) 287 for (size_t i = 0; i < deletionList.size(); ++i)
288 m_orderedCacheList.remove(deletionList[i].get()); 288 m_orderedCacheList.remove(deletionList[i].get());
289 } 289 }
290 290
291 } // namespace blink 291 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698