Remove old download priority arguments.

This commit is contained in:
John Preston 2019-04-12 15:52:39 +04:00
parent b2895a39ed
commit eb438e35ee
14 changed files with 188 additions and 292 deletions

View File

@ -499,13 +499,13 @@ void Panel::hideAndDestroy() {
void Panel::processUserPhoto() {
if (!_user->userpicLoaded()) {
_user->loadUserpic(true);
_user->loadUserpic();
}
const auto photo = _user->userpicPhotoId()
? _user->owner().photo(_user->userpicPhotoId()).get()
: nullptr;
if (isGoodUserPhoto(photo)) {
photo->large()->load(_user->userpicPhotoOrigin(), true);
photo->large()->load(_user->userpicPhotoOrigin());
} else if (_user->userpicPhotoUnknown() || (photo && !photo->date)) {
_user->session().api().requestFullPeer(_user);
}

View File

@ -131,10 +131,7 @@ void GoodThumbSource::ready(
});
}
void GoodThumbSource::load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void GoodThumbSource::load(Data::FileOrigin origin) {
if (loading() || _empty) {
return;
}
@ -163,12 +160,9 @@ void GoodThumbSource::load(
std::move(callback));
}
void GoodThumbSource::loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void GoodThumbSource::loadEvenCancelled(Data::FileOrigin origin) {
_empty = false;
load(origin, loadFirst, prior);
load(origin);
}
QImage GoodThumbSource::takeLoaded() {

View File

@ -17,14 +17,8 @@ class GoodThumbSource : public Images::Source {
public:
explicit GoodThumbSource(not_null<DocumentData*> document);
void load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void load(Data::FileOrigin origin) override;
void loadEvenCancelled(Data::FileOrigin origin) override;
QImage takeLoaded() override;
void unload() override;

View File

@ -239,8 +239,8 @@ void PeerData::paintUserpicSquare(Painter &p, int x, int y, int size) const {
}
}
void PeerData::loadUserpic(bool loadFirst, bool prior) {
_userpic->load(userpicOrigin(), loadFirst, prior);
void PeerData::loadUserpic() {
_userpic->load(userpicOrigin());
}
bool PeerData::userpicLoaded() const {

View File

@ -229,7 +229,7 @@ public:
int x,
int y,
int size) const;
void loadUserpic(bool loadFirst = false, bool prior = true);
void loadUserpic();
[[nodiscard]] bool userpicLoaded() const;
[[nodiscard]] bool useEmptyUserpic() const;
[[nodiscard]] InMemoryKey userpicUniqueKey() const;

View File

@ -62,5 +62,5 @@ LocationData::LocationData(const LocationCoords &coords)
}
void LocationData::load(Data::FileOrigin origin) {
thumb->load(origin, false, false);
thumb->load(origin);
}

View File

@ -34,6 +34,12 @@ constexpr auto kMaxFileQueries = 16;
// Max 8 http[s] files downloaded at the same time.
constexpr auto kMaxWebFileQueries = 8;
// Different part sizes are not supported for now :(
// Because we start downloading with some part size
// and then we get a cdn-redirect where we support only
// fixed part size download for hash checking.
constexpr auto kPartSize = 128 * 1024;
} // namespace
Downloader::Downloader(not_null<ApiWrap*> api)
@ -136,14 +142,6 @@ Downloader::~Downloader() {
namespace {
constexpr auto kDownloadPhotoPartSize = 64 * 1024; // 64kb for photo
constexpr auto kDownloadDocumentPartSize = 128 * 1024; // 128kb for document
constexpr auto kDownloadCdnPartSize = 128 * 1024; // 128kb for cdn requests
} // namespace
namespace {
QThread *_webLoadThread = nullptr;
WebLoadManager *_webLoadManager = nullptr;
WebLoadManager *webLoadManager() {
@ -292,11 +290,6 @@ void FileLoader::removeFromQueue() {
_inQueue = false;
}
void FileLoader::pause() {
removeFromQueue();
_paused = true;
}
FileLoader::~FileLoader() {
removeFromQueue();
}
@ -308,7 +301,7 @@ void FileLoader::localLoaded(
_localLoading = nullptr;
if (result.data.isEmpty()) {
_localStatus = LocalStatus::NotFound;
start(true);
start();
return;
}
if (!imageData.isNull()) {
@ -319,10 +312,7 @@ void FileLoader::localLoaded(
notifyAboutProgress();
}
void FileLoader::start(bool loadFirst, bool prior) {
if (_paused) {
_paused = false;
}
void FileLoader::start() {
if (_finished || tryLoadLocal()) {
return;
} else if (_fromCloud == LoadFromLocalOnly) {
@ -339,59 +329,36 @@ void FileLoader::start(bool loadFirst, bool prior) {
auto currentPriority = _downloader->currentPriority();
FileLoader *before = nullptr, *after = nullptr;
if (prior) {
if (_inQueue && _priority == currentPriority) {
if (loadFirst) {
if (!_prev) return startLoading(loadFirst, prior);
before = _queue->start;
} else {
if (!_next || _next->_priority < currentPriority) return startLoading(loadFirst, prior);
after = _next;
while (after->_next && after->_next->_priority == currentPriority) {
after = after->_next;
}
}
} else {
_priority = currentPriority;
if (loadFirst) {
if (_inQueue && !_prev) return startLoading(loadFirst, prior);
before = _queue->start;
} else {
if (_inQueue) {
if (_next && _next->_priority == currentPriority) {
after = _next;
} else if (_prev && _prev->_priority < currentPriority) {
before = _prev;
while (before->_prev && before->_prev->_priority < currentPriority) {
before = before->_prev;
}
} else {
return startLoading(loadFirst, prior);
}
} else {
if (_queue->start && _queue->start->_priority == currentPriority) {
after = _queue->start;
} else {
before = _queue->start;
}
}
if (after) {
while (after->_next && after->_next->_priority == currentPriority) {
after = after->_next;
}
}
}
if (_inQueue && _priority == currentPriority) {
if (!_next || _next->_priority < currentPriority) return startLoading();
after = _next;
while (after->_next && after->_next->_priority == currentPriority) {
after = after->_next;
}
} else {
if (loadFirst) {
if (_inQueue && (!_prev || _prev->_priority == currentPriority)) return startLoading(loadFirst, prior);
before = _prev;
while (before->_prev && before->_prev->_priority != currentPriority) {
before = before->_prev;
_priority = currentPriority;
if (_inQueue) {
if (_next && _next->_priority == currentPriority) {
after = _next;
} else if (_prev && _prev->_priority < currentPriority) {
before = _prev;
while (before->_prev && before->_prev->_priority < currentPriority) {
before = before->_prev;
}
} else {
return startLoading();
}
} else {
if (_inQueue && !_next) return startLoading(loadFirst, prior);
after = _queue->end;
if (_queue->start && _queue->start->_priority == currentPriority) {
after = _queue->start;
} else {
before = _queue->start;
}
}
if (after) {
while (after->_next && after->_next->_priority == currentPriority) {
after = after->_next;
}
}
}
@ -423,7 +390,7 @@ void FileLoader::start(bool loadFirst, bool prior) {
} else {
LOG(("Queue Error: _start && !before && !after"));
}
return startLoading(loadFirst, prior);
return startLoading();
}
void FileLoader::loadLocal(const Storage::Cache::Key &key) {
@ -524,8 +491,8 @@ void FileLoader::cancel(bool fail) {
LoadNextFromQueue(queue);
}
void FileLoader::startLoading(bool loadFirst, bool prior) {
if ((_queue->queriesCount >= _queue->queriesLimit && (!loadFirst || !prior)) || _finished) {
void FileLoader::startLoading() {
if ((_queue->queriesCount >= _queue->queriesLimit) || _finished) {
return;
}
loadPart();
@ -736,7 +703,7 @@ bool mtpFileLoader::loadPart() {
}
makeRequest(_nextRequestOffset);
_nextRequestOffset += partSize();
_nextRequestOffset += Storage::kPartSize;
return true;
}
@ -747,22 +714,6 @@ MTP::DcId mtpFileLoader::dcId() const {
return Global::WebFileDcId();
}
int mtpFileLoader::partSize() const {
return kDownloadCdnPartSize;
// Different part sizes are not supported for now :(
// Because we start downloading with some part size
// and then we get a cdn-redirect where we support only
// fixed part size download for hash checking.
//
//if (_cdnDcId) {
// return kDownloadCdnPartSize;
//} else if (_locationType == UnknownFileLocation) {
// return kDownloadPhotoPartSize;
//}
//return kDownloadDocumentPartSize;
}
mtpFileLoader::RequestData mtpFileLoader::prepareRequest(int offset) const {
auto result = RequestData();
result.dcId = _cdnDcId ? _cdnDcId : dcId();
@ -775,7 +726,7 @@ mtpFileLoader::RequestData mtpFileLoader::prepareRequest(int offset) const {
mtpRequestId mtpFileLoader::sendRequest(const RequestData &requestData) {
const auto offset = requestData.offset;
const auto limit = partSize();
const auto limit = Storage::kPartSize;
const auto shiftedDcId = MTP::downloadDcId(
requestData.dcId,
requestData.dcIndex);
@ -885,90 +836,107 @@ void mtpFileLoader::normalPartLoaded(
void mtpFileLoader::webPartLoaded(
const MTPupload_WebFile &result,
mtpRequestId requestId) {
Expects(result.type() == mtpc_upload_webFile);
auto offset = finishSentRequestGetOffset(requestId);
auto &webFile = result.c_upload_webFile();
if (!_size) {
_size = webFile.vsize.v;
} else if (webFile.vsize.v != _size) {
LOG(("MTP Error: Bad size provided by bot for webDocument: %1, real: %2").arg(_size).arg(webFile.vsize.v));
return cancel(true);
}
auto buffer = bytes::make_span(webFile.vbytes.v);
return partLoaded(offset, buffer);
result.match([&](const MTPDupload_webFile &data) {
const auto offset = finishSentRequestGetOffset(requestId);
if (!_size) {
_size = data.vsize.v;
} else if (data.vsize.v != _size) {
LOG(("MTP Error: "
"Bad size provided by bot for webDocument: %1, real: %2"
).arg(_size
).arg(data.vsize.v));
cancel(true);
return;
}
partLoaded(offset, bytes::make_span(data.vbytes.v));
});
}
void mtpFileLoader::cdnPartLoaded(const MTPupload_CdnFile &result, mtpRequestId requestId) {
Expects(!_finished);
auto offset = finishSentRequestGetOffset(requestId);
if (result.type() == mtpc_upload_cdnFileReuploadNeeded) {
const auto offset = finishSentRequestGetOffset(requestId);
result.match([&](const MTPDupload_cdnFileReuploadNeeded &data) {
auto requestData = RequestData();
requestData.dcId = dcId();
requestData.dcIndex = 0;
requestData.offset = offset;
auto shiftedDcId = MTP::downloadDcId(requestData.dcId, requestData.dcIndex);
auto requestId = MTP::send(MTPupload_ReuploadCdnFile(MTP_bytes(_cdnToken), result.c_upload_cdnFileReuploadNeeded().vrequest_token), rpcDone(&mtpFileLoader::reuploadDone), rpcFail(&mtpFileLoader::cdnPartFailed), shiftedDcId);
const auto shiftedDcId = MTP::downloadDcId(
requestData.dcId,
requestData.dcIndex);
const auto requestId = MTP::send(
MTPupload_ReuploadCdnFile(
MTP_bytes(_cdnToken),
data.vrequest_token),
rpcDone(&mtpFileLoader::reuploadDone),
rpcFail(&mtpFileLoader::cdnPartFailed),
shiftedDcId);
placeSentRequest(requestId, requestData);
return;
}
Expects(result.type() == mtpc_upload_cdnFile);
}, [&](const MTPDupload_cdnFile &data) {
auto key = bytes::make_span(_cdnEncryptionKey);
auto iv = bytes::make_span(_cdnEncryptionIV);
Expects(key.size() == MTP::CTRState::KeySize);
Expects(iv.size() == MTP::CTRState::IvecSize);
auto key = bytes::make_span(_cdnEncryptionKey);
auto iv = bytes::make_span(_cdnEncryptionIV);
Expects(key.size() == MTP::CTRState::KeySize);
Expects(iv.size() == MTP::CTRState::IvecSize);
auto state = MTP::CTRState();
auto ivec = bytes::make_span(state.ivec);
std::copy(iv.begin(), iv.end(), ivec.begin());
auto state = MTP::CTRState();
auto ivec = bytes::make_span(state.ivec);
std::copy(iv.begin(), iv.end(), ivec.begin());
auto counterOffset = static_cast<uint32>(offset) >> 4;
state.ivec[15] = static_cast<uchar>(counterOffset & 0xFF);
state.ivec[14] = static_cast<uchar>((counterOffset >> 8) & 0xFF);
state.ivec[13] = static_cast<uchar>((counterOffset >> 16) & 0xFF);
state.ivec[12] = static_cast<uchar>((counterOffset >> 24) & 0xFF);
auto counterOffset = static_cast<uint32>(offset) >> 4;
state.ivec[15] = static_cast<uchar>(counterOffset & 0xFF);
state.ivec[14] = static_cast<uchar>((counterOffset >> 8) & 0xFF);
state.ivec[13] = static_cast<uchar>((counterOffset >> 16) & 0xFF);
state.ivec[12] = static_cast<uchar>((counterOffset >> 24) & 0xFF);
auto decryptInPlace = data.vbytes.v;
auto buffer = bytes::make_detached_span(decryptInPlace);
MTP::aesCtrEncrypt(buffer, key.data(), &state);
auto decryptInPlace = result.c_upload_cdnFile().vbytes.v;
auto buffer = bytes::make_detached_span(decryptInPlace);
MTP::aesCtrEncrypt(buffer, key.data(), &state);
switch (checkCdnFileHash(offset, buffer)) {
case CheckCdnHashResult::NoHash: {
_cdnUncheckedParts.emplace(offset, decryptInPlace);
requestMoreCdnFileHashes();
} return;
switch (checkCdnFileHash(offset, buffer)) {
case CheckCdnHashResult::NoHash: {
_cdnUncheckedParts.emplace(offset, decryptInPlace);
requestMoreCdnFileHashes();
} return;
case CheckCdnHashResult::Invalid: {
LOG(("API Error: Wrong cdnFileHash for offset %1.").arg(offset));
cancel(true);
} return;
case CheckCdnHashResult::Invalid: {
LOG(("API Error: Wrong cdnFileHash for offset %1.").arg(offset));
cancel(true);
} return;
case CheckCdnHashResult::Good: return partLoaded(offset, buffer);
}
Unexpected("Result of checkCdnFileHash()");
case CheckCdnHashResult::Good: {
partLoaded(offset, buffer);
} return;
}
Unexpected("Result of checkCdnFileHash()");
});
}
mtpFileLoader::CheckCdnHashResult mtpFileLoader::checkCdnFileHash(int offset, bytes::const_span buffer) {
auto cdnFileHashIt = _cdnFileHashes.find(offset);
mtpFileLoader::CheckCdnHashResult mtpFileLoader::checkCdnFileHash(
int offset,
bytes::const_span buffer) {
const auto cdnFileHashIt = _cdnFileHashes.find(offset);
if (cdnFileHashIt == _cdnFileHashes.cend()) {
return CheckCdnHashResult::NoHash;
}
auto realHash = openssl::Sha256(buffer);
if (bytes::compare(realHash, bytes::make_span(cdnFileHashIt->second.hash))) {
const auto realHash = openssl::Sha256(buffer);
const auto receivedHash = bytes::make_span(cdnFileHashIt->second.hash);
if (bytes::compare(realHash, receivedHash)) {
return CheckCdnHashResult::Invalid;
}
return CheckCdnHashResult::Good;
}
void mtpFileLoader::reuploadDone(const MTPVector<MTPFileHash> &result, mtpRequestId requestId) {
void mtpFileLoader::reuploadDone(
const MTPVector<MTPFileHash> &result,
mtpRequestId requestId) {
auto offset = finishSentRequestGetOffset(requestId);
addCdnHashes(result.v);
makeRequest(offset);
}
void mtpFileLoader::getCdnFileHashesDone(const MTPVector<MTPFileHash> &result, mtpRequestId requestId) {
void mtpFileLoader::getCdnFileHashesDone(
const MTPVector<MTPFileHash> &result,
mtpRequestId requestId) {
Expects(!_finished);
Expects(_cdnHashesRequestId == requestId);
@ -1018,14 +986,22 @@ void mtpFileLoader::getCdnFileHashesDone(const MTPVector<MTPFileHash> &result, m
}
return;
}
LOG(("API Error: Could not find cdnFileHash for offset %1 after getCdnFileHashes request.").arg(offset));
LOG(("API Error: "
"Could not find cdnFileHash for offset %1 "
"after getCdnFileHashes request."
).arg(offset));
cancel(true);
}
void mtpFileLoader::placeSentRequest(mtpRequestId requestId, const RequestData &requestData) {
void mtpFileLoader::placeSentRequest(
mtpRequestId requestId,
const RequestData &requestData) {
Expects(!_finished);
_downloader->requestedAmountIncrement(requestData.dcId, requestData.dcIndex, partSize());
_downloader->requestedAmountIncrement(
requestData.dcId,
requestData.dcIndex,
Storage::kPartSize);
++_queue->queriesCount;
_sentRequests.emplace(requestId, requestData);
}
@ -1035,7 +1011,10 @@ int mtpFileLoader::finishSentRequestGetOffset(mtpRequestId requestId) {
Assert(it != _sentRequests.cend());
auto requestData = it->second;
_downloader->requestedAmountIncrement(requestData.dcId, requestData.dcIndex, -partSize());
_downloader->requestedAmountIncrement(
requestData.dcId,
requestData.dcIndex,
-Storage::kPartSize);
--_queue->queriesCount;
_sentRequests.erase(it);
@ -1141,12 +1120,12 @@ void mtpFileLoader::switchToCDN(
}
void mtpFileLoader::addCdnHashes(const QVector<MTPFileHash> &hashes) {
for_const (auto &hash, hashes) {
Assert(hash.type() == mtpc_fileHash);
auto &data = hash.c_fileHash();
_cdnFileHashes.emplace(
data.voffset.v,
CdnFileHash { data.vlimit.v, data.vhash.v });
for (const auto &hash : hashes) {
hash.match([&](const MTPDfileHash &data) {
_cdnFileHashes.emplace(
data.voffset.v,
CdnFileHash{ data.vlimit.v, data.vhash.v });
});
}
}
@ -1226,9 +1205,7 @@ webFileLoader::webFileLoader(
fromCloud,
autoLoading,
cacheTag)
, _url(url)
, _requestSent(false)
, _already(0) {
, _url(url) {
_queue = _downloader->queueForWeb();
}

View File

@ -133,18 +133,14 @@ public:
bool setFileName(const QString &filename); // set filename for loaders to cache
void permitLoadFromCloud();
void pause();
void start(bool loadFirst = false, bool prior = true);
void start();
void cancel();
bool loading() const {
return _inQueue;
}
bool paused() const {
return _paused;
}
bool started() const {
return _inQueue || _paused;
return _inQueue;
}
bool loadingLocal() const {
return (_localStatus == LocalStatus::Loading);
@ -184,7 +180,7 @@ protected:
virtual std::optional<MediaKey> fileLocationKey() const = 0;
virtual void cancelRequests() = 0;
void startLoading(bool loadFirst, bool prior);
void startLoading();
void removeFromQueue();
void cancel(bool failed);
@ -202,7 +198,6 @@ protected:
int _priority = 0;
Queue *_queue = nullptr;
bool _paused = false;
bool _autoLoading = false;
uint8 _cacheTag = 0;
bool _inQueue = false;
@ -287,7 +282,6 @@ private:
void cancelRequests() override;
MTP::DcId dcId() const;
int partSize() const;
RequestData prepareRequest(int offset) const;
void makeRequest(int offset);
@ -373,11 +367,11 @@ protected:
QString _url;
bool _requestSent;
int32 _already;
bool _requestSent = false;
int32 _already = 0;
friend class WebLoadManager;
webFileLoaderPrivate *_private;
webFileLoaderPrivate *_private = nullptr;
};

View File

@ -913,18 +913,15 @@ void Image::automaticLoad(
}
}
void Image::load(Data::FileOrigin origin, bool loadFirst, bool prior) {
void Image::load(Data::FileOrigin origin) {
if (!loaded()) {
_source->load(origin, loadFirst, prior);
_source->load(origin);
}
}
void Image::loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void Image::loadEvenCancelled(Data::FileOrigin origin) {
if (!loaded()) {
_source->loadEvenCancelled(origin, loadFirst, prior);
_source->loadEvenCancelled(origin);
}
}

View File

@ -55,14 +55,8 @@ public:
Source &operator=(Source &&other) = delete;
virtual ~Source() = default;
virtual void load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) = 0;
virtual void loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) = 0;
virtual void load(Data::FileOrigin origin) = 0;
virtual void loadEvenCancelled(Data::FileOrigin origin) = 0;
virtual QImage takeLoaded() = 0;
virtual void unload() = 0;
@ -211,14 +205,8 @@ public:
void setInformation(int size, int width, int height) {
_source->setInformation(size, width, height);
}
void load(
Data::FileOrigin origin,
bool loadFirst = false,
bool prior = true);
void loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst = false,
bool prior = true);
void load(Data::FileOrigin origin);
void loadEvenCancelled(Data::FileOrigin origin);
const StorageImageLocation &location() const {
return _source->location();
}

View File

@ -24,24 +24,18 @@ ImageSource::ImageSource(QImage &&data, const QByteArray &format)
, _height(_data.height()) {
}
void ImageSource::load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void ImageSource::load(Data::FileOrigin origin) {
if (_data.isNull() && !_bytes.isEmpty()) {
_data = App::readImage(_bytes, &_format, false);
}
}
void ImageSource::loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
load(origin, loadFirst, prior);
void ImageSource::loadEvenCancelled(Data::FileOrigin origin) {
load(origin);
}
QImage ImageSource::takeLoaded() {
load({}, false, false);
load({});
return _data;
}
@ -60,8 +54,8 @@ void ImageSource::unload() {
}
void ImageSource::automaticLoad(
Data::FileOrigin origin,
const HistoryItem *item) {
Data::FileOrigin origin,
const HistoryItem *item) {
}
void ImageSource::automaticLoadSettingsChanged() {
@ -156,10 +150,7 @@ LocalFileSource::LocalFileSource(
, _height(_data.height()) {
}
void LocalFileSource::load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void LocalFileSource::load(Data::FileOrigin origin) {
if (!_data.isNull()) {
return;
}
@ -179,11 +170,8 @@ void LocalFileSource::load(
_height = std::max(_data.height(), 1);
}
void LocalFileSource::loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
load(origin, loadFirst, prior);
void LocalFileSource::loadEvenCancelled(Data::FileOrigin origin) {
load(origin);
}
QImage LocalFileSource::takeLoaded() {
@ -195,8 +183,8 @@ void LocalFileSource::unload() {
}
void LocalFileSource::automaticLoad(
Data::FileOrigin origin,
const HistoryItem *item) {
Data::FileOrigin origin,
const HistoryItem *item) {
}
void LocalFileSource::automaticLoadSettingsChanged() {
@ -245,7 +233,7 @@ bool LocalFileSource::isDelayedStorageImage() const {
void LocalFileSource::setImageBytes(const QByteArray &bytes) {
_bytes = bytes;
load({}, false, true);
load({});
}
int LocalFileSource::width() {
@ -273,7 +261,7 @@ void LocalFileSource::setInformation(int size, int width, int height) {
void LocalFileSource::ensureDimensionsKnown() {
if (!_width || !_height) {
load({}, false, false);
load({});
}
}
@ -381,15 +369,12 @@ void RemoteSource::automaticLoadSettingsChanged() {
}
}
void RemoteSource::load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void RemoteSource::load(Data::FileOrigin origin) {
if (!_loader) {
_loader = createLoader(origin, LoadFromCloudOrLocal, false);
}
if (loaderValid()) {
_loader->start(loadFirst, prior);
_loader->start();
}
}
@ -397,14 +382,11 @@ bool RemoteSource::cancelled() const {
return (_loader == CancelledFileLoader);
}
void RemoteSource::loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void RemoteSource::loadEvenCancelled(Data::FileOrigin origin) {
if (cancelled()) {
_loader = nullptr;
}
return load(origin, loadFirst, prior);
return load(origin);
}
bool RemoteSource::displayLoading() {
@ -656,7 +638,7 @@ void DelayedStorageSource::performDelayedLoad(Data::FileOrigin origin) {
return;
}
if (base::take(_loadFromCloud)) {
load(origin, false, true);
load(origin);
} else {
loadLocal();
}
@ -689,23 +671,17 @@ void DelayedStorageSource::automaticLoadSettingsChanged() {
StorageSource::automaticLoadSettingsChanged();
}
void DelayedStorageSource::load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void DelayedStorageSource::load(Data::FileOrigin origin) {
if (_location.valid()) {
StorageSource::load(origin, loadFirst, prior);
StorageSource::load(origin);
} else {
_loadRequested = _loadFromCloud = true;
}
}
void DelayedStorageSource::loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) {
void DelayedStorageSource::loadEvenCancelled(Data::FileOrigin origin) {
_loadCancelled = false;
StorageSource::loadEvenCancelled(origin, loadFirst, prior);
StorageSource::loadEvenCancelled(origin);
}
bool DelayedStorageSource::displayLoading() {

View File

@ -15,14 +15,8 @@ class ImageSource : public Source {
public:
ImageSource(QImage &&data, const QByteArray &format);
void load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void load(Data::FileOrigin origin) override;
void loadEvenCancelled(Data::FileOrigin origin) override;
QImage takeLoaded() override;
void unload() override;
@ -70,14 +64,8 @@ public:
const QByteArray &format = QByteArray(),
QImage &&data = QImage());
void load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void load(Data::FileOrigin origin) override;
void loadEvenCancelled(Data::FileOrigin origin) override;
QImage takeLoaded() override;
void unload() override;
@ -122,14 +110,8 @@ private:
class RemoteSource : public Source {
public:
void load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void load(Data::FileOrigin origin) override;
void loadEvenCancelled(Data::FileOrigin origin) override;
QImage takeLoaded() override;
void unload() override;
@ -263,14 +245,8 @@ public:
DelayedStorageSource();
DelayedStorageSource(int width, int height);
void load(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void loadEvenCancelled(
Data::FileOrigin origin,
bool loadFirst,
bool prior) override;
void load(Data::FileOrigin origin) override;
void loadEvenCancelled(Data::FileOrigin origin) override;
void setDelayedStorageLocation(
const StorageImageLocation &location) override;

View File

@ -691,7 +691,7 @@ void UserpicButton::processPeerPhoto() {
_waiting = !_peer->userpicLoaded();
if (_waiting) {
_peer->loadUserpic(true);
_peer->loadUserpic();
}
if (_role == Role::OpenPhoto) {
if (_peer->userpicPhotoUnknown()) {

View File

@ -666,7 +666,7 @@ void Notification::updateNotifyDisplay() {
p.fillRect(0, st::notifyBorderWidth, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder);
if (!options.hideNameAndPhoto) {
_history->peer->loadUserpic(true, true);
_history->peer->loadUserpic();
_history->peer->paintUserpicLeft(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
} else {
p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), manager()->hiddenUserpicPlaceholder());