Replace DEPRECATED_DEFINE_STATIC_LOCAL by static NeverDestroyed<T> in loader
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Mar 2014 08:38:23 +0000 (08:38 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Mar 2014 08:38:23 +0000 (08:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130893

Reviewed by Darin Adler.

* loader/ImageLoader.cpp:
(WebCore::beforeLoadEventSender):
(WebCore::loadEventSender):
(WebCore::errorEventSender):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::cacheStorage):
* loader/appcache/ApplicationCacheStorage.h:
* loader/archive/ArchiveFactory.cpp:
(WebCore::archiveMIMETypes):
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::brokenImage):
* loader/cache/CachedRawResource.cpp:
(WebCore::shouldIgnoreHeaderForCacheReuse):
* loader/cache/MemoryCache.cpp:
(WebCore::dummyCachedImageClient):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166488 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp
Source/WebCore/loader/appcache/ApplicationCacheStorage.h
Source/WebCore/loader/archive/ArchiveFactory.cpp
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedRawResource.cpp
Source/WebCore/loader/cache/MemoryCache.cpp

index 36f5fc3..5b26030 100644 (file)
@@ -1,5 +1,28 @@
 2014-03-28  Sergio Villar Senin  <svillar@igalia.com>
 
+        Replace DEPRECATED_DEFINE_STATIC_LOCAL by static NeverDestroyed<T> in loader
+        https://bugs.webkit.org/show_bug.cgi?id=130893
+
+        Reviewed by Darin Adler.
+
+        * loader/ImageLoader.cpp:
+        (WebCore::beforeLoadEventSender):
+        (WebCore::loadEventSender):
+        (WebCore::errorEventSender):
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::cacheStorage):
+        * loader/appcache/ApplicationCacheStorage.h:
+        * loader/archive/ArchiveFactory.cpp:
+        (WebCore::archiveMIMETypes):
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::brokenImage):
+        * loader/cache/CachedRawResource.cpp:
+        (WebCore::shouldIgnoreHeaderForCacheReuse):
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::dummyCachedImageClient):
+
+2014-03-28  Sergio Villar Senin  <svillar@igalia.com>
+
         Replace DEPRECATED_DEFINE_STATIC_LOCAL by static NeverDestroyed<T> in css
         https://bugs.webkit.org/show_bug.cgi?id=130409
 
index 834963c..7d94fc8 100644 (file)
@@ -38,6 +38,7 @@
 #include "RenderImage.h"
 #include "RenderSVGImage.h"
 #include "SecurityOrigin.h"
+#include <wtf/NeverDestroyed.h>
 
 #if ENABLE(VIDEO)
 #include "RenderVideo.h"
@@ -64,19 +65,19 @@ namespace WebCore {
 
 static ImageEventSender& beforeLoadEventSender()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(ImageEventSender, sender, (eventNames().beforeloadEvent));
+    static NeverDestroyed<ImageEventSender> sender(eventNames().beforeloadEvent);
     return sender;
 }
 
 static ImageEventSender& loadEventSender()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(ImageEventSender, sender, (eventNames().loadEvent));
+    static NeverDestroyed<ImageEventSender> sender(eventNames().loadEvent);
     return sender;
 }
 
 static ImageEventSender& errorEventSender()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(ImageEventSender, sender, (eventNames().errorEvent));
+    static NeverDestroyed<ImageEventSender> sender(eventNames().errorEvent);
     return sender;
 }
 
index 6a474dd..7ba7109 100644 (file)
@@ -38,6 +38,7 @@
 #include "SecurityOrigin.h"
 #include "URL.h"
 #include "UUID.h"
+#include <wtf/NeverDestroyed.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/StringExtras.h>
 #include <wtf/text/CString.h>
@@ -1599,8 +1600,7 @@ ApplicationCacheStorage::ApplicationCacheStorage()
 
 ApplicationCacheStorage& cacheStorage()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(ApplicationCacheStorage, storage, ());
-    
+    static NeverDestroyed<ApplicationCacheStorage> storage;
     return storage;
 }
 
index 76eaa3e..4b96d71 100644 (file)
@@ -147,11 +147,11 @@ private:
     typedef HashMap<String, ApplicationCacheGroup*> CacheGroupMap;
     CacheGroupMap m_cachesInMemory; // Excludes obsolete cache groups.
 
-    friend ApplicationCacheStorage& cacheStorage();
+    friend class WTF::NeverDestroyed<ApplicationCacheStorage>;
 };
+
 ApplicationCacheStorage& cacheStorage();
-    
+
 } // namespace WebCore
 
 #endif // ApplicationCacheStorage_h
index 1022345..548150c 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/WTFString.h>
 
@@ -57,7 +58,7 @@ template <typename ArchiveClass> static PassRefPtr<Archive> archiveFactoryCreate
 
 static ArchiveMIMETypesMap& archiveMIMETypes()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(ArchiveMIMETypesMap, mimeTypes, ());
