libzypp 17.37.17
|
#include <zypp-media/ng/provideitem.h>
Classes | |
struct | ItemStats |
Public Types | |
enum | State { Uninitialized , Pending , Downloading , Processing , Cancelling , Finalizing , Finished } |
Public Types inherited from zyppng::Base | |
using | Ptr = std::shared_ptr<Base> |
using | WeakPtr = std::weak_ptr<Base> |
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 |
Public Member Functions inherited from zyppng::Base | |
Base () | |
virtual | ~Base () |
WeakPtr | parent () const |
void | addChild (const Base::Ptr &child) |
void | removeChild (const Ptr &child) |
const std::unordered_set< Ptr > & | children () const |
std::thread::id | threadId () const |
template<typename T> | |
std::vector< std::weak_ptr< T > > | findChildren () const |
template<typename T> | |
std::shared_ptr< T > | shared_this () const |
template<typename T> | |
std::shared_ptr< T > | shared_this () |
template<typename T> | |
std::weak_ptr< T > | weak_this () const |
template<typename T> | |
std::weak_ptr< T > | weak_this () |
template<typename SenderFunc, typename ReceiverFunc> | |
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc) |
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker> | |
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers) |
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 Member Functions inherited from zyppng::Base | |
Base (BasePrivate &dd) |
Protected Attributes | |
ProvideRequestRef | _runningReq |
Protected Attributes inherited from zyppng::Base | |
std::unique_ptr< BasePrivate > | d_ptr |
Friends | |
class | Provide |
class | ProvidePrivate |
class | ProvideQueue |
Additional Inherited Members | |
Static Public Member Functions inherited from zyppng::Base | |
template<typename Obj, typename Functor> | |
static decltype(auto) | make_base_slot (Obj *o, Functor &&f) |
template<typename SenderFunc, typename ReceiverFunc> | |
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc) |
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker> | |
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers) |
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.
|
pure virtual |
Called by the controller when the item is supposed to start fetching / processing
Implemented in zyppng::AttachMediaItem, and zyppng::ProvideFileItem.
|
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 489 of file provideitem.cc.
ProvideItem::State zyppng::ProvideItem::state | ( | ) | const |
Definition at line 498 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::AttachMediaItem, and zyppng::ProvideFileItem.
Definition at line 190 of file provideitem.cc.
|
protectedvirtual |
Request was finished with a error The base implementation simply calls cancelWithError
Reimplemented in zyppng::AttachMediaItem, and zyppng::ProvideFileItem.
Definition at line 386 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::AttachMediaItem, and zyppng::ProvideFileItem.
Definition at line 402 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 451 of file provideitem.cc.
|
protectedpure virtual |
Cancels all running requests and immediately moves to error state
Implemented in zyppng::AttachMediaItem, and zyppng::ProvideFileItem.
|
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 461 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.