LibreOffice Module desktop (master)  1
crashreport.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_DESKTOP_CRASHREPORT_HXX
11 #define INCLUDED_DESKTOP_CRASHREPORT_HXX
12 
13 #include <desktop/dllapi.h>
14 
15 #include <rtl/ustring.hxx>
16 #include <osl/mutex.hxx>
17 
18 #include <config_features.h>
19 
20 // vector not sort the entries
21 #include <memory>
22 #include <vector>
23 #include <string>
24 
25 namespace google_breakpad
26 {
27 class ExceptionHandler;
28 }
29 
38 class
39 #if HAVE_FEATURE_BREAKPAD
40 // MSVC 2013 has undefined symbols for inline functions if it's exported
42 #endif
43 /*class*/ CrashReporter
44 {
45 public:
46  typedef enum {AddItem, Write, Create} tAddKeyHandling;
47 #if HAVE_FEATURE_BREAKPAD
48  static void addKeyValue(const OUString& rKey, const OUString& rValue, tAddKeyHandling AddKeyHandling);
49 
50  static void installExceptionHandler();
51  static void removeExceptionHandler();
52 
53  static bool crashReportInfoExists();
54 
55  static bool readSendConfig(std::string& response);
56 
57  static bool IsDumpEnable();
58 
59 private:
60  static osl::Mutex maMutex;
61  static bool mbInit;
62  typedef struct _mpair
63  {
64  OUString first;
65  OUString second;
66  _mpair(const OUString& First, const OUString& Second)
67  {
68  first = First;
69  second = Second;
70  };
71  } mpair;
72 
73  typedef std::vector<mpair> vmaKeyValues;
74  static vmaKeyValues maKeyValues; // used to temporarily save entries before the old info has been uploaded
75 
76  static std::unique_ptr<google_breakpad::ExceptionHandler> mpExceptionHandler;
77 
78  static std::string getIniFileName();
79  static void writeCommonInfo();
80  static void writeToFile(std::ios_base::openmode Openmode);
81  // when we create the ExceptionHandler we have no access to the user
82  // profile yet, so update when we have access
83  static void updateMinidumpLocation();
84 
85 #else
86  // Add dummy methods for the non-breakpad case. That allows us to use
87  // // the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD
88  // // everywhere we want to log something to the crash report system.
89  inline static void addKeyValue(SAL_UNUSED_PARAMETER const OUString& /*rKey*/, SAL_UNUSED_PARAMETER const OUString& /*rValue*/, SAL_UNUSED_PARAMETER tAddKeyHandling /*AddKeyHandling*/) {};
90 #endif // HAVE_FEATURE_BREAKPAD
91 };
92 
93 #endif // INCLUDED_DESKTOP_CRASHREPORT_HXX
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
Provides access to the crash reporter service.
Definition: crashreport.hxx:38
#define CRASHREPORT_DLLPUBLIC
Definition: dllapi.h:25
::osl::Mutex maMutex
void SAL_CALL first(const css::awt::SpinEvent &rEvent) override
static void addKeyValue(SAL_UNUSED_PARAMETER const OUString &, SAL_UNUSED_PARAMETER const OUString &, SAL_UNUSED_PARAMETER tAddKeyHandling)
Definition: crashreport.hxx:89