Index: client/crash_report_database_mac.mm |
diff --git a/client/crash_report_database_mac.mm b/client/crash_report_database_mac.mm |
index fe3e13a360a465531ac08d0182ff6532d0da32ec..1b54d1eff6ab174a622977e26c8fe8ec0ef978ba 100644 |
--- a/client/crash_report_database_mac.mm |
+++ b/client/crash_report_database_mac.mm |
@@ -109,6 +109,7 @@ class CrashReportDatabaseMac : public CrashReportDatabase { |
OperationStatus PrepareNewCrashReport(NewReport** report) override; |
OperationStatus FinishedWritingCrashReport(NewReport* report, |
UUID* uuid) override; |
+ OperationStatus ErrorWritingCrashReport(NewReport* report) override; |
OperationStatus LookUpCrashReport(const UUID& uuid, |
Report* report) override; |
OperationStatus GetPendingReports( |
@@ -280,6 +281,24 @@ CrashReportDatabaseMac::FinishedWritingCrashReport(NewReport* report, |
} |
CrashReportDatabase::OperationStatus |
+CrashReportDatabaseMac::ErrorWritingCrashReport(NewReport* report) { |
+ // Takes ownership of the |handle| and the O_EXLOCK. |
+ base::ScopedFD lock(report->handle); |
+ |
+ // Take ownership of the report. |
+ scoped_ptr<NewReport> scoped_report(report); |
+ |
+ // Remove the file that the report would have been written to had no error |
+ // occurred. |
+ if (unlink(report->path.value().c_str()) != 0) { |
+ PLOG(ERROR) << "unlink " << report->path.value(); |
+ return kFileSystemError; |
+ } |
+ |
+ return kNoError; |
+} |
+ |
+CrashReportDatabase::OperationStatus |
CrashReportDatabaseMac::LookUpCrashReport(const UUID& uuid, |
CrashReportDatabase::Report* report) { |
base::FilePath path = LocateCrashReport(uuid); |