Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::CatalogEncodedFontStore Class Reference

Session-owned verified encoded bytes and shared catalog decode admission. More...

#include "donner/svg/resources/CatalogEncodedFontStore.h"

Public Member Functions

 CatalogEncodedFontStore (const CatalogEncodedFontStore &)=delete
CatalogEncodedFontStore & operator= (const CatalogEncodedFontStore &)=delete
FontFaceAvailability availability (std::string_view contentId) const
 Return the current consumer-visible state for a compiled catalog asset.
bool queue (std::string_view contentId)
 Queue only a coordinator-approved demand. Enumeration and provider loads do not call this.
uint64_t beginFetch (std::string_view contentId)
 Start a queued fetch; the returned nonzero token rejects stale/duplicate completions.
bool publishVerified (std::string_view contentId, uint64_t requestToken, std::vector< uint8_t > bytes)
 Publish broker-verified bytes for an exact active request. Returns false without mutation on unknown IDs, stale tokens, size/capacity/header mismatch, or exhausted retention budget.
bool adoptReadyAssets ()
 Adopt staged immutable bytes only at a coordinator-approved idle/frame boundary. Until then availability remains Fetching and encodedBytes returns null, so a running frame cannot mix old and new font geometry. Returns whether any bytes became consumer-visible.
bool fail (std::string_view contentId, uint64_t requestToken)
 Finish an exact active request with a terminal transport failure.
bool retry (std::string_view contentId)
 Explicit retry is coordinator-owned; deadlines/cooldowns are enforced by the broker.
std::shared_ptr< const std::vector< uint8_t > > encodedBytes (std::string_view contentId) const
 An immutable lease preserves bytes during a provider copy. Eviction refuses leased buffers.
bool evict (std::string_view contentId)
 Evict unleased encoded bytes for a catalog asset.
size_t retainedBytes () const
 Encoded-buffer capacity bytes currently retained by this store.
FontFaceAdmission tryAcquireDecode (std::string_view contentId) const
 One admitted catalog copy/decode at a time. Release is an independent wake source, including when a pending preview document has already died and only its coordinator task remains.
uint64_t wakeRevision () const
 Revision incremented when a consumer may need to retry pending font work.
void setWakeCallback (std::function< void()> callback)
 Install a callback that schedules a retry after an admitted state change.

Static Public Attributes

static constexpr size_t kMaximumAssetBytes = 2 * 1024 * 1024
 Per-asset cap for encoded buffer capacity and declared decoded bytes.
static constexpr size_t kMaximumRetainedBytes = 4 * 1024 * 1024
 Maximum encoded-buffer capacity bytes retained by the store at once.

Detailed Description

Session-owned verified encoded bytes and shared catalog decode admission.

All methods are thread-safe. The store never fetches, decodes, or calls into a document. The browser broker verifies exact length and SHA-256 before publishVerified(); the store additionally enforces the compiled ID and size and only accepts an in-flight request token. A caller cannot establish trust using a response-provided manifest, URL, or same-origin status.

The wake callback is copied under the mutex and invoked after releasing it. It must capture lifetime-safe application state and only schedule work. It may run after setWakeCallback({}) if another thread already copied it; callers must invalidate their lifetime token at teardown.

Member Function Documentation

◆ availability()

FontFaceAvailability donner::svg::CatalogEncodedFontStore::availability ( std::string_view contentId) const

Return the current consumer-visible state for a compiled catalog asset.

Parameters
contentIdCompiled SHA-256 identity of the encoded font.

◆ evict()

bool donner::svg::CatalogEncodedFontStore::evict ( std::string_view contentId)

Evict unleased encoded bytes for a catalog asset.

Parameters
contentIdCompiled SHA-256 identity of the encoded font.
Returns
Whether the asset's stored bytes were evicted.

◆ setWakeCallback()

void donner::svg::CatalogEncodedFontStore::setWakeCallback ( std::function< void()> callback)

Install a callback that schedules a retry after an admitted state change.

Parameters
callbackLifetime-safe callback, or empty to clear it.

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