comphelper/source/misc/traceevent.cxx |    8 ++++----
 include/comphelper/profilezone.hxx    |    7 +++----
 include/comphelper/traceevent.hxx     |   15 ++++++++++++++-
 3 files changed, 21 insertions(+), 9 deletions(-)

New commits:
commit 9e5b04d1e8c49d5f95173b5074368b1aa24a1e64
Author:     Tor Lillqvist <t...@collabora.com>
AuthorDate: Tue Apr 27 16:42:15 2021 +0300
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Wed Apr 28 16:48:00 2021 +0200

    Introduce a new class NamedEvent to be used by the upcoming AsyncEvent, too
    
    Don't use the term "profile id" as what we mean is the event *name*
    (as used in the Chrome Trace Event format).
    
    Change-Id: Id58a10f4c5f8a095ae75b9bf74131b70659ee701
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114755
    Tested-by: Tor Lillqvist <t...@collabora.com>
    Reviewed-by: Tor Lillqvist <t...@collabora.com>

diff --git a/comphelper/source/misc/traceevent.cxx 
b/comphelper/source/misc/traceevent.cxx
index efe1378d9364..9febf71e2db7 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -42,7 +42,7 @@ void TraceEvent::addRecording(const OUString& sObject)
     g_aRecording.emplace_back(sObject);
 }
 
-void TraceEvent::addInstantEvent(const char* sProfileId)
+void TraceEvent::addInstantEvent(const char* sName)
 {
     TimeValue aSystemTime;
     osl_getSystemTime(&aSystemTime);
@@ -57,7 +57,7 @@ void TraceEvent::addInstantEvent(const char* sProfileId)
 
     addRecording("{"
                  "\"name:\""
-                 + OUString(sProfileId, strlen(sProfileId), 
RTL_TEXTENCODING_UTF8)
+                 + OUString(sName, strlen(sName), RTL_TEXTENCODING_UTF8)
                  + "\","
                    "\"ph\":\"i\","
                    "\"ts\":"
@@ -106,7 +106,7 @@ void ProfileZone::addRecording()
     // Generate a single "Complete Event" (type X)
     TraceEvent::addRecording("{"
                              "\"name\":\""
-                             + OUString(m_sProfileId, strlen(m_sProfileId), 
RTL_TEXTENCODING_UTF8)
+                             + OUString(m_sName, strlen(m_sName), 
RTL_TEXTENCODING_UTF8)
                              + "\","
                                "\"ph\":\"X\","
                                "\"ts\":"
@@ -125,7 +125,7 @@ void ProfileZone::addRecording()
 void ProfileZone::stopConsole()
 {
     sal_uInt32 nEndTime = osl_getGlobalTimer();
-    std::cerr << "comphelper::ProfileZone: " << m_sProfileId << " finished in "
+    std::cerr << "comphelper::ProfileZone: " << m_sName << " finished in "
               << nEndTime - m_nCreateTime << " ms" << std::endl;
 }
 
diff --git a/include/comphelper/profilezone.hxx 
b/include/comphelper/profilezone.hxx
index dec5b35928bc..8ef851cfaea1 100644
--- a/include/comphelper/profilezone.hxx
+++ b/include/comphelper/profilezone.hxx
@@ -18,11 +18,10 @@
 
 namespace comphelper
 {
-class COMPHELPER_DLLPUBLIC ProfileZone : public TraceEvent
+class COMPHELPER_DLLPUBLIC ProfileZone : public NamedEvent
 {
     static int s_nNesting; // level of nested zones.
 
-    const char* m_sProfileId;
     long long m_nCreateTime;
     bool m_bConsole;
     void stopConsole();
@@ -47,8 +46,8 @@ public:
      * Similar to the DEBUG macro in sal/log.hxx, don't forget to remove these 
lines before
      * committing.
      */
-    ProfileZone(const char* sProfileId, bool bConsole = false)
-        : m_sProfileId(sProfileId ? sProfileId : "(null)")
+    ProfileZone(const char* sName, bool bConsole = false)
+        : NamedEvent(sName)
         , m_bConsole(bConsole)
     {
         if (s_bRecording || m_bConsole)
diff --git a/include/comphelper/traceevent.hxx 
b/include/comphelper/traceevent.hxx
index ff66a834e639..7e988bd063f0 100644
--- a/include/comphelper/traceevent.hxx
+++ b/include/comphelper/traceevent.hxx
@@ -13,6 +13,8 @@
 #include <sal/config.h>
 
 #include <atomic>
+#include <memory>
+#include <set>
 
 #include <osl/process.h>
 #include <osl/time.h>
@@ -32,7 +34,7 @@ protected:
     static void addRecording(const OUString& sObject);
 
 public:
-    static void addInstantEvent(const char* sProfileId);
+    static void addInstantEvent(const char* sName);
 
     static void startRecording();
     static void stopRecording();
@@ -40,6 +42,17 @@ public:
     static css::uno::Sequence<OUString> getRecordingAndClear();
 };
 
+class COMPHELPER_DLLPUBLIC NamedEvent : public TraceEvent
+{
+protected:
+    const char* m_sName;
+
+    NamedEvent(const char* sName)
+        : m_sName(sName ? sName : "(null)")
+    {
+    }
+};
+
 } // namespace comphelper
 
 #endif // INCLUDED_COMPHELPER_TRACEEVENT_HXX
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to