electron_crash_reporter_client.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_
  5. #define SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_
  6. #include <map>
  7. #include <string>
  8. #include "base/compiler_specific.h"
  9. #include "base/macros.h"
  10. #include "base/no_destructor.h"
  11. #include "build/build_config.h"
  12. #include "components/crash/core/app/crash_reporter_client.h"
  13. class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
  14. public:
  15. static void Create();
  16. static ElectronCrashReporterClient* Get();
  17. void SetCollectStatsConsent(bool upload_allowed);
  18. void SetUploadUrl(const std::string& url);
  19. void SetShouldRateLimit(bool rate_limit);
  20. void SetShouldCompressUploads(bool compress_uploads);
  21. void SetGlobalAnnotations(
  22. const std::map<std::string, std::string>& annotations);
  23. // crash_reporter::CrashReporterClient implementation.
  24. #if defined(OS_LINUX)
  25. void SetCrashReporterClientIdFromGUID(
  26. const std::string& client_guid) override;
  27. void GetProductNameAndVersion(const char** product_name,
  28. const char** version) override;
  29. void GetProductNameAndVersion(std::string* product_name,
  30. std::string* version,
  31. std::string* channel) override;
  32. base::FilePath GetReporterLogFilename() override;
  33. #endif
  34. #if defined(OS_WIN)
  35. void GetProductNameAndVersion(const std::wstring& exe_path,
  36. std::wstring* product_name,
  37. std::wstring* version,
  38. std::wstring* special_build,
  39. std::wstring* channel_name) override;
  40. #endif
  41. #if defined(OS_WIN)
  42. bool GetCrashDumpLocation(std::wstring* crash_dir) override;
  43. #else
  44. bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
  45. #endif
  46. #if defined(OS_MAC) || defined(OS_LINUX)
  47. bool GetCrashMetricsLocation(base::FilePath* metrics_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. DISALLOW_COPY_AND_ASSIGN(ElectronCrashReporterClient);
  73. };
  74. #endif // SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_