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