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.
5 #ifndef COMPONENTS_BREAKPAD_APP_BREAKPAD_CLIENT_H_
6 #define COMPONENTS_BREAKPAD_APP_BREAKPAD_CLIENT_H_
10 #include "base/strings/string16.h"
11 #include "build/build_config.h"
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.
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;
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);
36 #if defined(BREAKPAD_IMPLEMENTATION)
37 // Breakpad's embedder API should only be used by breakpad.
38 BreakpadClient* GetBreakpadClient();
41 // Interface that the embedder implements.
42 class BreakpadClient {
45 virtual ~BreakpadClient();
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
51 virtual void SetBreakpadClientIdFromGUID(const std::string& client_guid);
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);
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);
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,
74 // Returns true if it is ok to restart the application. Invoked right before
75 // restarting after a crash.
76 virtual bool AboutToRestart();
78 // Returns true if the crash report uploader supports deferred uploads.
79 virtual bool GetDeferredUploadsSupported(bool is_per_user_install);
81 // Returns true if the running binary is a per-user installation.
82 virtual bool GetIsPerUserInstall(const base::FilePath& exe_path);
84 // Returns true if larger crash dumps should be dumped.
85 virtual bool GetShouldDumpLargerDumps(bool is_per_user_install);
87 // Returns the result code to return when breakpad failed to respawn a
89 virtual int GetResultCodeRespawnFailed();
91 // Invoked when initializing breakpad in the browser process.
92 virtual void InitBrowserCrashDumpsRegKey();
94 // Invoked before attempting to write a minidump.
95 virtual void RecordCrashDumpAttempt(bool is_real_crash);
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);
104 virtual base::FilePath GetReporterLogFilename();
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);
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();
115 // Returns true if running in unattended mode (for automated testing).
116 virtual bool IsRunningUnattended();
118 // Returns true if the user has given consent to collect stats.
119 virtual bool GetCollectStatsConsent();
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);
127 #if defined(OS_ANDROID)
128 // Returns the descriptor key of the android minidump global descriptor.
129 virtual int GetAndroidMinidumpDescriptor();
132 #if defined(OS_MACOSX)
133 // Install additional breakpad filter callbacks.
134 virtual void InstallAdditionalFilters(BreakpadRef breakpad);
137 // Returns true if breakpad should run in the given process type.
138 virtual bool EnableBreakpadForProcess(const std::string& process_type);
141 } // namespace breakpad
143 #endif // COMPONENTS_BREAKPAD_APP_BREAKPAD_CLIENT_H_