Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / crash / app / crash_reporter_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_CRASH_APP_CRASH_REPORTER_CLIENT_H_
6 #define COMPONENTS_CRASH_APP_CRASH_REPORTER_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 crash_reporter {
29
30 class CrashReporterClient;
31
32 // Setter and getter for the client.  The client should be set early, before any
33 // crash reporter code is called, and should stay alive throughout the entire
34 // runtime.
35 void SetCrashReporterClient(CrashReporterClient* client);
36
37 #if defined(CRASH_IMPLEMENTATION)
38 // The components's embedder API should only be used by the component.
39 CrashReporterClient* GetCrashReporterClient();
40 #endif
41
42 // Interface that the embedder implements.
43 class CrashReporterClient {
44  public:
45   CrashReporterClient();
46   virtual ~CrashReporterClient();
47
48   // Sets the crash reporting client ID, a unique identifier for the client
49   // that is sending crash reports. After it is set, it should not be changed.
50   // |client_guid| may either be a full GUID or a GUID that was already stripped
51   // from its dashes.
52   virtual void SetCrashReporterClientIdFromGUID(const std::string& client_guid);
53
54 #if defined(OS_WIN)
55   // Returns true if an alternative location to store the minidump files was
56   // specified. Returns true if |crash_dir| was set.
57   virtual bool GetAlternativeCrashDumpLocation(base::FilePath* crash_dir);
58
59   // Returns a textual description of the product type and version to include
60   // in the crash report.
61   virtual void GetProductNameAndVersion(const base::FilePath& exe_path,
62                                         base::string16* product_name,
63                                         base::string16* version,
64                                         base::string16* special_build,
65                                         base::string16* channel_name);
66
67   // Returns true if a restart dialog should be displayed. In that case,
68   // |message| and |title| are set to a message to display in a dialog box with
69   // the given title before restarting, and |is_rtl_locale| indicates whether
70   // to display the text as RTL.
71   virtual bool ShouldShowRestartDialog(base::string16* title,
72                                        base::string16* message,
73                                        bool* is_rtl_locale);
74
75   // Returns true if it is ok to restart the application. Invoked right before
76   // restarting after a crash.
77   virtual bool AboutToRestart();
78
79   // Returns true if the crash report uploader supports deferred uploads.
80   virtual bool GetDeferredUploadsSupported(bool is_per_user_install);
81
82   // Returns true if the running binary is a per-user installation.
83   virtual bool GetIsPerUserInstall(const base::FilePath& exe_path);
84
85   // Returns true if larger crash dumps should be dumped.
86   virtual bool GetShouldDumpLargerDumps(bool is_per_user_install);
87
88   // Returns the result code to return when breakpad failed to respawn a
89   // crashed process.
90   virtual int GetResultCodeRespawnFailed();
91
92   // Invoked when initializing the crash reporter in the browser process.
93   virtual void InitBrowserCrashDumpsRegKey();
94
95   // Invoked before attempting to write a minidump.
96   virtual void RecordCrashDumpAttempt(bool is_real_crash);
97 #endif
98
99 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
100   // Returns a textual description of the product type and version to include
101   // in the crash report. Neither out parameter should be set to NULL.
102   virtual void GetProductNameAndVersion(const char** product_name,
103                                         const char** version);
104
105   virtual base::FilePath GetReporterLogFilename();
106
107   // Custom crash minidump handler after the minidump is generated.
108   // Returns true if the minidump is handled (client); otherwise, return false
109   // to fallback to default handler.
110   // WARNING: this handler runs in a compromised context. It may not call into
111   // libc nor allocate memory normally.
112   virtual bool HandleCrashDump(const char* crashdump_filename);
113 #endif
114
115   // The location where minidump files should be written. Returns true if
116   // |crash_dir| was set.
117   virtual bool GetCrashDumpLocation(base::FilePath* crash_dir);
118
119   // Register all of the potential crash keys that can be sent to the crash
120   // reporting server. Returns the size of the union of all keys.
121   virtual size_t RegisterCrashKeys();
122
123   // Returns true if running in unattended mode (for automated testing).
124   virtual bool IsRunningUnattended();
125
126   // Returns true if the user has given consent to collect stats.
127   virtual bool GetCollectStatsConsent();
128
129 #if defined(OS_WIN) || defined(OS_MACOSX)
130   // Returns true if crash reporting is enforced via management policies. In
131   // that case, |breakpad_enabled| is set to the value enforced by policies.
132   virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled);
133 #endif
134
135 #if defined(OS_ANDROID)
136   // Returns the descriptor key of the android minidump global descriptor.
137   virtual int GetAndroidMinidumpDescriptor();
138 #endif
139
140 #if defined(OS_MACOSX)
141   // Install additional breakpad filter callbacks.
142   virtual void InstallAdditionalFilters(BreakpadRef breakpad);
143 #endif
144
145   // Returns true if breakpad should run in the given process type.
146   virtual bool EnableBreakpadForProcess(const std::string& process_type);
147 };
148
149 }  // namespace crash_reporter
150
151 #endif  // COMPONENTS_CRASH_APP_CRASH_REPORTER_CLIENT_H_