mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Make upload report metrics optional
Bug: crashpad:30 Change-Id: I202e4571ee8dc8006550173c1cf0c735fae29103 Reviewed-on: https://chromium-review.googlesource.com/1148580 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
parent
c11c8833f7
commit
2418cb8fbe
@ -69,7 +69,8 @@ CrashReportDatabase::UploadReport::UploadReport()
|
||||
reader_(std::make_unique<FileReader>()),
|
||||
database_(nullptr),
|
||||
attachment_readers_(),
|
||||
attachment_map_() {}
|
||||
attachment_map_(),
|
||||
report_metrics_(false) {}
|
||||
|
||||
CrashReportDatabase::UploadReport::~UploadReport() {
|
||||
if (database_) {
|
||||
|
@ -178,6 +178,7 @@ class CrashReportDatabase {
|
||||
CrashReportDatabase* database_;
|
||||
std::vector<std::unique_ptr<FileReader>> attachment_readers_;
|
||||
std::map<std::string, FileReader*> attachment_map_;
|
||||
bool report_metrics_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(UploadReport);
|
||||
};
|
||||
@ -326,11 +327,16 @@ class CrashReportDatabase {
|
||||
//! \param[in] uuid The unique identifier for the crash report record.
|
||||
//! \param[out] report A crash report record for the report to be uploaded.
|
||||
//! Only valid if this returns #kNoError.
|
||||
//! \param[in] report_metrics If `false`, metrics will not be recorded for
|
||||
//! this upload attempt when RecordUploadComplete() is called or \a report
|
||||
//! is destroyed. Metadata for the upload attempt will still be recorded
|
||||
//! in the database.
|
||||
//!
|
||||
//! \return The operation status code.
|
||||
virtual OperationStatus GetReportForUploading(
|
||||
const UUID& uuid,
|
||||
std::unique_ptr<const UploadReport>* report) = 0;
|
||||
std::unique_ptr<const UploadReport>* report,
|
||||
bool report_metrics = true) = 0;
|
||||
|
||||
//! \brief Records a successful upload for a report and updates the last
|
||||
//! upload attempt time as returned by
|
||||
|
@ -180,7 +180,8 @@ class CrashReportDatabaseGeneric : public CrashReportDatabase {
|
||||
OperationStatus GetCompletedReports(std::vector<Report>* reports) override;
|
||||
OperationStatus GetReportForUploading(
|
||||
const UUID& uuid,
|
||||
std::unique_ptr<const UploadReport>* report) override;
|
||||
std::unique_ptr<const UploadReport>* report,
|
||||
bool report_metrics) override;
|
||||
OperationStatus SkipReportUpload(const UUID& uuid,
|
||||
Metrics::CrashSkippedReason reason) override;
|
||||
OperationStatus DeleteReport(const UUID& uuid) override;
|
||||
@ -455,7 +456,8 @@ OperationStatus CrashReportDatabaseGeneric::GetCompletedReports(
|
||||
|
||||
OperationStatus CrashReportDatabaseGeneric::GetReportForUploading(
|
||||
const UUID& uuid,
|
||||
std::unique_ptr<const UploadReport>* report) {
|
||||
std::unique_ptr<const UploadReport>* report,
|
||||
bool report_metrics) {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
auto upload_report = std::make_unique<LockfileUploadReport>();
|
||||
@ -470,6 +472,7 @@ OperationStatus CrashReportDatabaseGeneric::GetReportForUploading(
|
||||
if (!upload_report->Initialize(path, this)) {
|
||||
return kFileSystemError;
|
||||
}
|
||||
upload_report->report_metrics_ = report_metrics;
|
||||
|
||||
report->reset(upload_report.release());
|
||||
return kNoError;
|
||||
@ -609,7 +612,9 @@ OperationStatus CrashReportDatabaseGeneric::RecordUploadAttempt(
|
||||
const std::string& id) {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
Metrics::CrashUploadAttempted(successful);
|
||||
if (report->report_metrics_) {
|
||||
Metrics::CrashUploadAttempted(successful);
|
||||
}
|
||||
time_t now = time(nullptr);
|
||||
|
||||
report->id = id;
|
||||
|
@ -141,7 +141,8 @@ class CrashReportDatabaseMac : public CrashReportDatabase {
|
||||
OperationStatus GetCompletedReports(std::vector<Report>* reports) override;
|
||||
OperationStatus GetReportForUploading(
|
||||
const UUID& uuid,
|
||||
std::unique_ptr<const UploadReport>* report) override;
|
||||
std::unique_ptr<const UploadReport>* report,
|
||||
bool report_metrics) override;
|
||||
OperationStatus SkipReportUpload(const UUID& uuid,
|
||||
Metrics::CrashSkippedReason reason) override;
|
||||
OperationStatus DeleteReport(const UUID& uuid) override;
|
||||
@ -422,7 +423,8 @@ CrashReportDatabaseMac::GetCompletedReports(
|
||||
CrashReportDatabase::OperationStatus
|
||||
CrashReportDatabaseMac::GetReportForUploading(
|
||||
const UUID& uuid,
|
||||
std::unique_ptr<const UploadReport>* report) {
|
||||
std::unique_ptr<const UploadReport>* report,
|
||||
bool report_metrics) {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
auto upload_report = std::make_unique<UploadReportMac>();
|
||||
@ -444,6 +446,7 @@ CrashReportDatabaseMac::GetReportForUploading(
|
||||
|
||||
upload_report->database_ = this;
|
||||
upload_report->lock_fd.reset(lock.release());
|
||||
upload_report->report_metrics_ = report_metrics;
|
||||
report->reset(upload_report.release());
|
||||
return kNoError;
|
||||
}
|
||||
@ -454,7 +457,9 @@ CrashReportDatabaseMac::RecordUploadAttempt(UploadReport* report,
|
||||
const std::string& id) {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
Metrics::CrashUploadAttempted(successful);
|
||||
if (report->report_metrics_) {
|
||||
Metrics::CrashUploadAttempted(successful);
|
||||
}
|
||||
|
||||
DCHECK(report);
|
||||
DCHECK(successful || id.empty());
|
||||
|
@ -594,7 +594,8 @@ class CrashReportDatabaseWin : public CrashReportDatabase {
|
||||
OperationStatus GetCompletedReports(std::vector<Report>* reports) override;
|
||||
OperationStatus GetReportForUploading(
|
||||
const UUID& uuid,
|
||||
std::unique_ptr<const UploadReport>* report) override;
|
||||
std::unique_ptr<const UploadReport>* report,
|
||||
bool report_metrics) override;
|
||||
OperationStatus SkipReportUpload(const UUID& uuid,
|
||||
Metrics::CrashSkippedReason reason) override;
|
||||
OperationStatus DeleteReport(const UUID& uuid) override;
|
||||
@ -731,7 +732,8 @@ OperationStatus CrashReportDatabaseWin::GetCompletedReports(
|
||||
|
||||
OperationStatus CrashReportDatabaseWin::GetReportForUploading(
|
||||
const UUID& uuid,
|
||||
std::unique_ptr<const UploadReport>* report) {
|
||||
std::unique_ptr<const UploadReport>* report,
|
||||
bool report_metrics) {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
std::unique_ptr<Metadata> metadata(AcquireMetadata());
|
||||
@ -749,6 +751,7 @@ OperationStatus CrashReportDatabaseWin::GetReportForUploading(
|
||||
if (!upload_report->Initialize(upload_report->file_path, this)) {
|
||||
return kFileSystemError;
|
||||
}
|
||||
upload_report->report_metrics_ = report_metrics;
|
||||
|
||||
report->reset(upload_report.release());
|
||||
}
|
||||
@ -761,7 +764,9 @@ OperationStatus CrashReportDatabaseWin::RecordUploadAttempt(
|
||||
const std::string& id) {
|
||||
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||
|
||||
Metrics::CrashUploadAttempted(successful);
|
||||
if (report->report_metrics_) {
|
||||
Metrics::CrashUploadAttempted(successful);
|
||||
}
|
||||
|
||||
std::unique_ptr<Metadata> metadata(AcquireMetadata());
|
||||
if (!metadata)
|
||||
|
@ -41,9 +41,10 @@ class MockDatabase : public CrashReportDatabase {
|
||||
MOCK_METHOD2(LookUpCrashReport, OperationStatus(const UUID&, Report*));
|
||||
MOCK_METHOD1(GetPendingReports, OperationStatus(std::vector<Report>*));
|
||||
MOCK_METHOD1(GetCompletedReports, OperationStatus(std::vector<Report>*));
|
||||
MOCK_METHOD2(GetReportForUploading,
|
||||
MOCK_METHOD3(GetReportForUploading,
|
||||
OperationStatus(const UUID&,
|
||||
std::unique_ptr<const UploadReport>*));
|
||||
std::unique_ptr<const UploadReport>*,
|
||||
bool report_metrics));
|
||||
MOCK_METHOD3(RecordUploadAttempt,
|
||||
OperationStatus(UploadReport*, bool, const std::string&));
|
||||
MOCK_METHOD2(SkipReportUpload,
|
||||
|
Loading…
x
Reference in New Issue
Block a user