Title: [291612] trunk/Source/WebCore
Revision
291612
Author
commit-qu...@webkit.org
Date
2022-03-22 05:33:41 -0700 (Tue, 22 Mar 2022)

Log Message

[GLIB] Use a static string for default application name
https://bugs.webkit.org/show_bug.cgi?id=238124

Patch by Philippe Normand <pnorm...@igalia.com> on 2022-03-22
Reviewed by Xabier Rodriguez-Calvar.

* platform/glib/ApplicationGLib.cpp:
(WebCore::getApplicationName):
* platform/glib/ApplicationGLib.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291611 => 291612)


--- trunk/Source/WebCore/ChangeLog	2022-03-22 10:36:52 UTC (rev 291611)
+++ trunk/Source/WebCore/ChangeLog	2022-03-22 12:33:41 UTC (rev 291612)
@@ -1,3 +1,14 @@
+2022-03-22  Philippe Normand  <pnorm...@igalia.com>
+
+        [GLIB] Use a static string for default application name
+        https://bugs.webkit.org/show_bug.cgi?id=238124
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * platform/glib/ApplicationGLib.cpp:
+        (WebCore::getApplicationName):
+        * platform/glib/ApplicationGLib.h:
+
 2022-03-22  Youenn Fablet  <you...@apple.com>
 
         Move RealtimeMediaSource::VideoSampleObserver::videoSampleAvailable to VideoFrame

Modified: trunk/Source/WebCore/platform/audio/glib/MediaSessionGLib.cpp (291611 => 291612)


--- trunk/Source/WebCore/platform/audio/glib/MediaSessionGLib.cpp	2022-03-22 10:36:52 UTC (rev 291611)
+++ trunk/Source/WebCore/platform/audio/glib/MediaSessionGLib.cpp	2022-03-22 12:33:41 UTC (rev 291612)
@@ -141,7 +141,7 @@
     case MprisProperty::GetPosition:
         return session.getPositionAsGVariant();
     case MprisProperty::Identity:
-        return g_variant_new_string(getApplicationName());
+        return g_variant_new_string(getApplicationName().ascii().data());
     case MprisProperty::DesktopEntry:
         return g_variant_new_string("");
     case MprisProperty::CanSeek:

Modified: trunk/Source/WebCore/platform/glib/ApplicationGLib.cpp (291611 => 291612)


--- trunk/Source/WebCore/platform/glib/ApplicationGLib.cpp	2022-03-22 10:36:52 UTC (rev 291611)
+++ trunk/Source/WebCore/platform/glib/ApplicationGLib.cpp	2022-03-22 12:33:41 UTC (rev 291612)
@@ -25,6 +25,7 @@
 
 static String gApplicationName;
 static String gApplicationID;
+static NeverDestroyed<WTF::String> gDefaultApplicationName(MAKE_STATIC_STRING_IMPL("WebKit"));
 
 void setApplicationName(const String& applicationName)
 {
@@ -31,11 +32,11 @@
     gApplicationName = applicationName;
 }
 
-const char* getApplicationName()
+const String& getApplicationName()
 {
     if (!gApplicationName.isEmpty())
-        return gApplicationName.ascii().data();
-    return "WebKit";
+        return gApplicationName;
+    return gDefaultApplicationName;
 }
 
 void setApplicationID(const String& applicationID)

Modified: trunk/Source/WebCore/platform/glib/ApplicationGLib.h (291611 => 291612)


--- trunk/Source/WebCore/platform/glib/ApplicationGLib.h	2022-03-22 10:36:52 UTC (rev 291611)
+++ trunk/Source/WebCore/platform/glib/ApplicationGLib.h	2022-03-22 12:33:41 UTC (rev 291612)
@@ -25,7 +25,7 @@
 namespace WebCore {
 
 WEBCORE_EXPORT void setApplicationName(const String&);
-WEBCORE_EXPORT const char* getApplicationName();
+WEBCORE_EXPORT const String& getApplicationName();
 
 WEBCORE_EXPORT void setApplicationID(const String&);
 WEBCORE_EXPORT const String& getApplicationID();

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp (291611 => 291612)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2022-03-22 10:36:52 UTC (rev 291611)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2022-03-22 12:33:41 UTC (rev 291612)
@@ -477,8 +477,10 @@
             g_object_set(object, "stream-properties", properties.get(), nullptr);
             GST_DEBUG("Set media.role as %s on %" GST_PTR_FORMAT, role->utf8().data(), GST_ELEMENT_CAST(object));
         }
-        if (g_object_class_find_property(objectClass, "client-name"))
-            g_object_set(object, "client-name", getApplicationName(), nullptr);
+        if (g_object_class_find_property(objectClass, "client-name")) {
+            auto& clientName = getApplicationName();
+            g_object_set(object, "client-name", clientName.ascii().data(), nullptr);
+        }
     }), role.isolatedCopy().releaseImpl().leakRef(), static_cast<GClosureNotify>([](gpointer userData, GClosure*) {
         reinterpret_cast<StringImpl*>(userData)->deref();
     }), static_cast<GConnectFlags>(0));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to