[GTK] Replace DEFINE_STATIC_LOCAL with NeverDestroyed<T> in GTK WK1 and WK2 code
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Feb 2014 09:46:25 +0000 (09:46 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Feb 2014 09:46:25 +0000 (09:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128195

Reviewed by Martin Robinson.

Use static NeverDestroyed<T> variables instead of the DEFINE_STATIC_LOCAL macro.

Source/WebKit/gtk:

* WebCoreSupport/PlatformStrategiesGtk.cpp:
(PlatformStrategiesGtk::initialize):
* WebCoreSupport/PlatformStrategiesGtk.h:
* webkit/webkitwebsettings.cpp:
(isGoogleDomain):

Source/WebKit2:

* UIProcess/API/gtk/WebKitBackForwardListItem.cpp:
(historyItemsMap):
* UIProcess/API/gtk/WebKitWebContext.cpp:
(downloadsMap):
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::pluginWindowMap):
* WebProcess/gtk/WebGtkExtensionManager.cpp:
(WebKit::WebGtkExtensionManager::shared):
* WebProcess/gtk/WebGtkExtensionManager.h:

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

Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/PlatformStrategiesGtk.cpp
Source/WebKit/gtk/WebCoreSupport/PlatformStrategiesGtk.h
Source/WebKit/gtk/webkit/webkitwebsettings.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp
Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp
Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h

index 1ccb093..cf65b29 100644 (file)
@@ -1,3 +1,18 @@
+2014-02-05  Zan Dobersek  <zdobersek@igalia.com>
+
+        [GTK] Replace DEFINE_STATIC_LOCAL with NeverDestroyed<T> in GTK WK1 and WK2 code
+        https://bugs.webkit.org/show_bug.cgi?id=128195
+
+        Reviewed by Martin Robinson.
+
+        Use static NeverDestroyed<T> variables instead of the DEFINE_STATIC_LOCAL macro.
+
+        * WebCoreSupport/PlatformStrategiesGtk.cpp:
+        (PlatformStrategiesGtk::initialize):
+        * WebCoreSupport/PlatformStrategiesGtk.h:
+        * webkit/webkitwebsettings.cpp:
+        (isGoogleDomain):
+
 2014-02-04  Andreas Kling  <akling@apple.com>
 
         Remove <iframe seamless> support.
index c6d1a0b..132d716 100644 (file)
@@ -30,8 +30,8 @@ using namespace WebCore;
 
 void PlatformStrategiesGtk::initialize()
 {
-    DEFINE_STATIC_LOCAL(PlatformStrategiesGtk, platformStrategies, ());
-    setPlatformStrategies(&platformStrategies);
+    static NeverDestroyed<PlatformStrategiesGtk> platformStrategies;
+    setPlatformStrategies(&platformStrategies.get());
 }
 
 PlatformStrategiesGtk::PlatformStrategiesGtk()
index 7f98285..99d5d59 100644 (file)
@@ -28,6 +28,7 @@
 #include "SharedWorkerStrategy.h"
 #include "StorageStrategy.h"
 #include "VisitedLinkStrategy.h"
+#include <wtf/NeverDestroyed.h>
 
 class PlatformStrategiesGtk : public WebCore::PlatformStrategies, private WebCore::CookiesStrategy, private WebCore::DatabaseStrategy, private WebCore::LoaderStrategy, private WebCore::PluginStrategy, private WebCore::SharedWorkerStrategy, private WebCore::StorageStrategy, private WebCore::VisitedLinkStrategy {
 public:
@@ -64,6 +65,8 @@ private:
     // WebCore::VisitedLinkStrategy
     virtual bool isLinkVisited(WebCore::Page*, WebCore::LinkHash, const WebCore::URL& baseURL, const WTF::AtomicString& attributeURL);
     virtual void addVisitedLink(WebCore::Page*, WebCore::LinkHash);
+
+    friend class NeverDestroyed<PlatformStrategiesGtk>;
 };
 
 #endif // PlatformStrategiesGtk_h
index 2817e8f..742b23d 100644 (file)
 #include "webkitglobalsprivate.h"
 #include "webkitversion.h"
 #include "webkitwebsettingsprivate.h"
+#include <glib/gi18n-lib.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/gobject/GUniquePtr.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringConcatenate.h>
-#include <glib/gi18n-lib.h>
 
 /**
  * SECTION:webkitwebsettings
@@ -1586,23 +1587,23 @@ static void initializeOtherGoogleDomains(Vector<String>& otherGoogleDomains)
 
 static bool isGoogleDomain(String host)
 {
-    DEFINE_STATIC_LOCAL(HashSet<String>, googleDomains, ());
-    DEFINE_STATIC_LOCAL(Vector<String>, otherGoogleDomains, ());
+    static NeverDestroyed<HashSet<String>> googleDomains;
+    static NeverDestroyed<Vector<String>> otherGoogleDomains;
 
-    if (googleDomains.isEmpty())
-        initializeDomainsList(googleDomains);
+    if (googleDomains.get().isEmpty())
+        initializeDomainsList(googleDomains.get());
 
-    if (otherGoogleDomains.isEmpty())
-        initializeOtherGoogleDomains(otherGoogleDomains);
+    if (otherGoogleDomains.get().isEmpty())
+        initializeOtherGoogleDomains(otherGoogleDomains.get());
 
     // First check if this is one of the various google.com international domains.
     int position = host.find(".google.");
-    if (position > 0 && googleDomains.contains(host.substring(position + sizeof(".google.") - 1)))
+    if (position > 0 && googleDomains.get().contains(host.substring(position + sizeof(".google.") - 1)))
         return true;
 
     // Then we check the possibility of it being one of the other, .com-only google domains.
-    for (unsigned int i = 0; i < otherGoogleDomains.size(); i++) {
-        if (host.endsWith(otherGoogleDomains.at(i)))
+    for (unsigned i = 0; i < otherGoogleDomains.get().size(); i++) {
+        if (host.endsWith(otherGoogleDomains.get().at(i)))
             return true;
     }
 
index c649009..2ff83a8 100644 (file)
@@ -1,3 +1,22 @@
+2014-02-05  Zan Dobersek  <zdobersek@igalia.com>
+
+        [GTK] Replace DEFINE_STATIC_LOCAL with NeverDestroyed<T> in GTK WK1 and WK2 code
+        https://bugs.webkit.org/show_bug.cgi?id=128195
+
+        Reviewed by Martin Robinson.
+
+        Use static NeverDestroyed<T> variables instead of the DEFINE_STATIC_LOCAL macro.
+
+        * UIProcess/API/gtk/WebKitBackForwardListItem.cpp:
+        (historyItemsMap):
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        (downloadsMap):
+        * UIProcess/gtk/WebPageProxyGtk.cpp:
+        (WebKit::pluginWindowMap):
+        * WebProcess/gtk/WebGtkExtensionManager.cpp:
+        (WebKit::WebGtkExtensionManager::shared):
+        * WebProcess/gtk/WebGtkExtensionManager.h:
+
 2014-02-04  Andreas Kling  <akling@apple.com>
 
         Remove <iframe seamless> support.
index ae18b05..72f1e0f 100644 (file)
@@ -23,6 +23,7 @@
 #include "WebKitBackForwardListPrivate.h"
 #include "WebKitPrivate.h"
 #include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/gobject/GRefPtr.h>
 #include <wtf/text/CString.h>
 
@@ -56,7 +57,7 @@ typedef HashMap<WebBackForwardListItem*, WebKitBackForwardListItem*> HistoryItem
 
 static HistoryItemsMap& historyItemsMap()
 {
-    DEFINE_STATIC_LOCAL(HistoryItemsMap, itemsMap, ());
+    static NeverDestroyed<HistoryItemsMap> itemsMap;
     return itemsMap;
 }
 
index f033348..d5d6019 100644 (file)
@@ -47,6 +47,7 @@
 #include <WebCore/IconDatabase.h>
 #include <WebCore/Language.h>
 #include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -357,7 +358,7 @@ typedef HashMap<DownloadProxy*, GRefPtr<WebKitDownload> > DownloadsMap;
 
 static DownloadsMap& downloadsMap()
 {
-    DEFINE_STATIC_LOCAL(DownloadsMap, downloads, ());
+    static NeverDestroyed<DownloadsMap> downloads;
     return downloads;
 }
 
index 108d488..8a53985 100644 (file)
@@ -35,6 +35,7 @@
 #include "WebProcessProxy.h"
 #include <WebCore/UserAgentGtk.h>
 #include <gtk/gtkx.h>
+#include <wtf/NeverDestroyed.h>
 
 namespace WebKit {
 
@@ -79,7 +80,7 @@ void WebPageProxy::loadRecentSearches(const String&, Vector<String>&)
 typedef HashMap<uint64_t, GtkWidget* > PluginWindowMap;
 static PluginWindowMap& pluginWindowMap()
 {
-    DEFINE_STATIC_LOCAL(PluginWindowMap, map, ());
+    static NeverDestroyed<PluginWindowMap> map;
     return map;
 }
 
index 1e2390d..a8edf62 100644 (file)
@@ -34,7 +34,7 @@ namespace WebKit {
 
 WebGtkExtensionManager& WebGtkExtensionManager::shared()
 {
-    DEFINE_STATIC_LOCAL(WebGtkExtensionManager, extensionManager, ());
+    static NeverDestroyed<WebGtkExtensionManager> extensionManager;
     return extensionManager;
 }
 
index ec0bdc5..fcc866b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "Module.h"
 #include "WKBundle.h"
+#include <wtf/NeverDestroyed.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/Vector.h>
 #include <wtf/gobject/GRefPtr.h>
@@ -50,6 +51,8 @@ private:
 
     Vector<Module*> m_extensionModules;
     GRefPtr<WebKitWebExtension> m_extension;
+
+    friend class NeverDestroyed<WebGtkExtensionManager>;
 };
 
 } // namespace WebKit