Crashpad
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Loading...
Searching...
No Matches
crashpad::CrashReportDatabaseGeneric Class Reference
Inheritance diagram for crashpad::CrashReportDatabaseGeneric:
[legend]
Collaboration diagram for crashpad::CrashReportDatabaseGeneric:
[legend]

Public Member Functions

 CrashReportDatabaseGeneric (const CrashReportDatabaseGeneric &)=delete
 
CrashReportDatabaseGenericoperator= (const CrashReportDatabaseGeneric &)=delete
 
bool Initialize (const base::FilePath &path, bool may_create)
 
SettingsGetSettings () override
 Returns the Settings object for this database.
 
OperationStatus PrepareNewCrashReport (std::unique_ptr< NewReport > *report) override
 Creates a record of a new crash report.
 
OperationStatus FinishedWritingCrashReport (std::unique_ptr< NewReport > report, UUID *uuid) override
 Informs the database that a crash report has been successfully written.
 
OperationStatus LookUpCrashReport (const UUID &uuid, Report *report) override
 Returns the crash report record for the unique identifier.
 
OperationStatus GetPendingReports (std::vector< Report > *reports) override
 Returns a list of crash report records that have not been uploaded.
 
OperationStatus GetCompletedReports (std::vector< Report > *reports) override
 Returns a list of crash report records that have been completed, either by being uploaded or by skipping upload.
 
OperationStatus GetReportForUploading (const UUID &uuid, std::unique_ptr< const UploadReport > *report, bool report_metrics) override
 Obtains and locks a report object for uploading to a collection server. On iOS the file lock is released and mutual-exclusion is kept via a file attribute.
 
OperationStatus SkipReportUpload (const UUID &uuid, Metrics::CrashSkippedReason reason) override
 Moves a report from the pending state to the completed state, but without the report being uploaded.
 
OperationStatus DeleteReport (const UUID &uuid) override
 Deletes a crash report file and its associated metadata.
 
OperationStatus RequestUpload (const UUID &uuid) override
 Marks a crash report as explicitly requested to be uploaded by the user and moves it to 'pending' state.
 
int CleanDatabase (time_t lockfile_ttl) override
 Cleans the database of expired lockfiles, metadata without report files, report files without metadata, and attachments without report files.
 
base::FilePath DatabasePath () override
 The path to the database passed to Initialize.
 
- Public Member Functions inherited from crashpad::CrashReportDatabase
 CrashReportDatabase (const CrashReportDatabase &)=delete
 
CrashReportDatabaseoperator= (const CrashReportDatabase &)=delete
 
OperationStatus RecordUploadComplete (std::unique_ptr< const UploadReport > report, const std::string &id)
 Records a successful upload for a report and updates the last upload attempt time as returned by Settings::GetLastUploadAttemptTime().
 

Additional Inherited Members

- Public Types inherited from crashpad::CrashReportDatabase
enum  OperationStatus
 The result code for operations performed on a database. More...
 
- Static Public Member Functions inherited from crashpad::CrashReportDatabase
static std::unique_ptr< CrashReportDatabaseInitialize (const base::FilePath &path)
 Opens a database of crash reports, possibly creating it.
 
static std::unique_ptr< CrashReportDatabaseInitializeWithoutCreating (const base::FilePath &path)
 Opens an existing database of crash reports.
 
- Protected Member Functions inherited from crashpad::CrashReportDatabase
base::FilePath AttachmentsRootPath ()
 Build a filepath for the root attachments directory.
 
base::FilePath AttachmentsPath (const UUID &uuid)
 Build a filepath for the directory for the report to hold attachments.
 
void RemoveAttachmentsByUUID (const UUID &uuid)
 Attempts to remove any attachments associated with the given report UUID. There may not be any, so failing is not an error.
 

Member Function Documentation

◆ CleanDatabase()

int crashpad::CrashReportDatabaseGeneric::CleanDatabase ( time_t lockfile_ttl)
overridevirtual

Cleans the database of expired lockfiles, metadata without report files, report files without metadata, and attachments without report files.

As the macOS implementation does not use lock or metadata files, the cleaning is limited to attachments without report files.

Parameters
[in]lockfile_ttlThe number of seconds at which lockfiles or new report files are considered expired.
Returns
The number of reports cleaned.

Reimplemented from crashpad::CrashReportDatabase.

◆ DatabasePath()

base::FilePath crashpad::CrashReportDatabaseGeneric::DatabasePath ( )
overridevirtual

The path to the database passed to Initialize.

Returns
The filepath of the database;

Implements crashpad::CrashReportDatabase.

◆ DeleteReport()

OperationStatus crashpad::CrashReportDatabaseGeneric::DeleteReport ( const UUID & uuid)
overridevirtual

