Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: client/crash_report_database_mac.mm

Issue 1392653002: Add functionality to prune old crash reports from the database. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/crash_report_database.h ('k') | client/crash_report_database_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/crash_report_database_mac.mm
diff --git a/client/crash_report_database_mac.mm b/client/crash_report_database_mac.mm
index f451efb0e0d96a3d14eaf48d2ffdc02bfd77f66a..621d8a66f344184be23522be35975c6412d8a093 100644
--- a/client/crash_report_database_mac.mm
+++ b/client/crash_report_database_mac.mm
@@ -125,6 +125,7 @@ class CrashReportDatabaseMac : public CrashReportDatabase {
bool successful,
const std::string& id) override;
OperationStatus SkipReportUpload(const UUID& uuid) override;
+ OperationStatus DeleteReport(const UUID& uuid) override;
private:
//! \brief A private extension of the Report class that maintains bookkeeping
@@ -476,6 +477,26 @@ CrashReportDatabase::OperationStatus CrashReportDatabaseMac::SkipReportUpload(
return kNoError;
}
+CrashReportDatabase::OperationStatus CrashReportDatabaseMac::DeleteReport(
+ const UUID& uuid) {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+
+ base::FilePath report_path = LocateCrashReport(uuid);
+ if (report_path.empty())
+ return kReportNotFound;
+
+ base::ScopedFD lock(ObtainReportLock(report_path));
+ if (!lock.is_valid())
+ return kBusyError;
+
+ if (unlink(report_path.value().c_str()) != 0) {
+ PLOG(ERROR) << "unlink " << report_path.value();
+ return kFileSystemError;
+ }
+
+ return kNoError;
+}
+
base::FilePath CrashReportDatabaseMac::LocateCrashReport(const UUID& uuid) {
const std::string target_uuid = uuid.ToString();
for (size_t i = 0; i < arraysize(kReportDirectories); ++i) {
« no previous file with comments | « client/crash_report_database.h ('k') | client/crash_report_database_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698