class SnapshotStore

Defined at line 25 of file ../../src/developer/forensics/crash_reports/snapshot_store.h

Manages the distribution and lifetime of snapshots.

To limit memory usage, the managed snapshots' archive cannot exceed |max_archives_size_| in size.

When space is constrained, calling AddSnapshot will cause SnapshotStore to drop the oldest

archive until there is enough space for the new archive.

Public Methods

void SnapshotStore (feedback::AnnotationManager * annotation_manager, std::string garbage_collected_snapshots_path, const std::optional<SnapshotPersistence::Root> & temp_root, const std::optional<SnapshotPersistence::Root> & persistent_root, StorageSize max_archives_size)

Defined at line 27 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

void AddSnapshot (const std::string & uuid, fuchsia::feedback::Attachment archive)

Stores the given data in memory for later retrieval.

Defined at line 148 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

void DeleteSnapshot (const std::string & uuid)

Deletes the data for |uuid| from memory, if it still exists.

Defined at line 115 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

void DeleteAll ()

Deletes all snapshots in memory and in persistence.

Defined at line 135 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

ItemLocation MoveToPersistence (const std::string & uuid, bool only_consider_tmp)

Moves the snapshot for |uuid| from memory to persistence, if possible. If |only_consider_tmp|

is true, only /tmp will be considered as a valid storage location. Returns the location of the

snapshot after the attempt to move.

Defined at line 195 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

void MoveToTmp (const std::string & uuid)

Attempts to move the snapshot for |uuid| from /cache to /tmp.

Defined at line 215 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

bool SnapshotExists (const std::string & uuid)

Returns true if data for |uuid| is currently stored in the SnapshotStore.

Defined at line 217 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

std::optional<ItemLocation> SnapshotLocation (const std::string & uuid)

Returns the location where the snapshot for |uuid| is currently stored in the SnapshotStore, if

anywhere.

Defined at line 226 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

size_t Size ()

Returns the number of snapshots stored in SnapshotStore.

Note: intended primarily for testing.

TODO(https://fxbug.dev/42063091): Consider deleting this function after reports with timed out

snapshots aren't associated with their original snapshot uuids (https://fxbug.dev/42062635).

Defined at line 235 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

bool IsGarbageCollected (const std::string & uuid)

Returns true if data for |uuid| was garbage collected.

Defined at line 237 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

bool SizeLimitsExceeded ()

Returns true if the size of the currently stored archives is greater than the limit.

Defined at line 241 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

Snapshot GetSnapshot (const std::string & uuid)

Returns the snapshot for |uuid|, if one exists. If no snapshot exists for |uuid| a

MissingSnapshot containing annotations indicating the error will be returned.

When a client no longer needs the data contained in a Snapshot, they should call Release to

inform the SnapshotStore. If all clients call release, the SnapshotStore will voluntarily

drop the Snapshot, freeing up space for new data.

Defined at line 66 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

std::vector<std::string> GetSnapshotUuids ()

Defined at line 104 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc

MissingSnapshot GetMissingSnapshot (const std::string & uuid)

Returns the snapshot for |uuid|. Check-fails that |uuid| results in the return of a

MissingSnapshot. A MissingSnapshot is guaranteed to be generated if |uuid| is the uuid of a

SpecialCaseSnapshot.

Defined at line 108 of file ../../src/developer/forensics/crash_reports/snapshot_store.cc