From 8fe03eef707561bb0b9e1655292619ec3cd347f5 Mon Sep 17 00:00:00 2001 From: Juergen Funk Date: Wed, 25 Sep 2019 13:49:26 +0200 Subject: Refactoring of the class CrashReporter - remove double code - using of all the methode of the CrashReporter-Class - all methode only active when crash-dump enable except the addKeyValue With this change the handling for the patch tdf#127711 A runtime-switch for the MiniCrashDump would be simpler Change-Id: I339b3b8e06f7fc2cd3c0d34ece112a6fd352913a Reviewed-on: https://gerrit.libreoffice.org/79272 Tested-by: Jenkins Reviewed-by: Juergen Funk (CIB) --- include/desktop/crashreport.hxx | 59 ++++++++++++++++++++++++----------------- include/desktop/minidump.hxx | 13 ++++++++- 2 files changed, 47 insertions(+), 25 deletions(-) (limited to 'include/desktop') diff --git a/include/desktop/crashreport.hxx b/include/desktop/crashreport.hxx index e3486bbf0863..3af83b8e637c 100644 --- a/include/desktop/crashreport.hxx +++ b/include/desktop/crashreport.hxx @@ -17,7 +17,8 @@ #include -#include +// vector not sort the entries +#include #include namespace google_breakpad @@ -41,40 +42,50 @@ CRASHREPORT_DLLPUBLIC /*class*/ CrashReporter { public: - static void addKeyValue(const OUString& rKey, const OUString& rValue); - - static std::string getIniFileName(); - - static void writeCommonInfo(); + typedef enum {AddItem, Write, Create} tAddKeyHandling; +#if HAVE_FEATURE_BREAKPAD + static void addKeyValue(const OUString& rKey, const OUString& rValue, tAddKeyHandling AddKeyHandling); static void storeExceptionHandler(google_breakpad::ExceptionHandler* pExceptionHandler); - // when we create the ExceptionHandler we have no access to the user - // profile yet, so update when we have access - static void updateMinidumpLocation(); + static bool crashReportInfoExists(); -private: + static bool readSendConfig(std::string& response); +private: static osl::Mutex maMutex; - static bool mbInit; - - static std::map maKeyValues; // used to temporarily save entries before the old info has been uploaded + typedef struct _mpair + { + OUString first; + OUString second; + _mpair(const OUString& First, const OUString& Second) + { + first = First; + second = Second; + }; + } mpair; + + typedef std::vector vmaKeyValues; + static vmaKeyValues maKeyValues; // used to temporarily save entries before the old info has been uploaded static google_breakpad::ExceptionHandler* mpExceptionHandler; -}; -// Add dummy methods for the non-breakpad case. That allows us to use -// the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD -// everywhere we want to log something to the crash report system. -#if HAVE_FEATURE_BREAKPAD -#else -inline void CrashReporter::addKeyValue(SAL_UNUSED_PARAMETER const OUString& /*rKey*/, SAL_UNUSED_PARAMETER const OUString& /*rValue*/) -{ -} -#endif + static std::string getIniFileName(); + static void writeCommonInfo(); + static void writeToFile(std::ios_base::openmode Openmode); + // when we create the ExceptionHandler we have no access to the user + // profile yet, so update when we have access + static void updateMinidumpLocation(); +#else + // Add dummy methods for the non-breakpad case. That allows us to use + // // the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD + // // everywhere we want to log something to the crash report system. + inline static void addKeyValue(SAL_UNUSED_PARAMETER const OUString& /*rKey*/, SAL_UNUSED_PARAMETER const OUString& /*rValue*/, SAL_UNUSED_PARAMETER tAddKeyHandling /*AddKeyHandling*/) {}; +#endif // HAVE_FEATURE_BREAKPAD +}; -#endif +#endif // INCLUDED_DESKTOP_CRASHREPORT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/desktop/minidump.hxx b/include/desktop/minidump.hxx index 63336cae5595..6ed0e18277f8 100644 --- a/include/desktop/minidump.hxx +++ b/include/desktop/minidump.hxx @@ -16,7 +16,18 @@ namespace crashreport { -CRASHREPORT_DLLPUBLIC bool readConfig(const std::string& iniPath, std::string& response); +// when response = nullptr only make test +/** Read+Send, Test and send info from the Dump.ini . + + @param [in] iniPath Path-file to the read/test ini-file + @param [in] response=nullptr in this case made the Test only + @param [in] response!=nullptr in this case made the Read+Send + + @retval true Read+Send, Test was okay + @retval false Read+Send, Test is a error +*/ + +CRASHREPORT_DLLPUBLIC bool readConfig(const std::string& iniPath, std::string * response); } -- cgit v1.2.3