electron_crash_reporter_client.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. base::FilePath GetReporterLogFilename() override;
  30. #endif
  31. #if BUILDFLAG(IS_WIN)
  32. void GetProductNameAndVersion(const std::wstring& exe_path,
  33. std::wstring* product_name,
  34. std::wstring* version,
  35. std::wstring* special_build,
  36. std::wstring* channel_name) override;
  37. #endif
  38. #if BUILDFLAG(IS_WIN)
  39. bool GetCrashDumpLocation(std::wstring* crash_dir) override;
  40. #else
  41. bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
  42. #endif
  43. bool IsRunningUnattended() override;
  44. bool GetCollectStatsConsent() override;
  45. bool GetShouldRateLimit() override;
  46. bool GetShouldCompressUploads() override;
  47. void GetProcessSimpleAnnotations(
  48. std::map<std::string, std::string>* annotations) override;
  49. #if BUILDFLAG(IS_MAC)
  50. bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) override;
  51. #endif
  52. #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
  53. bool ShouldMonitorCrashHandlerExpensively() override;
  54. #endif
  55. void GetProductInfo(ProductInfo* product_info) override;
  56. bool EnableBreakpadForProcess(const std::string& process_type) override;
  57. std::string GetUploadUrl() override;
  58. private:
  59. friend class base::NoDestructor<ElectronCrashReporterClient>;
  60. std::string upload_url_;
  61. bool collect_stats_consent_ = false;
  62. bool rate_limit_ = false;
  63. bool compress_uploads_ = false;
  64. std::map<std::string, std::string> global_annotations_;
  65. ElectronCrashReporterClient();
  66. ~ElectronCrashReporterClient() override;
  67. };
  68. #endif // ELECTRON_SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_