12 #ifndef hifi_AssetRequest_h
13 #define hifi_AssetRequest_h
19 #include "AssetClient.h"
20 #include "AssetUtils.h"
22 #include "ByteRange.h"
24 const QString ATP_SCHEME {
"atp:" };
26 class AssetRequest :
public QObject {
40 HashVerificationFailed,
41 SizeVerificationFailed,
46 AssetRequest(
const QString& hash,
const ByteRange& byteRange = ByteRange());
47 virtual ~AssetRequest()
override;
49 Q_INVOKABLE
void start();
51 const QByteArray& getData()
const {
return _data; }
52 const State& getState()
const {
return _state; }
53 const Error& getError()
const {
return _error; }
54 const QString getErrorString()
const;
55 QUrl getUrl()
const {
return AssetUtils::getATPUrl(_hash); }
56 QString getHash()
const {
return _hash; }
58 bool loadedFromCache()
const {
return _loadedFromCache; }
61 void finished(AssetRequest* thisRequest);
62 void progress(qint64 totalReceived, qint64 total);
66 State _state = NotStarted;
67 Error _error = NoError;
68 uint64_t _totalReceived { 0 };
71 int _numPendingRequests { 0 };
72 MessageID _assetRequestID { INVALID_MESSAGE_ID };
73 const ByteRange _byteRange;
74 bool _loadedFromCache {
false };