Update AssetClient/Request to use const byteRange

This commit is contained in:
Ryan Huffman 2017-04-26 18:01:56 -07:00
parent fee36453a3
commit f5b7feccde
5 changed files with 7 additions and 7 deletions

View file

@ -181,7 +181,7 @@ RenameMappingRequest* AssetClient::createRenameMappingRequest(const AssetPath& o
return request; return request;
} }
AssetRequest* AssetClient::createRequest(const AssetHash& hash, ByteRange byteRange) { AssetRequest* AssetClient::createRequest(const AssetHash& hash, const ByteRange& byteRange) {
auto request = new AssetRequest(hash, byteRange); auto request = new AssetRequest(hash, byteRange);
// Move to the AssetClient thread in case we are not currently on that thread (which will usually be the case) // Move to the AssetClient thread in case we are not currently on that thread (which will usually be the case)

View file

@ -56,7 +56,7 @@ public:
Q_INVOKABLE DeleteMappingsRequest* createDeleteMappingsRequest(const AssetPathList& paths); Q_INVOKABLE DeleteMappingsRequest* createDeleteMappingsRequest(const AssetPathList& paths);
Q_INVOKABLE SetMappingRequest* createSetMappingRequest(const AssetPath& path, const AssetHash& hash); Q_INVOKABLE SetMappingRequest* createSetMappingRequest(const AssetPath& path, const AssetHash& hash);
Q_INVOKABLE RenameMappingRequest* createRenameMappingRequest(const AssetPath& oldPath, const AssetPath& newPath); Q_INVOKABLE RenameMappingRequest* createRenameMappingRequest(const AssetPath& oldPath, const AssetPath& newPath);
Q_INVOKABLE AssetRequest* createRequest(const AssetHash& hash, ByteRange byteRange = ByteRange()); Q_INVOKABLE AssetRequest* createRequest(const AssetHash& hash, const ByteRange& byteRange = ByteRange());
Q_INVOKABLE AssetUpload* createUpload(const QString& filename); Q_INVOKABLE AssetUpload* createUpload(const QString& filename);
Q_INVOKABLE AssetUpload* createUpload(const QByteArray& data); Q_INVOKABLE AssetUpload* createUpload(const QByteArray& data);

View file

@ -23,7 +23,7 @@
static int requestID = 0; static int requestID = 0;
AssetRequest::AssetRequest(const QString& hash, ByteRange byteRange) : AssetRequest::AssetRequest(const QString& hash, const ByteRange& byteRange) :
_requestID(++requestID), _requestID(++requestID),
_hash(hash), _hash(hash),
_byteRange(byteRange) _byteRange(byteRange)

View file

@ -41,7 +41,7 @@ public:
UnknownError UnknownError
}; };
AssetRequest(const QString& hash, ByteRange byteRange = ByteRange()); AssetRequest(const QString& hash, const ByteRange& byteRange = ByteRange());
virtual ~AssetRequest() override; virtual ~AssetRequest() override;
Q_INVOKABLE void start(); Q_INVOKABLE void start();
@ -65,7 +65,7 @@ private:
QByteArray _data; QByteArray _data;
int _numPendingRequests { 0 }; int _numPendingRequests { 0 };
MessageID _assetRequestID { INVALID_MESSAGE_ID }; MessageID _assetRequestID { INVALID_MESSAGE_ID };
ByteRange _byteRange; const ByteRange _byteRange;
}; };
#endif #endif

View file

@ -16,8 +16,8 @@ struct ByteRange {
int64_t fromInclusive { 0 }; int64_t fromInclusive { 0 };
int64_t toExclusive { 0 }; int64_t toExclusive { 0 };
bool isSet() { return fromInclusive < 0 || fromInclusive < toExclusive; } bool isSet() const { return fromInclusive < 0 || fromInclusive < toExclusive; }
int64_t size() { return toExclusive - fromInclusive; } int64_t size() const { return toExclusive - fromInclusive; }
// byte ranges are invalid if: // byte ranges are invalid if:
// (1) the toExclusive of the range is negative // (1) the toExclusive of the range is negative