electron_crash_reporter_client.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifndef ELECTRON_SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_
  5. #define ELECTRON_SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_
  6. #include <map>
  7. #include <string>
  8. #include "base/compiler_specific.h"
  9. #include "base/no_destructor.h"
  10. #include "build/build_config.h"
  11. #include "components/crash/core/app/crash_reporter_client.h"
  12. class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
  13. public:
  14. static void Create();
  15. // disable copy
  16. ElectronCrashReporterClient(const ElectronCrashReporterClient&) = delete;
  17. ElectronCrashReporterClient& operator=(const ElectronCrashReporterClient&) =
  18. delete;
  19. static ElectronCrashReporterClient* Get();
  20. void SetCollectStatsConsent(bool upload_allowed);
  21. void SetUploadUrl(const std::string& url);
  22. void SetShouldRateLimit(bool rate_limit);
  23. void SetShouldCompressUploads(bool compress_uploads);
  24. void SetGlobalAnnotations(
  25. const std::map<std::string, std::string>& annotations);
  26. // crash_reporter::CrashReporterClient implementation.
  27. #if defined(OS_LINUX)
  28. void SetCrashReporterClientIdFromGUID(
  29. const std::string& client_guid) override;
  30. void GetProductNameAndVersion(const char** product_name,
  31. const char** version) override;
  32. void GetProductNameAndVersion(std::string* product_name,
  33. std::string* version,
  34. std::string* channel) override;
  35. base::FilePath GetReporterLogFilename() override;
  36. #endif
  37. #if defined(OS_WIN)
  38. void GetProductNameAndVersion(const std::wstring& exe_path,
  39. std::wstring* product_name,
  40. std::wstring* version,
  41. std::wstring* special_build,
  42. std::wstring* channel_name) override;
  43. #endif
  44. #if defined(OS_WIN)
  45. bool GetCrashDumpLocation(std::wstring* crash_dir) override;
  46. #else
  47. bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
  48. #endif
  49. bool IsRunningUnattended() override;
  50. bool GetCollectStatsConsent() override;
  51. bool GetShouldRateLimit() override;
  52. bool GetShouldCompressUploads() override;
  53. void GetProcessSimpleAnnotations(
  54. std::map<std::string, std::string>* annotations) override;
  55. #if defined(OS_MAC)
  56. bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) override;
  57. #endif
  58. #if defined(OS_MAC) || defined(OS_LINUX)
  59. bool ShouldMonitorCrashHandlerExpensively() override;
  60. #endif
  61. bool EnableBreakpadForProcess(const std::string& process_type) override;
  62. std::string GetUploadUrl() override;
  63. private:
  64. friend class base::NoDestructor<ElectronCrashReporterClient>;
  65. std::string upload_url_;
  66. bool collect_stats_consent_ = false;
  67. bool rate_limit_ = false;
  68. bool compress_uploads_ = false;
  69. std::map<std::string, std::string> global_annotations_;
  70. ElectronCrashReporterClient();
  71. ~ElectronCrashReporterClient() override;
  72. };
  73. #endif // ELECTRON_SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_