// Copyright 2015 The Crashpad Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef CRASHPAD_CLIENT_PRUNE_CRASH_REPORTS_H_ #define CRASHPAD_CLIENT_PRUNE_CRASH_REPORTS_H_ #include <sys/types.h> #include <time.h> #include <memory> #include "client/crash_report_database.h" namespace crashpad { class PruneCondition; //! \brief Deletes crash reports from \a database that match \a condition. //! //! This function can be used to remove old or large reports from the database. //! The \a condition will be evaluated against each report in the \a database, //! sorted in descending order by CrashReportDatabase::Report::creation_time. //! This guarantee allows conditions to be stateful. //! //! \param[in] database The database from which crash reports will be deleted. //! \param[in] condition The condition against which all reports in the database //! will be evaluated. //! //! \return The number of deleted crash reports. size_t PruneCrashReportDatabase(CrashReportDatabase* database, PruneCondition* condition); std::unique_ptr<PruneCondition> GetDefaultDatabasePruneCondition(); //! \brief An abstract base class for evaluating crash reports for deletion. //! //! When passed to PruneCrashReportDatabase(), each crash report in the //! database will be evaluated according to ShouldPruneReport(). The reports //! are evaluated serially in descending sort order by //! CrashReportDatabase::Report::creation_time. class PruneCondition { … }; //! \brief A PruneCondition that deletes reports older than the specified number //! days. class AgePruneCondition final : public PruneCondition { … }; //! \brief A PruneCondition that deletes older reports to keep the total //! Crashpad database size under the specified limit. class DatabaseSizePruneCondition final : public PruneCondition { … }; //! \brief A PruneCondition that conjoins two other PruneConditions. class BinaryPruneCondition final : public PruneCondition { … }; } // namespace crashpad #endif // CRASHPAD_CLIENT_PRUNE_CRASH_REPORTS_H_