Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / breakpad / app / breakpad_client.h
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_BREAKPAD_APP_BREAKPAD_CLIENT_H_
6 #define COMPONENTS_BREAKPAD_APP_BREAKPAD_CLIENT_H_
7
8 #include <string>
9
10 #include "base/strings/string16.h"
11 #include "build/build_config.h"
12
13 namespace base {
14 class FilePath;
15 }
16
17 #if defined(OS_MACOSX)
18 // We don't want to directly include
19 // breakpad/src/client/mac/Framework/Breakpad.h here, so we repeat the
20 // definition of BreakpadRef.
21 //
22 // On Mac, when compiling without breakpad support, a stub implementation is
23 // compiled in. Not having any includes of the breakpad library allows for
24 // reusing this header for the stub.
25 typedef void* BreakpadRef;
26 #endif
27
28 namespace breakpad {
29
30 class BreakpadClient;
31
32 // Setter and getter for the client.  The client should be set early, before any
33 // breakpad code is called, and should stay alive throughout the entire runtime.
34 void SetBreakpadClient(BreakpadClient* client);
35
36 #if defined(BREAKPAD_IMPLEMENTATION)
37 // Breakpad's embedder API should only be used by breakpad.
38 BreakpadClient* GetBreakpadClient();
39 #endif
40
41 // Interface that the embedder implements.
42 class BreakpadClient {
43  public:
44   BreakpadClient();
45   virtual ~BreakpadClient();
46
47   // Sets the Breakpad client ID, which is a unique identifier for the client
48   // that is sending crash reports. After it is set, it should not be changed.
49   // |client_guid| may either be a full GUID or a GUID that was already stripped
50   // from its dashes.
51   virtual void SetBreakpadClientIdFromGUID(const std::string& client_guid);
52
53 #if defined(OS_WIN)
54   // Returns true if an alternative location to store the minidump files was
55   // specified. Returns true if |crash_dir| was set.
56   virtual bool GetAlternativeCrashDumpLocation(base::FilePath* crash_dir);
57
58   // Returns a textual description of the product type and version to include
59   // in the crash report.
60   virtual void GetProductNameAndVersion(const base::FilePath& exe_path,
61                                         base::string16* product_name,
62                                         base::string16* version,
63                                         base::string16* special_build,
64                                         base::string16* channel_name);
65
66   // Returns true if a restart dialog should be displayed. In that case,
67   // |message| and |title| are set to a message to display in a dialog box with
68   // the given title before restarting, and |is_rtl_locale| indicates whether
69   // to display the text as RTL.
70   virtual bool ShouldShowRestartDialog(base::string16* title,
71                                        base::string16* message,
72                                        bool* is_rtl_locale);
73
74   // Returns true if it is ok to restart the application. Invoked right before
75   // restarting after a crash.
76   virtual bool AboutToRestart();
77
78   // Returns true if the crash report uploader supports deferred uploads.
79   virtual bool GetDeferredUploadsSupported(bool is_per_user_install);
80
81   // Returns true if the running binary is a per-user installation.
82   virtual bool GetIsPerUserInstall(const base::FilePath& exe_path);
83
84   // Returns true if larger crash dumps should be dumped.
85   virtual bool GetShouldDumpLargerDumps(bool is_per_user_install);
86
87   // Returns the result code to return when breakpad failed to respawn a
88   // crashed process.
89   virtual int GetResultCodeRespawnFailed();
90
91   // Invoked when initializing breakpad in the browser process.
92   virtual void InitBrowserCrashDumpsRegKey();
93
94   // Invoked before attempting to write a minidump.
95   virtual void RecordCrashDumpAttempt(bool is_real_crash);
96 #endif
97
98 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
99   // Returns a textual description of the product type and version to include
100   // in the crash report.
101   virtual void GetProductNameAndVersion(std::string* product_name,
102                                         std::string* version);
103
104   virtual base::FilePath GetReporterLogFilename();
105 #endif
106
107   // The location where minidump files should be written. Returns true if
108   // |crash_dir| was set.
109   virtual bool GetCrashDumpLocation(base::FilePath* crash_dir);
110
111   // Register all of the potential crash keys that can be sent to the crash
112   // reporting server. Returns the size of the union of all keys.
113   virtual size_t RegisterCrashKeys();
114
115   // Returns true if running in unattended mode (for automated testing).
116   virtual bool IsRunningUnattended();
117
118   // Returns true if the user has given consent to collect stats.
119   virtual bool GetCollectStatsConsent();
120
121 #if defined(OS_WIN) || defined(OS_MACOSX)
122   // Returns true if breakpad is enforced via management policies. In that
123   // case, |breakpad_enabled| is set to the value enforced by policies.
124   virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled);
125 #endif
126
127 #if defined(OS_ANDROID)
128   // Returns the descriptor key of the android minidump global descriptor.
129   virtual int GetAndroidMinidumpDescriptor();
130 #endif
131
132 #if defined(OS_MACOSX)
133   // Install additional breakpad filter callbacks.
134   virtual void InstallAdditionalFilters(BreakpadRef breakpad);
135 #endif
136
137   // Returns true if breakpad should run in the given process type.
138   virtual bool EnableBreakpadForProcess(const std::string& process_type);
139 };
140
141 }  // namespace breakpad
142
143 #endif  // COMPONENTS_BREAKPAD_APP_BREAKPAD_CLIENT_H_