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 <vector>
22 #include <string>
23 
24 namespace google_breakpad
25 {
26 class ExceptionHandler;
27 }
28 
37 class
38 #if HAVE_FEATURE_BREAKPAD
39 // MSVC 2013 has undefined symbols for inline functions if it's exported
41 #endif
42 /*class*/ CrashReporter
43 {
44 public:
45  typedef enum {AddItem, Write, Create} tAddKeyHandling;
46 #if HAVE_FEATURE_BREAKPAD
47  static void addKeyValue(const OUString& rKey, const OUString& rValue, tAddKeyHandling AddKeyHandling);
48 
49  static void storeExceptionHandler(google_breakpad::ExceptionHandler* pExceptionHandler);
50 
51  static bool crashReportInfoExists();
52 
53  static bool readSendConfig(std::string& response);
54 
55  static bool IsDumpEnable();
56 
57 private:
58  static osl::Mutex maMutex;
59  static bool mbInit;
60  typedef struct _mpair
61  {
62  OUString first;
63  OUString second;
64  _mpair(const OUString& First, const OUString& Second)
65  {
66  first = First;
67  second = Second;
68  };
69  } mpair;
70 
71  typedef std::vector<mpair> vmaKeyValues;
72  static vmaKeyValues maKeyValues; // used to temporarily save entries before the old info has been uploaded
73 
74  static google_breakpad::ExceptionHandler* mpExceptionHandler;
75 
76  static std::string getIniFileName();
77  static void writeCommonInfo();
78  static void writeToFile(std::ios_base::openmode Openmode);
79  // when we create the ExceptionHandler we have no access to the user
80  // profile yet, so update when we have access
81  static void updateMinidumpLocation();
82 
83 #else
84  // Add dummy methods for the non-breakpad case. That allows us to use
85  // // the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD
86  // // everywhere we want to log something to the crash report system.
87  inline static void addKeyValue(SAL_UNUSED_PARAMETER const OUString& /*rKey*/, SAL_UNUSED_PARAMETER const OUString& /*rValue*/, SAL_UNUSED_PARAMETER tAddKeyHandling /*AddKeyHandling*/) {};
88 #endif // HAVE_FEATURE_BREAKPAD
89 };
90 
91 #endif // INCLUDED_DESKTOP_CRASHREPORT_HXX
92 
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::osl::Mutex maMutex
Provides access to the crash reporter service.
Definition: crashreport.hxx:37
#define CRASHREPORT_DLLPUBLIC
Definition: dllapi.h:25
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
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:87