Deletes a crash report file and its associated metadata.

Parameters
[in]uuidThe UUID of the report to delete.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.

◆ FinishedWritingCrashReport()

OperationStatus crashpad::CrashReportDatabaseGeneric::FinishedWritingCrashReport ( std::unique_ptr< NewReport > report,
UUID * uuid )
overridevirtual

Informs the database that a crash report has been successfully written.

Parameters
[in]reportA NewReport obtained with PrepareNewCrashReport(). The NewReport object will be invalidated as part of this call.
[out]uuidThe UUID of this crash report.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.

◆ GetCompletedReports()

OperationStatus crashpad::CrashReportDatabaseGeneric::GetCompletedReports ( std::vector< Report > * reports)
overridevirtual

Returns a list of crash report records that have been completed, either by being uploaded or by skipping upload.

Parameters
[out]reportsA list of crash report record objects. This must be empty on entry. Only valid if this returns kNoError.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.

◆ GetPendingReports()

OperationStatus crashpad::CrashReportDatabaseGeneric::GetPendingReports ( std::vector< Report > * reports)
overridevirtual

Returns a list of crash report records that have not been uploaded.

Parameters
[out]reportsA list of crash report record objects. This must be empty on entry. Only valid if this returns kNoError.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.

◆ GetReportForUploading()

OperationStatus crashpad::CrashReportDatabaseGeneric::GetReportForUploading ( const UUID & uuid,
std::unique_ptr< const UploadReport > * report,
bool report_metrics )
overridevirtual

Obtains and locks a report object for uploading to a collection server. On iOS the file lock is released and mutual-exclusion is kept via a file attribute.

Callers should upload the crash report using the FileReader provided. Callers should then call RecordUploadComplete() to record a successful upload. If RecordUploadComplete() is not called, the upload attempt will be recorded as unsuccessful and the report lock released when report is destroyed.

On iOS, holding a lock during a slow upload can lead to watchdog kills if the app is suspended mid-upload. Instead, if the client can obtain the lock, the database sets a lock-time file attribute and releases the lock. The attribute is cleared when the upload is completed. The lock-time attribute can be used to prevent file access from other processes, or to discard reports that likely were terminated mid-upload.

Parameters
[in]uuidThe unique identifier for the crash report record.
[out]reportA crash report record for the report to be uploaded. Only valid if this returns kNoError.
[in]report_metricsIf false, metrics will not be recorded for this upload attempt when RecordUploadComplete() is called or report is destroyed. Metadata for the upload attempt will still be recorded in the database.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.

◆ GetSettings()

Settings * crashpad::CrashReportDatabaseGeneric::GetSettings ( )
overridevirtual

Returns the Settings object for this database.

Returns
A weak pointer to the Settings object, which is owned by the database.

Implements crashpad::CrashReportDatabase.

◆ LookUpCrashReport()

OperationStatus crashpad::CrashReportDatabaseGeneric::LookUpCrashReport ( const UUID & uuid,
Report * report )
overridevirtual

Returns the crash report record for the unique identifier.

Parameters
[in]uuidThe crash report record unique identifier.
[out]reportA crash report record. Only valid if this returns kNoError.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.

◆ PrepareNewCrashReport()

OperationStatus crashpad::CrashReportDatabaseGeneric::PrepareNewCrashReport ( std::unique_ptr< NewReport > * report)
overridevirtual

Creates a record of a new crash report.

Callers should write the crash report using the FileWriter provided. Callers should then call FinishedWritingCrashReport() to complete report creation. If an error is encountered while writing the crash report, no special action needs to be taken. If FinishedWritingCrashReport() is not called, the report will be removed from the database when report is destroyed.

Parameters
[out]reportA NewReport object containing a FileWriter with which to write the report data. Only valid if this returns kNoError.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.

◆ RequestUpload()

OperationStatus crashpad::CrashReportDatabaseGeneric::RequestUpload ( const UUID & uuid)
overridevirtual

Marks a crash report as explicitly requested to be uploaded by the user and moves it to 'pending' state.

Parameters
[in]uuidThe unique identifier for the crash report record.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.

◆ SkipReportUpload()

OperationStatus crashpad::CrashReportDatabaseGeneric::SkipReportUpload ( const UUID & uuid,
Metrics::CrashSkippedReason reason )
overridevirtual

Moves a report from the pending state to the completed state, but without the report being uploaded.

This can be used if the user has disabled crash report collection, but crash generation is still enabled in the product.

Parameters
[in]uuidThe unique identifier for the crash report record.
[in]reasonThe reason the report upload is being skipped for metrics tracking purposes.
Returns
The operation status code.

Implements crashpad::CrashReportDatabase.


The documentation for this class was generated from the following file: