| 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_CRASH_CONTENT_APP_CRASH_REPORTER_CLIENT_H_ | |
| 6 #define COMPONENTS_CRASH_CONTENT_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 #if !defined(OS_MACOSX) | |
| 49 // Sets the crash reporting client ID, a unique identifier for the client | |
| 50 // that is sending crash reports. After it is set, it should not be changed. | |
| 51 // |client_guid| may either be a full GUID or a GUID that was already stripped | |
| 52 // from its dashes. | |
| 53 // | |
| 54 // On Mac OS X, this is the responsibility of Crashpad, and can not be set | |
| 55 // directly by the client. | |
| 56 virtual void SetCrashReporterClientIdFromGUID(const std::string& client_guid); | |
| 57 #endif | |
| 58 | |
| 59 #if defined(OS_WIN) | |
| 60 // Returns true if an alternative location to store the minidump files was | |
| 61 // specified. Returns true if |crash_dir| was set. | |
| 62 virtual bool GetAlternativeCrashDumpLocation(base::FilePath* crash_dir); | |
| 63 | |
| 64 // Returns a textual description of the product type and version to include | |
| 65 // in the crash report. | |
| 66 virtual void GetProductNameAndVersion(const base::FilePath& exe_path, | |
| 67 base::string16* product_name, | |
| 68 base::string16* version, | |
| 69 base::string16* special_build, | |
| 70 base::string16* channel_name); | |
| 71 | |
| 72 // Returns true if a restart dialog should be displayed. In that case, | |
| 73 // |message| and |title| are set to a message to display in a dialog box with | |
| 74 // the given title before restarting, and |is_rtl_locale| indicates whether | |
| 75 // to display the text as RTL. | |
| 76 virtual bool ShouldShowRestartDialog(base::string16* title, | |
| 77 base::string16* message, | |
| 78 bool* is_rtl_locale); | |
| 79 | |
| 80 // Returns true if it is ok to restart the application. Invoked right before | |
| 81 // restarting after a crash. | |
| 82 virtual bool AboutToRestart(); | |
| 83 | |
| 84 // Returns true if the crash report uploader supports deferred uploads. | |
| 85 virtual bool GetDeferredUploadsSupported(bool is_per_user_install); | |
| 86 | |
| 87 // Returns true if the running binary is a per-user installation. | |
| 88 virtual bool GetIsPerUserInstall(const base::FilePath& exe_path); | |
| 89 | |
| 90 // Returns true if larger crash dumps should be dumped. | |
| 91 virtual bool GetShouldDumpLargerDumps(bool is_per_user_install); | |
| 92 | |
| 93 // Returns the result code to return when breakpad failed to respawn a | |
| 94 // crashed process. | |
| 95 virtual int GetResultCodeRespawnFailed(); | |
| 96 | |
| 97 // Invoked when initializing the crash reporter in the browser process. | |
| 98 virtual void InitBrowserCrashDumpsRegKey(); | |
| 99 | |
| 100 // Invoked before attempting to write a minidump. | |
| 101 virtual void RecordCrashDumpAttempt(bool is_real_crash); | |
| 102 | |
| 103 // Invoked with the results of a minidump attempt. | |
| 104 virtual void RecordCrashDumpAttemptResult(bool is_real_crash, bool succeeded); | |
| 105 #endif | |
| 106 | |
| 107 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS) | |
| 108 // Returns a textual description of the product type and version to include | |
| 109 // in the crash report. Neither out parameter should be set to NULL. | |
| 110 virtual void GetProductNameAndVersion(const char** product_name, | |
| 111 const char** version); | |
| 112 | |
| 113 virtual base::FilePath GetReporterLogFilename(); | |
| 114 | |
| 115 // Custom crash minidump handler after the minidump is generated. | |
| 116 // Returns true if the minidump is handled (client); otherwise, return false | |
| 117 // to fallback to default handler. | |
| 118 // WARNING: this handler runs in a compromised context. It may not call into | |
| 119 // libc nor allocate memory normally. | |
| 120 virtual bool HandleCrashDump(const char* crashdump_filename); | |
| 121 #endif | |
| 122 | |
| 123 // The location where minidump files should be written. Returns true if | |
| 124 // |crash_dir| was set. | |
| 125 virtual bool GetCrashDumpLocation(base::FilePath* crash_dir); | |
| 126 | |
| 127 // Register all of the potential crash keys that can be sent to the crash | |
| 128 // reporting server. Returns the size of the union of all keys. | |
| 129 virtual size_t RegisterCrashKeys(); | |
| 130 | |
| 131 // Returns true if running in unattended mode (for automated testing). | |
| 132 virtual bool IsRunningUnattended(); | |
| 133 | |
| 134 // Returns true if the user has given consent to collect stats. | |
| 135 virtual bool GetCollectStatsConsent(); | |
| 136 | |
| 137 #if defined(OS_WIN) || defined(OS_MACOSX) | |
| 138 // Returns true if crash reporting is enforced via management policies. In | |
| 139 // that case, |breakpad_enabled| is set to the value enforced by policies. | |
| 140 virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled); | |
| 141 #endif | |
| 142 | |
| 143 #if defined(OS_ANDROID) | |
| 144 // Returns the descriptor key of the android minidump global descriptor. | |
| 145 virtual int GetAndroidMinidumpDescriptor(); | |
| 146 | |
| 147 // Returns true if breakpad microdumps should be enabled. This orthogonal to | |
| 148 // the standard minidump uploader (which depends on the user consent). | |
| 149 virtual bool ShouldEnableBreakpadMicrodumps(); | |
| 150 #endif | |
| 151 | |
| 152 // Returns true if breakpad should run in the given process type. | |
| 153 virtual bool EnableBreakpadForProcess(const std::string& process_type); | |
| 154 }; | |
| 155 | |
| 156 } // namespace crash_reporter | |
| 157 | |
| 158 #endif // COMPONENTS_CRASH_CONTENT_APP_CRASH_REPORTER_CLIENT_H_ | |
| OLD | NEW |