2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 17:49:37 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-07-04 15:54:34 +08:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2013-11-13 17:29:35 +08:00
|
|
|
#ifndef ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_
|
|
|
|
#define ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_
|
2013-07-04 15:54:34 +08:00
|
|
|
|
2013-11-14 18:02:15 +08:00
|
|
|
#include <map>
|
2013-07-04 15:54:34 +08:00
|
|
|
#include <string>
|
2015-06-03 11:31:34 +08:00
|
|
|
#include <utility>
|
2015-06-03 09:47:42 +08:00
|
|
|
#include <vector>
|
2013-07-04 15:54:34 +08:00
|
|
|
|
2016-10-05 13:31:16 -07:00
|
|
|
#include "base/files/file_path.h"
|
2016-03-07 20:38:49 -08:00
|
|
|
#include "base/macros.h"
|
2016-12-12 14:35:59 -08:00
|
|
|
#include "native_mate/dictionary.h"
|
2013-07-04 15:54:34 +08:00
|
|
|
|
|
|
|
namespace crash_reporter {
|
|
|
|
|
|
|
|
class CrashReporter {
|
|
|
|
public:
|
2013-11-18 18:27:50 +08:00
|
|
|
typedef std::map<std::string, std::string> StringMap;
|
2015-06-03 11:31:34 +08:00
|
|
|
typedef std::pair<int, std::string> UploadReportResult; // upload-date, id
|
2013-11-18 18:27:50 +08:00
|
|
|
|
2013-11-14 13:33:09 +08:00
|
|
|
static CrashReporter* GetInstance();
|
2017-01-24 13:53:05 -08:00
|
|
|
static void StartInstance(const mate::Dictionary& options);
|
2013-11-14 13:33:09 +08:00
|
|
|
|
2013-11-19 12:19:23 +08:00
|
|
|
void Start(const std::string& product_name,
|
2013-11-14 13:33:09 +08:00
|
|
|
const std::string& company_name,
|
|
|
|
const std::string& submit_url,
|
2016-10-06 10:39:57 -07:00
|
|
|
const base::FilePath& crashes_dir,
|
2016-11-22 19:30:20 +11:00
|
|
|
bool upload_to_server,
|
2013-11-18 18:27:50 +08:00
|
|
|
bool skip_system_crash_handler,
|
|
|
|
const StringMap& extra_parameters);
|
2017-01-24 13:58:39 -08:00
|
|
|
|
2015-06-05 18:50:52 +08:00
|
|
|
virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports(
|
2016-10-06 10:39:57 -07:00
|
|
|
const base::FilePath& crashes_dir);
|
2016-10-05 16:15:49 -07:00
|
|
|
|
2016-11-22 19:30:20 +11:00
|
|
|
virtual void SetUploadToServer(bool upload_to_server);
|
|
|
|
virtual bool GetUploadToServer();
|
2017-11-01 21:57:43 -04:00
|
|
|
virtual void AddExtraParameter(const std::string& key,
|
2017-02-02 14:23:21 -08:00
|
|
|
const std::string& value);
|
2017-02-09 13:05:23 -08:00
|
|
|
virtual void RemoveExtraParameter(const std::string& key);
|
2017-10-31 23:42:25 -04:00
|
|
|
virtual std::map<std::string, std::string> GetParameters() const;
|
2016-11-08 11:18:49 +11:00
|
|
|
|
2013-11-14 13:33:09 +08:00
|
|
|
protected:
|
|
|
|
CrashReporter();
|
|
|
|
virtual ~CrashReporter();
|
|
|
|
|
|
|
|
virtual void InitBreakpad(const std::string& product_name,
|
|
|
|
const std::string& version,
|
|
|
|
const std::string& company_name,
|
|
|
|
const std::string& submit_url,
|
2016-10-06 10:39:57 -07:00
|
|
|
const base::FilePath& crashes_dir,
|
2016-11-22 19:30:20 +11:00
|
|
|
bool upload_to_server,
|
2015-09-28 14:52:55 +08:00
|
|
|
bool skip_system_crash_handler);
|
|
|
|
virtual void SetUploadParameters();
|
2013-11-14 13:33:09 +08:00
|
|
|
|
2013-11-14 18:02:15 +08:00
|
|
|
StringMap upload_parameters_;
|
2013-11-14 13:33:09 +08:00
|
|
|
bool is_browser_;
|
2013-07-04 15:54:34 +08:00
|
|
|
|
|
|
|
private:
|
2013-11-18 18:27:50 +08:00
|
|
|
void SetUploadParameters(const StringMap& parameters);
|
|
|
|
|
2013-11-14 13:33:09 +08:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CrashReporter);
|
2013-07-04 15:54:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace crash_reporter
|
|
|
|
|
2013-11-13 17:29:35 +08:00
|
|
|
#endif // ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_
|