OLD | NEW |
| (Empty) |
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_BREAKPAD_CLIENT_H_ | |
6 #define COMPONENTS_BREAKPAD_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 // Breakpad's embedder API should only be used by breakpad. | |
37 BreakpadClient* GetBreakpadClient(); | |
38 | |
39 // Interface that the embedder implements. | |
40 class BreakpadClient { | |
41 public: | |
42 BreakpadClient(); | |
43 virtual ~BreakpadClient(); | |
44 | |
45 // Sets the Breakpad client ID, which is a unique identifier for the client | |
46 // that is sending crash reports. After it is set, it should not be changed. | |
47 virtual void SetClientID(const std::string& client_id); | |
48 | |
49 #if defined(OS_WIN) | |
50 // Returns true if an alternative location to store the minidump files was | |
51 // specified. Returns true if |crash_dir| was set. | |
52 virtual bool GetAlternativeCrashDumpLocation(base::FilePath* crash_dir); | |
53 | |
54 // Returns a textual description of the product type and version to include | |
55 // in the crash report. | |
56 virtual void GetProductNameAndVersion(const base::FilePath& exe_path, | |
57 base::string16* product_name, | |
58 base::string16* version, | |
59 base::string16* special_build, | |
60 base::string16* channel_name); | |
61 | |
62 // Returns true if a restart dialog should be displayed. In that case, | |
63 // |message| and |title| are set to a message to display in a dialog box with | |
64 // the given title before restarting, and |is_rtl_locale| indicates whether | |
65 // to display the text as RTL. | |
66 virtual bool ShouldShowRestartDialog(base::string16* title, | |
67 base::string16* message, | |
68 bool* is_rtl_locale); | |
69 | |
70 // Returns true if it is ok to restart the application. Invoked right before | |
71 // restarting after a crash. | |
72 virtual bool AboutToRestart(); | |
73 | |
74 // Returns true if the crash report uploader supports deferred uploads. | |
75 virtual bool GetDeferredUploadsSupported(bool is_per_user_install); | |
76 | |
77 // Returns true if the running binary is a per-user installation. | |
78 virtual bool GetIsPerUserInstall(const base::FilePath& exe_path); | |
79 | |
80 // Returns true if larger crash dumps should be dumped. | |
81 virtual bool GetShouldDumpLargerDumps(bool is_per_user_install); | |
82 | |
83 // Returns the result code to return when breakpad failed to respawn a | |
84 // crashed process. | |
85 virtual int GetResultCodeRespawnFailed(); | |
86 | |
87 // Invoked when initializing breakpad in the browser process. | |
88 virtual void InitBrowserCrashDumpsRegKey(); | |
89 | |
90 // Invoked before attempting to write a minidump. | |
91 virtual void RecordCrashDumpAttempt(bool is_real_crash); | |
92 #endif | |
93 | |
94 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS) | |
95 // Returns a textual description of the product type and version to include | |
96 // in the crash report. | |
97 virtual void GetProductNameAndVersion(std::string* product_name, | |
98 std::string* version); | |
99 | |
100 virtual base::FilePath GetReporterLogFilename(); | |
101 #endif | |
102 | |
103 // The location where minidump files should be written. Returns true if | |
104 // |crash_dir| was set. | |
105 virtual bool GetCrashDumpLocation(base::FilePath* crash_dir); | |
106 | |
107 #if defined(OS_POSIX) | |
108 // Sets a function that'll be invoked to dump the current process when | |
109 // without crashing. | |
110 virtual void SetDumpWithoutCrashingFunction(void (*function)()); | |
111 #endif | |
112 | |
113 // Register all of the potential crash keys that can be sent to the crash | |
114 // reporting server. Returns the size of the union of all keys. | |
115 virtual size_t RegisterCrashKeys(); | |
116 | |
117 // Returns true if running in unattended mode (for automated testing). | |
118 virtual bool IsRunningUnattended(); | |
119 | |
120 #if defined(OS_WIN) || defined(OS_MACOSX) | |
121 // Returns true if the user has given consent to collect stats. | |
122 virtual bool GetCollectStatsConsent(); | |
123 | |
124 // Returns true if breakpad is enforced via management policies. In that | |
125 // case, |breakpad_enabled| is set to the value enforced by policies. | |
126 virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled); | |
127 #endif | |
128 | |
129 #if defined(OS_ANDROID) | |
130 // Returns the descriptor key of the android minidump global descriptor. | |
131 virtual int GetAndroidMinidumpDescriptor(); | |
132 #endif | |
133 | |
134 #if defined(OS_MACOSX) | |
135 // Install additional breakpad filter callbacks. | |
136 virtual void InstallAdditionalFilters(BreakpadRef breakpad); | |
137 #endif | |
138 }; | |
139 | |
140 } // namespace breakpad | |
141 | |
142 #endif // COMPONENTS_BREAKPAD_BREAKPAD_CLIENT_H_ | |
OLD | NEW |