libzypp 17.31.23
|
#include </home/abuild/rpmbuild/BUILD/libzypp-17.31.23/zypp-media/ng/provideitem.h>
Classes | |
struct | ItemStats |
Public Types | |
enum | State { Uninitialized , Pending , Downloading , Processing , Cancelling , Finalizing , Finished } |
Public Member Functions | |
ProvideItem (ProvidePrivate &parent) | |
~ProvideItem () | |
virtual void | initialize ()=0 |
virtual void | released () |
State | state () const |
SignalProxy< void(ProvideItem &item, State oldState, State newState)> | sigStateChanged () |
ProvidePrivate & | provider () |
virtual bool | canRedirectTo (ProvideRequestRef startedReq, const zypp::Url &url) |
const std::optional< ItemStats > & | currentStats () const |
const std::optional< ItemStats > & | previousStats () const |
virtual std::chrono::steady_clock::time_point | startTime () const |
virtual std::chrono::steady_clock::time_point | finishedTime () const |
void | pulse () |
virtual zypp::ByteCount | bytesExpected () const |
Protected Member Functions | |
virtual ItemStats | makeStats () |
virtual void | informalMessage (ProvideQueue &, ProvideRequestRef req, const ProvideMessage &msg) |
virtual void | cacheMiss (ProvideRequestRef req) |
virtual void | finishReq (ProvideQueue &queue, ProvideRequestRef finishedReq, const ProvideMessage &msg) |
virtual void | finishReq (ProvideQueue *queue, ProvideRequestRef finishedReq, const std::exception_ptr excpt) |
virtual expected< zypp::media::AuthData > | authenticationRequired (ProvideQueue &queue, ProvideRequestRef req, const zypp::Url &effectiveUrl, int64_t lastTimestamp, const std::map< std::string, std::string > &extraFields) |
bool | safeRedirectTo (ProvideRequestRef startedReq, const zypp::Url &url) |
void | redirectTo (ProvideRequestRef startedReq, const zypp::Url &url) |
virtual bool | enqueueRequest (ProvideRequestRef request) |
virtual void | cancelWithError (std::exception_ptr error)=0 |
bool | dequeue () |
void | updateState (const State newState) |
void | setFinished () |
Protected Attributes | |
ProvideRequestRef | _runningReq |
Private Member Functions | |
ZYPP_DECLARE_PRIVATE (ProvideItem) | |
Friends | |
class | Provide |
class | ProvidePrivate |
class | ProvideQueue |
Represents a operation added to the provide queue by the user code. A "user" operation can have multiple steps of downloading and processing one or multiple files. Even though this class is in public API space it's not possible to implement custom Items since more internal API would be required for it. It is only public to support the ProvideStatus class, so it can query details of a Item.
Definition at line 28 of file provideitem.h.
Enumerator | |
---|---|
Uninitialized | |
Pending | |
Downloading | |
Processing | |
Cancelling | |
Finalizing | |
Finished |
Definition at line 35 of file provideitem.h.
zyppng::ProvideItem::ProvideItem | ( | ProvidePrivate & | parent | ) |
Definition at line 83 of file provideitem.cc.
zyppng::ProvideItem::~ProvideItem | ( | ) |
Definition at line 87 of file provideitem.cc.
|
private |
|
pure virtual |
Called by the controller when the item is supposed to start fetching / processing
Implemented in zyppng::ProvideFileItem, and zyppng::AttachMediaItem.
|
virtual |
Called when the promise reference is released by the user process, cancel all running requests if there are any and clean up
Definition at line 485 of file provideitem.cc.
ProvideItem::State zyppng::ProvideItem::state | ( | ) | const |
Definition at line 494 of file provideitem.cc.
SignalProxy< void(ProvideItem &item, State oldState, State newState)> zyppng::ProvideItem::sigStateChanged | ( | ) |
Signal that is emitted when the state of the Item has changed
ProvidePrivate & zyppng::ProvideItem::provider | ( | ) |
Definition at line 90 of file provideitem.cc.
|
virtual |
Returns true if a redirect is allowed and does not conflict with previous redirects. Otherwise false is returned. This does not remember the passed URL as a redirect
Definition at line 110 of file provideitem.cc.
const std::optional< ProvideItem::ItemStats > & zyppng::ProvideItem::currentStats | ( | ) | const |
Returns the item statistics that were collected the last time pulse() was called on the item. If the item has not been started yet, this returns a empty optional
Definition at line 122 of file provideitem.cc.
const std::optional< ProvideItem::ItemStats > & zyppng::ProvideItem::previousStats | ( | ) | const |
Returns the item statistics that were collected the previous time pulse() was called on the item.
Definition at line 127 of file provideitem.cc.
|
virtual |
Returns the time point when the item started to process/download. If the item has not started yet, this returns epoch
Definition at line 132 of file provideitem.cc.
|
virtual |
Returns the time point when the item was finished. If the item was not finished yet, this returns epoch
Definition at line 137 of file provideitem.cc.
void zyppng::ProvideItem::pulse | ( | ) |
Updates the item statistics, this is called automatically by the Provide instance and usually does not need to be called explicitely by usercode.
Definition at line 141 of file provideitem.cc.
|
virtual |
Returns the bytes the item expects to provide, the default impl returns 0
Reimplemented in zyppng::ProvideFileItem.
Definition at line 154 of file provideitem.cc.
|
protectedvirtual |
Reimplemented in zyppng::ProvideFileItem.
Definition at line 159 of file provideitem.cc.
|
protectedvirtual |
Request received a informal message, e.g. ProvideStarted
Reimplemented in zyppng::ProvideFileItem.
Definition at line 167 of file provideitem.cc.
|
protectedvirtual |
Request had a cache miss and will be queued again, forget all about the request
Definition at line 180 of file provideitem.cc.
|
protectedvirtual |
Request was finished by the queue Base implementation handles redirect, metalink and error messages. If a different message is received, cancelWithError is called.
A subclass has to overload this function to handle success messages
Reimplemented in zyppng::ProvideFileItem, zyppng::AttachMediaItem, zyppng::ProvideFileItem, and zyppng::AttachMediaItem.
Definition at line 190 of file provideitem.cc.
|
protectedvirtual |
Request was finished with a error The base implementation simply calls cancelWithError
Reimplemented in zyppng::ProvideFileItem, and zyppng::AttachMediaItem.
Definition at line 382 of file provideitem.cc.
|
protectedvirtual |
Request needs authentication data, the function is supposed to return the AuthData to use for the response, or an error The default implementation simply uses the given URL to look for a Auth match in the zypp::media::CredentialManager.
Reimplemented in zyppng::ProvideFileItem, and zyppng::AttachMediaItem.
Definition at line 398 of file provideitem.cc.
|
protected |
Remembers previous redirects and returns false if the URL was encountered before, use this to prevent the item getting caught in a redirect loop
Definition at line 95 of file provideitem.cc.
|
protected |
Similar to safeRedirectTo, but does not check if a URL was already used by this Request before.
Definition at line 104 of file provideitem.cc.
|
protectedvirtual |
Enqueue the request in the correct queue, the item implementation is supposed to hold its own reference to all started requests, the base implementation just keeps track of 1 request at a time.
Definition at line 447 of file provideitem.cc.
|
protectedpure virtual |
Cancels all running requests and immediately moves to error state
Implemented in zyppng::ProvideFileItem, and zyppng::AttachMediaItem.
|
protected |
Dequeue this item and stop all requests in queues running Call this when the item is cancelled or finished.
|
protected |
Call this when the state of the item changes.
Definition at line 457 of file provideitem.cc.
|
protected |
|
friend |
Definition at line 31 of file provideitem.h.
|
friend |
Definition at line 32 of file provideitem.h.
|
friend |
Definition at line 33 of file provideitem.h.
|
protected |
Definition at line 189 of file provideitem.h.