electron_crash_reporter_client.h 3.0 KB

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