!36525 修复图片下载任务被异常remove的问题

Merge pull request !36525 from liyujie/master
This commit is contained in:
openharmony_ci 2024-07-09 17:07:13 +00:00 committed by Gitee
commit ead7ee1f93
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 177 additions and 123 deletions

View File

@ -105,16 +105,24 @@ public:
return true;
}
bool DownloadAsync(DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId) override
bool Download(const std::string& url, const std::shared_ptr<DownloadResult>& result) override
{
return false;
}
bool DownloadSync(DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId) override
bool DownloadAsync(
DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId, int32_t nodeId) override
{
return false;
}
bool RemoveDownloadTask(const std::string& url) override
bool DownloadSync(
DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId, int32_t nodeId) override
{
return false;
}
bool RemoveDownloadTask(const std::string& url, int32_t nodeId) override
{
return false;
}

View File

@ -19,6 +19,7 @@
#include <condition_variable>
#include <cstdint>
#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
@ -39,6 +40,12 @@ struct DownloadCondition {
std::optional<bool> downloadSuccess;
};
struct DownloadResult {
std::string dataOut;
std::string errorMsg;
std::optional<bool> downloadSuccess;
};
class DownloadManager {
public:
static DownloadManager* GetInstance();
@ -46,9 +53,12 @@ public:
virtual ~DownloadManager() = default;
virtual bool Download(const std::string& url, std::vector<uint8_t>& dataOut);
virtual bool DownloadAsync(DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId);
virtual bool DownloadSync(DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId);
virtual bool RemoveDownloadTask(const std::string& url);
virtual bool Download(const std::string& url, const std::shared_ptr<DownloadResult>& result);
virtual bool DownloadAsync(
DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId, int32_t nodeId);
virtual bool DownloadSync(
DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId, int32_t nodeId);
virtual bool RemoveDownloadTask(const std::string& url, int32_t nodeId);
private:
static std::unique_ptr<DownloadManager> instance_;

View File

@ -44,9 +44,9 @@ namespace OHOS::Ace {
namespace {
constexpr int32_t MAXIMUM_WAITING_PERIOD = 2800;
#define PRINT_LOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, 0xD00393A, "DownloadManager", "[%{public}s:%{public}d]" fmt, \
__FUNCTION__, __LINE__, ##__VA_ARGS__)
#define PRINT_LOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, 0xD00393A, "DownloadManager", "[%{public}s:%{public}d]" fmt, __FUNCTION__, \
__LINE__, ##__VA_ARGS__)
#define LOGE(fmt, ...) PRINT_LOG(ERROR, fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) PRINT_LOG(WARN, fmt, ##__VA_ARGS__)
@ -128,10 +128,58 @@ public:
return true;
}
bool DownloadAsync(DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId) override
bool Download(const std::string& url, const std::shared_ptr<DownloadResult>& downloadResult) override
{
NetStackRequest httpReq;
httpReq.SetHeader("Accept", "image/webp,image/apng,*/*");
httpReq.SetHeader("Accept", "image/webp,*/*");
httpReq.SetURL(url);
auto& session = NetStack::HttpClient::HttpSession::GetInstance();
auto task = session.CreateTask(httpReq);
std::shared_ptr<DownloadCondition> downloadCondition = std::make_shared<DownloadCondition>();
task->OnSuccess(
[downloadCondition, downloadResult](const NetStackRequest& request, const NetStackResponse& response) {
{
std::unique_lock<std::mutex> taskLock(downloadCondition->downloadMutex);
downloadResult->downloadSuccess = true;
downloadResult->dataOut = std::move(response.GetResult());
}
downloadCondition->cv.notify_all();
});
task->OnCancel(
[downloadCondition, downloadResult](const NetStackRequest& request, const NetStackResponse& response) {
{
std::unique_lock<std::mutex> taskLock(downloadCondition->downloadMutex);
downloadResult->errorMsg.append("Http task of url ");
downloadResult->errorMsg.append(request.GetURL());
downloadResult->errorMsg.append(" cancelled by netStack");
downloadResult->downloadSuccess = false;
}
downloadCondition->cv.notify_all();
});
task->OnFail([downloadCondition, downloadResult](
const NetStackRequest& request, const NetStackResponse& response, const NetStackError& error) {
{
std::unique_lock<std::mutex> taskLock(downloadCondition->downloadMutex);
downloadResult->errorMsg.append("Http task of url ");
downloadResult->errorMsg.append(request.GetURL());
downloadResult->errorMsg.append(" failed, response code ");
auto responseCode = response.GetResponseCode();
downloadResult->errorMsg.append(std::to_string(responseCode));
downloadResult->errorMsg.append(", msg from netStack: ");
downloadResult->errorMsg.append(error.GetErrorMessage());
downloadResult->downloadSuccess = false;
}
downloadCondition->cv.notify_all();
});
auto result = task->Start();
return HandleDownloadResult(result, downloadCondition, downloadResult);
}
bool DownloadAsync(
DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId, int32_t nodeId) override
{
NetStackRequest httpReq;
httpReq.SetHeader("Accept", "image/webp,*/*");
httpReq.SetURL(url);
auto& session = NetStack::HttpClient::HttpSession::GetInstance();
auto task = session.CreateTask(httpReq);
@ -171,19 +219,19 @@ public:
const NetStackRequest& request, u_long dlTotal, u_long dlNow, u_long ulTotal,
u_long ulNow) { onProgressCallback(dlTotal, dlNow, true, instanceId); });
}
std::scoped_lock lock(httpTaskMutex_);
httpTaskMap_.emplace(url, task);
AddDownloadTask(url, task, nodeId);
auto result = task->Start();
LOGI("download src [%{private}s] [%{public}s]", url.c_str(),
result ? " successfully" : " failed to download, please check netStack log");
return result;
}
bool DownloadSync(DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId) override
bool DownloadSync(
DownloadCallback&& downloadCallback, const std::string& url, int32_t instanceId, int32_t nodeId) override
{
LOGI("DownloadSync task of [%{private}s] start", url.c_str());
NetStackRequest httpReq;
httpReq.SetHeader("Accept", "image/webp,image/apng,*/*");
httpReq.SetHeader("Accept", "image/webp,*/*");
httpReq.SetURL(url);
auto& session = NetStack::HttpClient::HttpSession::GetInstance();
auto task = session.CreateTask(httpReq);
@ -209,17 +257,14 @@ public:
}
downloadCondition->cv.notify_all();
});
task->OnFail([downloadCondition](
const NetStackRequest& request, const NetStackResponse& response, const NetStackError& error) {
OnFail(downloadCondition, request, response, error);
});
task->OnFail([downloadCondition](const NetStackRequest& request, const NetStackResponse& response,
const NetStackError& error) { OnFail(downloadCondition, request, response, error); });
if (downloadCallback.onProgressCallback) {
task->OnProgress([onProgressCallback = downloadCallback.onProgressCallback, instanceId](
const NetStackRequest& request, u_long dlTotal, u_long dlNow, u_long ulTotal,
u_long ulNow) { onProgressCallback(dlTotal, dlNow, false, instanceId); });
}
std::scoped_lock lock(httpTaskMutex_);
httpTaskMap_.emplace(url, task);
AddDownloadTask(url, task, nodeId);
auto result = task->Start();
return HandleDownloadResult(result, std::move(downloadCallback), downloadCondition, instanceId, url);
}
@ -227,8 +272,7 @@ public:
static void OnFail(std::shared_ptr<DownloadCondition> downloadCondition, const NetStackRequest& request,
const NetStackResponse& response, const NetStackError& error)
{
LOGI(
"Sync Http task of url [%{private}s] failed, response code %{public}d, msg from netStack: [%{public}s]",
LOGI("Sync Http task of url [%{private}s] failed, response code %{public}d, msg from netStack: [%{public}s]",
request.GetURL().c_str(), response.GetResponseCode(), error.GetErrorMessage().c_str());
{
std::unique_lock<std::mutex> taskLock(downloadCondition->downloadMutex);
@ -244,17 +288,18 @@ public:
downloadCondition->cv.notify_all();
}
bool RemoveDownloadTask(const std::string& url) override
bool RemoveDownloadTask(const std::string& url, int32_t nodeId) override
{
std::scoped_lock lock(httpTaskMutex_);
auto iter = httpTaskMap_.find(url);
auto urlKey = url + std::to_string(nodeId);
auto iter = httpTaskMap_.find(urlKey);
if (iter != httpTaskMap_.end()) {
auto task = iter->second;
if (task->GetStatus() == NetStackTaskStatus::RUNNING) {
LOGI("AceImage RemoveDownloadTask, url:%{private}s", url.c_str());
task->Cancel();
}
httpTaskMap_.erase(url);
httpTaskMap_.erase(urlKey);
return true;
}
return false;
@ -294,6 +339,29 @@ private:
return true;
}
bool HandleDownloadResult(bool result, const std::shared_ptr<DownloadCondition>& downloadCondition,
const std::shared_ptr<DownloadResult>& downloadResult)
{
if (!result) {
return result;
}
{
std::unique_lock<std::mutex> downloadLock(downloadCondition->downloadMutex);
// condition_variable is waiting for any of the success, cancel or failed to respond in sync mode
downloadCondition->cv.wait_for(
downloadLock, std::chrono::milliseconds(MAXIMUM_WAITING_PERIOD), [downloadCondition, downloadResult] {
return downloadCondition ? downloadResult->downloadSuccess.has_value() : false;
});
}
return true;
}
void AddDownloadTask(const std::string& url, const std::shared_ptr<NetStackTask>& task, int32_t nodeId)
{
std::scoped_lock lock(httpTaskMutex_);
httpTaskMap_.emplace(url + std::to_string(nodeId), task);
}
bool Initialize()
{
if (initialized_) {

View File

@ -99,8 +99,8 @@ void RosenFontLoader::LoadFromNetwork(const RefPtr<PipelineBase>& context)
AceLogTag::ACE_FONT, "Sync Download font Failed,errorMessage is %{public}s", errorMessage.c_str());
};
downloadCallback.cancelCallback = downloadCallback.failCallback;
if (!DownloadManager::GetInstance()->DownloadSync(
std::move(downloadCallback), fontLoader->familySrc_, context->GetInstanceId())) {
if (!DownloadManager::GetInstance()->DownloadSync(std::move(downloadCallback),
fontLoader->familySrc_, context->GetInstanceId(), -1)) {
return;
}
},

View File

@ -72,8 +72,7 @@ RefPtr<ImageData> QueryDataFromCache(const ImageSourceInfo& src, bool& dataHit)
} // namespace
ImageLoadingContext::ImageLoadingContext(const ImageSourceInfo& src, LoadNotifier&& loadNotifier, bool syncLoad)
: src_(src), notifiers_(std::move(loadNotifier)),
containerId_(Container::CurrentId()), syncLoad_(syncLoad)
: src_(src), notifiers_(std::move(loadNotifier)), containerId_(Container::CurrentId()), syncLoad_(syncLoad)
{
stateManager_ = MakeRefPtr<ImageStateManager>(WeakClaim(this));
@ -85,15 +84,14 @@ ImageLoadingContext::ImageLoadingContext(const ImageSourceInfo& src, LoadNotifie
ImageLoadingContext::~ImageLoadingContext()
{
// cancel background task
if (Downloadable()) {
RemoveDownloadTask(src_.GetSrc());
}
if (!syncLoad_) {
auto state = stateManager_->GetCurrentState();
if (state == ImageLoadingState::DATA_LOADING) {
// cancel CreateImgObj task
ImageProvider::CancelTask(src_.GetKey(), WeakClaim(this));
if (Downloadable()) {
DownloadManager::GetInstance()->RemoveDownloadTask(src_.GetSrc(), nodeId_);
}
} else if (state == ImageLoadingState::MAKE_CANVAS_IMAGE) {
// cancel MakeCanvasImage task
if (InstanceOf<StaticImageObject>(imageObj_)) {
@ -169,14 +167,6 @@ void ImageLoadingContext::SetOnProgressCallback(
void ImageLoadingContext::OnDataLoading()
{
if (!src_.GetIsConfigurationChange()) {
if (auto obj = ImageProvider::QueryImageObjectFromCache(src_); obj) {
TAG_LOGD(AceLogTag::ACE_IMAGE, "%{private}s Hit the Cache, not need Create imageObject.",
src_.GetSrc().c_str());
DataReadyCallback(obj);
return;
}
}
if (Downloadable()) {
if (syncLoad_) {
DownloadImage();
@ -191,7 +181,6 @@ void ImageLoadingContext::OnDataLoading()
return;
}
ImageProvider::CreateImageObject(src_, WeakClaim(this), syncLoad_);
src_.SetIsConfigurationChange(false);
}
bool ImageLoadingContext::NotifyReadyIfCacheHit()
@ -260,7 +249,7 @@ void ImageLoadingContext::PerformDownload()
downloadCallback.cancelCallback = downloadCallback.failCallback;
if (onProgressCallback_) {
downloadCallback.onProgressCallback = [weak = AceType::WeakClaim(this)](
uint32_t dlTotal, uint32_t dlNow, bool async, int32_t instanceId) {
uint32_t dlTotal, uint32_t dlNow, bool async, int32_t instanceId) {
ContainerScope scope(instanceId);
auto callback = [weak = weak, dlTotal = dlTotal, dlNow = dlNow]() {
auto ctx = weak.Upgrade();
@ -270,12 +259,7 @@ void ImageLoadingContext::PerformDownload()
async ? NG::ImageUtils::PostToUI(callback, "ArkUIImageDownloadOnProcess") : callback();
};
}
NetworkImageLoader::DownloadImage(std::move(downloadCallback), src_.GetSrc(), syncLoad_);
}
bool ImageLoadingContext::RemoveDownloadTask(const std::string& src)
{
return DownloadManager::GetInstance()->RemoveDownloadTask(src);
NetworkImageLoader::DownloadImage(std::move(downloadCallback), src_.GetSrc(), syncLoad_, nodeId_);
}
void ImageLoadingContext::CacheDownloadedImage()

View File

@ -146,12 +146,16 @@ public:
void OnDataReadyOnCompleteCallBack();
void SetOnProgressCallback(std::function<void(const uint32_t& dlNow, const uint32_t& dlTotal)>&& onProgress);
bool RemoveDownloadTask(const std::string& src);
const std::string& GetErrorMsg()
{
return errorMsg_;
}
void SetNodeId(int32_t nodeId)
{
nodeId_ = nodeId;
}
private:
#define DEFINE_SET_NOTIFY_TASK(loadResult) \
void Set##loadResult##NotifyTask(loadResult##NotifyTask&& loadResult##NotifyTask) \
@ -212,6 +216,7 @@ private:
std::atomic<bool> needDataReadyCallBack_ = false;
// to determine whether the image needs to be reloaded
int32_t sizeLevel_ = -1;
int32_t nodeId_ = -1;
ImageFit imageFit_ = ImageFit::COVER;
std::unique_ptr<SizeF> sourceSizePtr_ = nullptr;

View File

@ -602,6 +602,7 @@ void ImagePattern::LoadImage(
TAG_LOGD(AceLogTag::ACE_IMAGE, "start loading image %{public}s", src.ToString().c_str());
}
loadingCtx_->SetLoadInVipChannel(GetLoadInVipChannel());
loadingCtx_->SetNodeId(GetHost()->GetId());
if (onProgressCallback_) {
loadingCtx_->SetOnProgressCallback(std::move(onProgressCallback_));
}
@ -1406,34 +1407,24 @@ void ImagePattern::OnIconConfigurationUpdate()
OnConfigurationUpdate();
}
void ImagePattern::ClearImageCache()
{
auto pipeline = PipelineContext::GetCurrentContext();
CHECK_NULL_VOID(pipeline);
auto imageCache = pipeline->GetImageCache();
CHECK_NULL_VOID(imageCache);
imageCache->Clear();
}
void ImagePattern::OnConfigurationUpdate()
{
ClearImageCache();
CHECK_NULL_VOID(loadingCtx_);
auto imageLayoutProperty = GetLayoutProperty<ImageLayoutProperty>();
CHECK_NULL_VOID(imageLayoutProperty);
auto src = imageLayoutProperty->GetImageSourceInfo().value_or(ImageSourceInfo(""));
src.GenerateCacheKey();
UpdateInternalResource(src);
src.SetIsConfigurationChange(true);
LoadImage(src, imageLayoutProperty->GetPropertyChangeFlag(),
imageLayoutProperty->GetVisibility().value_or(VisibleType::VISIBLE));
if (loadingCtx_->NeedAlt() && imageLayoutProperty->GetAlt()) {
auto altImageSourceInfo = imageLayoutProperty->GetAlt().value_or(ImageSourceInfo(""));
altImageSourceInfo.GenerateCacheKey();
if (altLoadingCtx_ && altLoadingCtx_->GetSourceInfo() == altImageSourceInfo) {
altLoadingCtx_.Reset();
}
altImageSourceInfo.SetIsConfigurationChange(true);
LoadAltImage(altImageSourceInfo);
}
}

View File

@ -456,7 +456,6 @@ private:
void OnDirectionConfigurationUpdate() override;
void OnIconConfigurationUpdate() override;
void OnConfigurationUpdate();
void ClearImageCache();
void LoadImage(const ImageSourceInfo& src, const PropertyChangeFlag& propertyChangeFlag, VisibleType visibleType);
void LoadAltImage(const ImageSourceInfo& altImageSourceInfo);

View File

@ -230,7 +230,7 @@ void ImageFileCache::WriteCacheFile(
if (iter != fileNameToFileInfoPos_.end()) {
auto infoIter = iter->second;
// either suffix not specified, or fileName ends with the suffix
if (suffix == "" || EndsWith(infoIter->fileName, suffix)) {
if (suffix.empty() || EndsWith(infoIter->fileName, suffix)) {
TAG_LOGI(AceLogTag::ACE_IMAGE, "file has been wrote %{private}s", infoIter->fileName.c_str());
return;
}

View File

@ -16,6 +16,7 @@
#include "core/image/image_loader.h"
#include <condition_variable>
#include <memory>
#include <mutex>
#include <ratio>
#include <regex>
@ -245,16 +246,13 @@ RefPtr<NG::ImageData> ImageLoader::LoadImageDataFromFileCache(const std::string&
RefPtr<NG::ImageData> ImageLoader::GetImageData(const ImageSourceInfo& src, const WeakPtr<PipelineBase>& context)
{
ACE_FUNCTION_TRACE();
bool queryCache = !src.GetIsConfigurationChange();
if (src.IsPixmap()) {
return LoadDecodedImageData(src, context);
}
#ifndef USE_ROSEN_DRAWING
if (queryCache) {
auto cachedData = ImageLoader::QueryImageDataFromImageCache(src);
if (cachedData) {
return NG::ImageData::MakeFromDataWrapper(&cachedData);
}
auto cachedData = ImageLoader::QueryImageDataFromImageCache(src);
if (cachedData) {
return NG::ImageData::MakeFromDataWrapper(&cachedData);
}
auto skData = LoadImageData(src, context);
CHECK_NULL_RETURN(skData, nullptr);
@ -264,11 +262,9 @@ RefPtr<NG::ImageData> ImageLoader::GetImageData(const ImageSourceInfo& src, cons
#else
std::shared_ptr<RSData> rsData = nullptr;
do {
if (queryCache) {
rsData = ImageLoader::QueryImageDataFromImageCache(src);
if (rsData) {
break;
}
rsData = ImageLoader::QueryImageDataFromImageCache(src);
if (rsData) {
break;
}
rsData = LoadImageData(src, context);
CHECK_NULL_RETURN(rsData, nullptr);
@ -279,11 +275,13 @@ RefPtr<NG::ImageData> ImageLoader::GetImageData(const ImageSourceInfo& src, cons
}
// NG ImageLoader entrance
bool NetworkImageLoader::DownloadImage(DownloadCallback&& downloadCallback, const std::string& src, bool sync)
bool NetworkImageLoader::DownloadImage(
DownloadCallback&& downloadCallback, const std::string& src, bool sync, int32_t nodeId)
{
return sync ? DownloadManager::GetInstance()->DownloadSync(std::move(downloadCallback), src, Container::CurrentId())
: DownloadManager::GetInstance()->DownloadAsync(
std::move(downloadCallback), src, Container::CurrentId());
return sync ? DownloadManager::GetInstance()->DownloadSync(std::move(downloadCallback),
src, Container::CurrentId(), nodeId)
: DownloadManager::GetInstance()->DownloadAsync(std::move(downloadCallback),
src, Container::CurrentId(), nodeId);
}
#ifndef USE_ROSEN_DRAWING
@ -351,8 +349,9 @@ std::shared_ptr<RSData> FileImageLoader::LoadImageData(
return rsData->BuildWithCopy(result->data(), result->size()) ? rsData : nullptr;
#else
SkDataWrapper* wrapper = new SkDataWrapper { std::move(result) };
return rsData->BuildWithProc(wrapper->data->data(), wrapper->data->size(),
SkDataWrapperReleaseProc, wrapper) ? rsData : nullptr;
return rsData->BuildWithProc(wrapper->data->data(), wrapper->data->size(), SkDataWrapperReleaseProc, wrapper)
? rsData
: nullptr;
#endif
#endif
}
@ -497,28 +496,24 @@ std::shared_ptr<RSData> NetworkImageLoader::LoadImageData(
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE, "Download network image, uri=%{public}s", uri.c_str());
}
std::string result;
DownloadCallback downloadCallback;
downloadCallback.successCallback = [result](const std::string&& imageData, bool async, int32_t instanceId) mutable {
result = imageData;
};
downloadCallback.failCallback = [](std::string errorMessage, bool async, int32_t instanceId) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "Download network image %{public}s failed!", errorMessage.c_str());
};
downloadCallback.cancelCallback = downloadCallback.failCallback;
if (!DownloadManager::GetInstance()->DownloadSync(std::move(downloadCallback), uri, Container::CurrentId()) ||
result.empty()) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "Download network image %{private}s failed!", uri.c_str());
#ifndef OHOS_PLATFORM
std::vector<uint8_t> imageData;
if (!DownloadManager::GetInstance()->Download(uri, imageData) || imageData.empty()) {
return nullptr;
}
#ifndef USE_ROSEN_DRAWING
sk_sp<SkData> data = SkData::MakeWithCopy(result.data(), result.length());
#else
auto data = std::make_shared<RSData>();
data->BuildWithCopy(result.data(), result.length());
data->BuildWithCopy(imageData.data(), imageData.size());
WriteCacheToFile(uri, imageData);
#else
auto downloadResult = std::make_shared<DownloadResult>();
if (!DownloadManager::GetInstance()->Download(uri, downloadResult)) {
return nullptr;
}
auto data = std::make_shared<RSData>();
data->BuildWithCopy(downloadResult->dataOut.data(), downloadResult->dataOut.size());
WriteCacheToFile(uri, downloadResult->dataOut);
#endif
// 3. write it into file cache.
WriteCacheToFile(uri, result);
return data;
}

View File

@ -145,7 +145,7 @@ public:
std::shared_ptr<RSData> LoadImageData(
const ImageSourceInfo& imageSourceInfo, const WeakPtr<PipelineBase>& context = nullptr) override;
#endif
static bool DownloadImage(DownloadCallback&& downloadCallback, const std::string& src, bool sync);
static bool DownloadImage(DownloadCallback&& downloadCallback, const std::string& src, bool sync, int32_t nodeId);
};
class InternalImageLoader final : public ImageLoader {

View File

@ -78,13 +78,10 @@ public:
{
isUriPureNumber_ = isUriPureNumber;
}
void SetIsConfigurationChange(bool isConfigurationChange)
{
isConfigurationChange_ = isConfigurationChange;
}
void Reset();
// interfaces to get infomation from [ImageSourceInfo]
void GenerateCacheKey();
bool IsInternalResource() const;
bool IsValid() const;
bool IsPng() const;
@ -105,11 +102,6 @@ public:
{
return isUriPureNumber_;
}
bool GetIsConfigurationChange() const
{
return isConfigurationChange_;
}
bool SupportObjCache() const;
void SetNeedCache(bool needCache)
{
@ -132,7 +124,6 @@ public:
private:
SrcType ResolveSrcType() const;
void GenerateCacheKey();
std::string src_;
std::shared_ptr<std::string> srcRef_ = nullptr;
@ -147,7 +138,6 @@ private:
bool isSvg_ = false;
bool isPng_ = false;
bool needCache_ = true;
bool isConfigurationChange_ = false;
bool isUriPureNumber_ = false;
bool isFromReset_ = false;
[[deprecated("in NG")]]

View File

@ -25,17 +25,23 @@ public:
{
return false;
}
bool DownloadAsync(
DownloadCallback&& /* downloadCallback */, const std::string& /* url */, int32_t /* instanceId */) override
bool Download(const std::string& /* url */, const std::shared_ptr<DownloadResult>& /* result */) override
{
return false;
}
bool DownloadSync(
DownloadCallback&& /* downloadCallback */, const std::string& /* url */, int32_t /* instanceId */) override
bool DownloadAsync(DownloadCallback&& /* downloadCallback */, const std::string& /* url */,
int32_t /* instanceId */, int32_t /* nodeId */) override
{
return false;
}
bool RemoveDownloadTask(const std::string& /* url */) override
bool DownloadSync(DownloadCallback&& /* downloadCallback */, const std::string& /* url */, int32_t /* instanceId */,
int32_t /* nodeId */) override
{
return false;
}
bool RemoveDownloadTask(const std::string& /* url */, int32_t /*nodeId*/) override
{
return false;
}

View File

@ -67,7 +67,8 @@ RefPtr<NG::ImageData> ImageLoader::LoadImageDataFromFileCache(const std::string&
return nullptr;
}
bool NetworkImageLoader::DownloadImage(DownloadCallback&& downloadCallback, const std::string& src, bool sync)
bool NetworkImageLoader::DownloadImage(
DownloadCallback&& downloadCallback, const std::string& src, bool sync, int32_t nodeId)
{
return false;
}

View File

@ -171,9 +171,4 @@ void ImageLoadingContext::PerformDownload() {}
void ImageLoadingContext::DownloadImageSuccess(const std::string& imageData) {}
void ImageLoadingContext::DownloadImageFailed(const std::string& errorMessage) {}
bool ImageLoadingContext::RemoveDownloadTask(const std::string& src)
{
return false;
}
} // namespace OHOS::Ace::NG

View File

@ -262,4 +262,6 @@ void ImageSourceInfo::SetModuleName(const std::string& moduleName)
{
moduleName_ = moduleName;
}
void ImageSourceInfo::GenerateCacheKey() {}
} // namespace OHOS::Ace