[GTK][WPE] Use LazyNeverDestroyed<XErrorTrapper> to remove static initializers
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jun 2018 01:10:37 +0000 (01:10 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jun 2018 01:10:37 +0000 (01:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187089

Reviewed by Michael Catanzaro.

Source/WebCore:

Do not allow copying since XErrorTrapper's logic relies on the address of XErrorTrapper.

* platform/graphics/x11/XErrorTrapper.h:

Source/WebKit:

Use LazyNeverDestroyed<XErrorTrapper> instead of global std::unique_ptr<XErrorTrapper>.
Since this variable's exit time destructor is not important in this code, using
LazyNeverDestroyed<XErrorTrapper> is fine. This removes the last static initializer
of libwebkit2gtk.so.

* PluginProcess/unix/PluginProcessMainUnix.cpp:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/x11/XErrorTrapper.h
Source/WebKit/ChangeLog
Source/WebKit/PluginProcess/unix/PluginProcessMainUnix.cpp

index 1a2a9ec..a79ada2 100644 (file)
@@ -1,3 +1,14 @@
+2018-06-27  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [GTK][WPE] Use LazyNeverDestroyed<XErrorTrapper> to remove static initializers
+        https://bugs.webkit.org/show_bug.cgi?id=187089
+
+        Reviewed by Michael Catanzaro.
+
+        Do not allow copying since XErrorTrapper's logic relies on the address of XErrorTrapper.
+
+        * platform/graphics/x11/XErrorTrapper.h:
+
 2018-06-27  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] Align inFlowNonReplacedWidthAndMargin() style with the rest of the compute functions.
index 5d53b6c..61baabe 100644 (file)
@@ -32,6 +32,7 @@
 namespace WebCore {
 
 class XErrorTrapper {
+    WTF_MAKE_NONCOPYABLE(XErrorTrapper);
 public:
     enum class Policy { Ignore, Warn, Crash };
     XErrorTrapper(Display*, Policy = Policy::Ignore, Vector<unsigned char>&& expectedErrors = { });
index 0e15801..36103d9 100644 (file)
@@ -1,3 +1,17 @@
+2018-06-27  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [GTK][WPE] Use LazyNeverDestroyed<XErrorTrapper> to remove static initializers
+        https://bugs.webkit.org/show_bug.cgi?id=187089
+
+        Reviewed by Michael Catanzaro.
+
+        Use LazyNeverDestroyed<XErrorTrapper> instead of global std::unique_ptr<XErrorTrapper>.
+        Since this variable's exit time destructor is not important in this code, using
+        LazyNeverDestroyed<XErrorTrapper> is fine. This removes the last static initializer
+        of libwebkit2gtk.so.
+
+        * PluginProcess/unix/PluginProcessMainUnix.cpp:
+
 2018-06-27  Youenn Fablet  <youenn@apple.com>
 
         Add a sandbox profile for some additional bank plugins
index 91f82b6..2bd2ed5 100644 (file)
 #if PLATFORM(X11)
 #include <WebCore/PlatformDisplayX11.h>
 #include <WebCore/XErrorTrapper.h>
+#include <wtf/NeverDestroyed.h>
 #endif
 
 namespace WebKit {
 
 #if PLATFORM(X11)
-static std::unique_ptr<WebCore::XErrorTrapper> xErrorTrapper;
+static LazyNeverDestroyed<WebCore::XErrorTrapper> xErrorTrapper;
 #endif
 
 class PluginProcessMain final: public ChildProcessMainBase {
@@ -82,7 +83,7 @@ public:
 #if PLATFORM(X11)
         if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::X11) {
             auto* display = downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay()).native();
-            xErrorTrapper = std::make_unique<WebCore::XErrorTrapper>(display, WebCore::XErrorTrapper::Policy::Warn);
+            xErrorTrapper.construct(display, WebCore::XErrorTrapper::Policy::Warn);
         }
 #endif