refactor: remove extra args from crashreporter init (#23144)

This commit is contained in:
Jeremy Apthorp 2020-04-20 14:44:09 -07:00 committed by GitHub
parent 554830b6ff
commit e65cac6ae8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 49 additions and 62 deletions

View file

@ -41,7 +41,7 @@ class CrashReporter {
if (extra._companyName == null) extra._companyName = companyName; if (extra._companyName == null) extra._companyName = companyName;
if (extra._version == null) extra._version = ret.appVersion; if (extra._version == null) extra._version = ret.appVersion;
binding.start(ret.productName, companyName, submitURL, ret.crashesDirectory, uploadToServer, ignoreSystemCrashHandler, rateLimit, compress, extra); binding.start(submitURL, ret.crashesDirectory, uploadToServer, ignoreSystemCrashHandler, rateLimit, compress, extra);
} }
getLastCrashReport () { getLastCrashReport () {

View file

@ -46,9 +46,7 @@ bool CrashReporter::IsInitialized() {
return is_initialized_; return is_initialized_;
} }
void CrashReporter::Start(const std::string& product_name, void CrashReporter::Start(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,
@ -58,8 +56,8 @@ void CrashReporter::Start(const std::string& product_name,
is_initialized_ = true; is_initialized_ = true;
SetUploadParameters(extra_parameters); SetUploadParameters(extra_parameters);
Init(product_name, company_name, submit_url, crashes_dir, upload_to_server, Init(submit_url, crashes_dir, upload_to_server, skip_system_crash_handler,
skip_system_crash_handler, rate_limit, compress); rate_limit, compress);
} }
void CrashReporter::SetUploadParameters(const StringMap& parameters) { void CrashReporter::SetUploadParameters(const StringMap& parameters) {
@ -73,12 +71,6 @@ void CrashReporter::SetUploadParameters(const StringMap& parameters) {
SetUploadParameters(); SetUploadParameters();
} }
void CrashReporter::SetUploadToServer(const bool upload_to_server) {}
bool CrashReporter::GetUploadToServer() {
return true;
}
std::vector<CrashReporter::UploadReportResult> std::vector<CrashReporter::UploadReportResult>
CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) { CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
base::ThreadRestrictions::ScopedAllowIO allow_io; base::ThreadRestrictions::ScopedAllowIO allow_io;
@ -102,30 +94,33 @@ CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
return result; return result;
} }
void CrashReporter::Init(const std::string& product_name,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool auto_submit,
bool skip_system_crash_handler,
bool rate_limit,
bool compress) {}
void CrashReporter::SetUploadParameters() {}
void CrashReporter::AddExtraParameter(const std::string& key,
const std::string& value) {}
void CrashReporter::RemoveExtraParameter(const std::string& key) {}
std::map<std::string, std::string> CrashReporter::GetParameters() const { std::map<std::string, std::string> CrashReporter::GetParameters() const {
return upload_parameters_; return upload_parameters_;
} }
#if defined(OS_MACOSX) && defined(MAS_BUILD) #if defined(OS_MACOSX) && defined(MAS_BUILD)
class DummyCrashReporter : public CrashReporter {
public:
~DummyCrashReporter() override {}
void SetUploadToServer(bool upload_to_server) override {}
bool GetUploadToServer() override { return false; }
void AddExtraParameter(const std::string& key,
const std::string& value) override {}
void RemoveExtraParameter(const std::string& key) override {}
void Init(const std::string& submit_url,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler,
bool rate_limit,
bool compress) override {}
void SetUploadParameters() override {}
};
// static // static
CrashReporter* CrashReporter::GetInstance() { CrashReporter* CrashReporter::GetInstance() {
static CrashReporter crash_reporter; static DummyCrashReporter crash_reporter;
return &crash_reporter; return &crash_reporter;
} }
#endif #endif
@ -156,9 +151,9 @@ void CrashReporter::StartInstance(const gin_helper::Dictionary& options) {
bool upload_to_server = true; bool upload_to_server = true;
bool skip_system_crash_handler = false; bool skip_system_crash_handler = false;
reporter->Start(product_name, company_name, submit_url, crashes_dir, reporter->Start(submit_url, crashes_dir, upload_to_server,
upload_to_server, skip_system_crash_handler, rate_limit, skip_system_crash_handler, rate_limit, compress,
compress, extra_parameters); extra_parameters);
} }
} // namespace crash_reporter } // namespace crash_reporter

View file

