electron/shell/common/crash_reporter/crash_reporter.h

80 lines
2.5 KiB
C
Raw Normal View History

// 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
// 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_
#include <map>
#include <string>
2015-06-03 03:31:34 +00:00
#include <utility>
#include <vector>
#include "base/files/file_path.h"
2016-03-08 04:38:49 +00:00
#include "base/macros.h"
namespace gin_helper {
class Dictionary;
}
namespace crash_reporter {
extern const char kCrashpadProcess[];
extern const char kCrashesDirectoryKey[];
class CrashReporter {
public:
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
static CrashReporter* GetInstance();
// FIXME(zcbenz): We should not do V8 in this file, this method should only
// accept C++ struct as parameter, and atom_api_crash_reporter.cc is
// responsible for parsing the parameter from JavaScript.
static void StartInstance(const gin_helper::Dictionary& options);
bool IsInitialized();
void Start(const std::string& product_name,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir,
2016-11-22 08:30:20 +00:00
bool upload_to_server,
bool skip_system_crash_handler,
const StringMap& extra_parameters);
2017-01-24 21:58:39 +00:00
virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports(
const base::FilePath& crashes_dir);
2016-11-22 08:30:20 +00:00
virtual void SetUploadToServer(bool upload_to_server);
virtual bool GetUploadToServer();
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
protected:
CrashReporter();
virtual ~CrashReporter();
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);
virtual void SetUploadParameters();
StringMap upload_parameters_;
std::string process_type_;
private:
bool is_initialized_ = false;
void SetUploadParameters(const StringMap& parameters);
DISALLOW_COPY_AND_ASSIGN(CrashReporter);
};
} // namespace crash_reporter
2019-06-19 20:56:58 +00:00
#endif // SHELL_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_