+    static NeverDestroyed<ArchiveMIMETypesMap> mimeTypes;
     static bool initialized = false;
 
     if (initialized)
@@ -66,11 +67,11 @@ static ArchiveMIMETypesMap& archiveMIMETypes()
     // FIXME: Remove unnecessary 'static_cast<RawDataCreationFunction*>' from the following 'mimeTypes.set' operations
     // once we switch to a non-broken Visual Studio compiler.  https://bugs.webkit.org/show_bug.cgi?id=121235
 #if ENABLE(WEB_ARCHIVE) && USE(CF)
-    mimeTypes.set("application/x-webarchive", static_cast<RawDataCreationFunction*>(&archiveFactoryCreate<LegacyWebArchive>));
+    mimeTypes.get().set("application/x-webarchive", static_cast<RawDataCreationFunction*>(&archiveFactoryCreate<LegacyWebArchive>));
 #endif
 #if ENABLE(MHTML)
-    mimeTypes.set("multipart/related", static_cast<RawDataCreationFunction*>(&archiveFactoryCreate<MHTMLArchive>));
-    mimeTypes.set("application/x-mimearchive", static_cast<RawDataCreationFunction*>(&archiveFactoryCreate<MHTMLArchive>));
+    mimeTypes.get().set("multipart/related", static_cast<RawDataCreationFunction*>(&archiveFactoryCreate<MHTMLArchive>));
+    mimeTypes.get().set("application/x-mimearchive", static_cast<RawDataCreationFunction*>(&archiveFactoryCreate<MHTMLArchive>));
 #endif
 
     initialized = true;
index 67519b4..b8f6f0a 100644 (file)
@@ -43,6 +43,7 @@
 #include "Settings.h"
 #include "SubresourceLoader.h"
 #include <wtf/CurrentTime.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Vector.h>
 
@@ -175,11 +176,11 @@ void CachedImage::allClientsRemoved()
 std::pair<Image*, float> CachedImage::brokenImage(float deviceScaleFactor) const
 {
     if (deviceScaleFactor >= 2) {
-        DEPRECATED_DEFINE_STATIC_LOCAL(Image*, brokenImageHiRes, (Image::loadPlatformResource("missingImage@2x").leakRef()));
+        static NeverDestroyed<Image*> brokenImageHiRes(Image::loadPlatformResource("missingImage@2x").leakRef());
         return std::make_pair(brokenImageHiRes, 2);
     }
 
-    DEPRECATED_DEFINE_STATIC_LOCAL(Image*, brokenImageLoRes, (Image::loadPlatformResource("missingImage").leakRef()));
+    static NeverDestroyed<Image*> brokenImageLoRes(Image::loadPlatformResource("missingImage").leakRef());
     return std::make_pair(brokenImageLoRes, 1);
 }
 
index 6f539d2..66e9ed7 100644 (file)
@@ -31,6 +31,7 @@
 #include "CachedResourceLoader.h"
 #include "ResourceBuffer.h"
 #include "SubresourceLoader.h"
+#include <wtf/NeverDestroyed.h>
 #include <wtf/PassRefPtr.h>
 
 namespace WebCore {
@@ -201,17 +202,17 @@ void CachedRawResource::setDataBufferingPolicy(DataBufferingPolicy dataBuffering
 static bool shouldIgnoreHeaderForCacheReuse(AtomicString headerName)
 {
     // FIXME: This list of headers that don't affect cache policy almost certainly isn't complete.
-    DEPRECATED_DEFINE_STATIC_LOCAL(HashSet<AtomicString>, m_headers, ());
-    if (m_headers.isEmpty()) {
-        m_headers.add("Accept");
-        m_headers.add("Cache-Control");
-        m_headers.add("Origin");
-        m_headers.add("Pragma");
-        m_headers.add("Purpose");
-        m_headers.add("Referer");
-        m_headers.add("User-Agent");
+    static NeverDestroyed<HashSet<AtomicString>> m_headers;
+    if (m_headers.get().isEmpty()) {
+        m_headers.get().add("Accept");
+        m_headers.get().add("Cache-Control");
+        m_headers.get().add("Origin");
+        m_headers.get().add("Pragma");
+        m_headers.get().add("Purpose");
+        m_headers.get().add("Referer");
+        m_headers.get().add("User-Agent");
     }
-    return m_headers.contains(headerName);
+    return m_headers.get().contains(headerName);
 }
 
 bool CachedRawResource::canReuse(const ResourceRequest& newRequest) const
index a9a0553..9742e5f 100644 (file)
@@ -44,6 +44,7 @@
 #include <stdio.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MathExtras.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/TemporaryChange.h>
 #include <wtf/text/CString.h>
 
@@ -242,7 +243,7 @@ unsigned MemoryCache::liveCapacity() const
 // remove the usage of CFRetain() in MemoryCache::addImageToCache() so as to make the code platform-independent.
 static CachedImageClient& dummyCachedImageClient()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(CachedImageClient, client, ());
+    static NeverDestroyed<CachedImageClient> client;
     return client;
 }