@ -34,9 +34,7 @@ class CrashReporter {
static void StartInstance(const gin_helper::Dictionary& options); static void StartInstance(const gin_helper::Dictionary& options);
bool IsInitialized(); bool IsInitialized();
void Start(const std::string& product_name, void Start(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,
@ -47,26 +45,24 @@ class CrashReporter {
virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports( virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports(
const base::FilePath& crashes_dir); const base::FilePath& crashes_dir);
virtual void SetUploadToServer(bool upload_to_server); virtual void SetUploadToServer(bool upload_to_server) = 0;
virtual bool GetUploadToServer(); virtual bool GetUploadToServer() = 0;
virtual void AddExtraParameter(const std::string& key, virtual void AddExtraParameter(const std::string& key,
const std::string& value); const std::string& value) = 0;
virtual void RemoveExtraParameter(const std::string& key); virtual void RemoveExtraParameter(const std::string& key) = 0;
virtual std::map<std::string, std::string> GetParameters() const; virtual std::map<std::string, std::string> GetParameters() const;
protected: protected:
CrashReporter(); CrashReporter();
virtual ~CrashReporter(); virtual ~CrashReporter();
virtual void Init(const std::string& product_name, virtual void Init(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,
bool rate_limit, bool rate_limit,
bool compress); bool compress) = 0;
virtual void SetUploadParameters(); virtual void SetUploadParameters() = 0;
StringMap upload_parameters_; StringMap upload_parameters_;
std::string process_type_; std::string process_type_;

View file

@ -56,9 +56,7 @@ CrashReporterLinux::CrashReporterLinux() : pid_(getpid()) {
CrashReporterLinux::~CrashReporterLinux() = default; CrashReporterLinux::~CrashReporterLinux() = default;
void CrashReporterLinux::Init(const std::string& product_name, void CrashReporterLinux::Init(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,
@ -87,6 +85,11 @@ bool CrashReporterLinux::GetUploadToServer() {
return upload_to_server_; return upload_to_server_;
} }
void CrashReporterLinux::AddExtraParameter(const std::string& key,
const std::string& value) {}
void CrashReporterLinux::RemoveExtraParameter(const std::string& key) {}
void CrashReporterLinux::EnableCrashDumping(const base::FilePath& crashes_dir) { void CrashReporterLinux::EnableCrashDumping(const base::FilePath& crashes_dir) {
{ {
base::ThreadRestrictions::ScopedAllowIO allow_io; base::ThreadRestrictions::ScopedAllowIO allow_io;

View file

@ -28,9 +28,7 @@ class CrashReporterLinux : public CrashReporter {
public: public:
static CrashReporterLinux* GetInstance(); static CrashReporterLinux* GetInstance();
void Init(const std::string& product_name, void Init(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,
@ -39,6 +37,9 @@ class CrashReporterLinux : public CrashReporter {
void SetUploadToServer(bool upload_to_server) override; void SetUploadToServer(bool upload_to_server) override;
void SetUploadParameters() override; void SetUploadParameters() override;
bool GetUploadToServer() override; bool GetUploadToServer() override;
void AddExtraParameter(const std::string& key,
const std::string& value) override;
void RemoveExtraParameter(const std::string& key) override;
private: private:
friend struct base::DefaultSingletonTraits<CrashReporterLinux>; friend struct base::DefaultSingletonTraits<CrashReporterLinux>;

View file

@ -21,9 +21,7 @@ class CrashReporterMac : public CrashReporterCrashpad {
public: public:
static CrashReporterMac* GetInstance(); static CrashReporterMac* GetInstance();
void Init(const std::string& product_name, void Init(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,

View file

@ -22,9 +22,7 @@ CrashReporterMac::CrashReporterMac() {}
CrashReporterMac::~CrashReporterMac() {} CrashReporterMac::~CrashReporterMac() {}
void CrashReporterMac::Init(const std::string& product_name, void CrashReporterMac::Init(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,

View file

@ -57,9 +57,7 @@ void CrashReporterWin::SetUnhandledExceptionFilter() {
} }
#endif #endif
void CrashReporterWin::Init(const std::string& product_name, void CrashReporterWin::Init(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,

View file

@ -25,9 +25,7 @@ class CrashReporterWin : public CrashReporterCrashpad {
static void SetUnhandledExceptionFilter(); static void SetUnhandledExceptionFilter();
#endif #endif
void Init(const std::string& product_name, void Init(const std::string& submit_url,
const std::string& company_name,
const std::string& submit_url,
const base::FilePath& crashes_dir, const base::FilePath& crashes_dir,
bool upload_to_server, bool upload_to_server,
bool skip_system_crash_handler, bool skip_system_crash_handler,