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 virtual void SetClientID(const std::string
& client_id
);
52 // Returns true if an alternative location to store the minidump files was
53 // specified. Returns true if |crash_dir| was set.
54 virtual bool GetAlternativeCrashDumpLocation(base::FilePath
* crash_dir
);
56 // Returns a textual description of the product type and version to include
57 // in the crash report.
58 virtual void GetProductNameAndVersion(const base::FilePath
& exe_path
,
59 base::string16
* product_name
,
60 base::string16
* version
,
61 base::string16
* special_build
,
62 base::string16
* channel_name
);
64 // Returns true if a restart dialog should be displayed. In that case,
65 // |message| and |title| are set to a message to display in a dialog box with
66 // the given title before restarting, and |is_rtl_locale| indicates whether
67 // to display the text as RTL.
68 virtual bool ShouldShowRestartDialog(base::string16
* title
,
69 base::string16
* message
,
72 // Returns true if it is ok to restart the application. Invoked right before
73 // restarting after a crash.
74 virtual bool AboutToRestart();
76 // Returns true if the crash report uploader supports deferred uploads.
77 virtual bool GetDeferredUploadsSupported(bool is_per_user_install
);
79 // Returns true if the running binary is a per-user installation.
80 virtual bool GetIsPerUserInstall(const base::FilePath
& exe_path
);
82 // Returns true if larger crash dumps should be dumped.
83 virtual bool GetShouldDumpLargerDumps(bool is_per_user_install
);
85 // Returns the result code to return when breakpad failed to respawn a
87 virtual int GetResultCodeRespawnFailed();
89 // Invoked when initializing breakpad in the browser process.
90 virtual void InitBrowserCrashDumpsRegKey();
92 // Invoked before attempting to write a minidump.
93 virtual void RecordCrashDumpAttempt(bool is_real_crash
);
96 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
97 // Returns a textual description of the product type and version to include
98 // in the crash report.
99 virtual void GetProductNameAndVersion(std::string
* product_name
,
100 std::string
* version
);
102 virtual base::FilePath
GetReporterLogFilename();
105 // The location where minidump files should be written. Returns true if
106 // |crash_dir| was set.
107 virtual bool GetCrashDumpLocation(base::FilePath
* crash_dir
);
109 // Register all of the potential crash keys that can be sent to the crash
110 // reporting server. Returns the size of the union of all keys.
111 virtual size_t RegisterCrashKeys();
113 // Returns true if running in unattended mode (for automated testing).
114 virtual bool IsRunningUnattended();
116 // Returns true if the user has given consent to collect stats.
117 virtual bool GetCollectStatsConsent();
119 #if defined(OS_WIN) || defined(OS_MACOSX)
120 // Returns true if breakpad is enforced via management policies. In that
121 // case, |breakpad_enabled| is set to the value enforced by policies.
122 virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled
);
125 #if defined(OS_ANDROID)
126 // Returns the descriptor key of the android minidump global descriptor.
127 virtual int GetAndroidMinidumpDescriptor();
130 #if defined(OS_MACOSX)
131 // Install additional breakpad filter callbacks.
132 virtual void InstallAdditionalFilters(BreakpadRef breakpad
);
135 // Returns true if breakpad should run in the given process type.
136 virtual bool EnableBreakpadForProcess(const std::string
& process_type
);
139 } // namespace breakpad
141 #endif // COMPONENTS_BREAKPAD_APP_BREAKPAD_CLIENT_H_