electron_crash_reporter_client.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. bool IsRunningUnattended() override;
  47. bool GetCollectStatsConsent() override;
  48. bool GetShouldRateLimit() override;
  49. bool GetShouldCompressUploads() override;
  50. void GetProcessSimpleAnnotations(
  51. std::map<std::string, std::string>* annotations) override;
  52. #if defined(OS_MAC)
  53. bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) override;
  54. #endif
  55. #if defined(OS_MAC) || defined(OS_LINUX)
  56. bool ShouldMonitorCrashHandlerExpensively() override;
  57. #endif
  58. bool EnableBreakpadForProcess(const std::string& process_type) override;
  59. std::string GetUploadUrl() override;
  60. private:
  61. friend class base::NoDestructor<ElectronCrashReporterClient>;
  62. std::string upload_url_;
  63. bool collect_stats_consent_ = false;
  64. bool rate_limit_ = false;
  65. bool compress_uploads_ = false;
  66. std::map<std::string, std::string> global_annotations_;
  67. ElectronCrashReporterClient();
  68. ~ElectronCrashReporterClient() override;
  69. DISALLOW_COPY_AND_ASSIGN(ElectronCrashReporterClient);
  70. };
  71. #endif // SHELL_APP_ELECTRON_CRASH_REPORTER_CLIENT_H_