crash_reporter.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_
  5. #define ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_
  6. #include <map>
  7. #include <string>
  8. #include <utility>
  9. #include <vector>
  10. #include "base/files/file_path.h"
  11. #include "base/macros.h"
  12. #include "native_mate/dictionary.h"
  13. namespace crash_reporter {
  14. class CrashReporter {
  15. public:
  16. typedef std::map<std::string, std::string> StringMap;
  17. typedef std::pair<int, std::string> UploadReportResult; // upload-date, id
  18. static CrashReporter* GetInstance();
  19. static void StartInstance(const mate::Dictionary& options);
  20. void Start(const std::string& product_name,
  21. const std::string& company_name,
  22. const std::string& submit_url,
  23. const base::FilePath& crashes_dir,
  24. bool upload_to_server,
  25. bool skip_system_crash_handler,
  26. const StringMap& extra_parameters);
  27. virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports(
  28. const base::FilePath& crashes_dir);
  29. virtual void SetUploadToServer(bool upload_to_server);
  30. virtual bool GetUploadToServer();
  31. virtual void AddExtraParameter(const std::string& key,
  32. const std::string& value);
  33. virtual void RemoveExtraParameter(const std::string& key);
  34. virtual std::map<std::string, std::string> GetParameters() const;
  35. protected:
  36. CrashReporter();
  37. virtual ~CrashReporter();
  38. virtual void InitBreakpad(const std::string& product_name,
  39. const std::string& version,
  40. const std::string& company_name,
  41. const std::string& submit_url,
  42. const base::FilePath& crashes_dir,
  43. bool upload_to_server,
  44. bool skip_system_crash_handler);
  45. virtual void SetUploadParameters();
  46. StringMap upload_parameters_;
  47. bool is_browser_;
  48. private:
  49. void SetUploadParameters(const StringMap& parameters);
  50. DISALLOW_COPY_AND_ASSIGN(CrashReporter);
  51. };
  52. } // namespace crash_reporter
  53. #endif // ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_