mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 09:12:41 +00:00
!31654 PostTask新增TaskName代码优化
Merge pull request !31654 from xieqiqi/master
This commit is contained in:
commit
c6c2384be1
@ -420,7 +420,7 @@ void AceAbility::OnStart(const Want& want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
[taskExecutor = Platform::AceContainer::GetContainer(id)->GetTaskExecutor(), id](
|
||||
const std::function<void()>& task) {
|
||||
ContainerScope scope(id);
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIAbilityInitRosenBackend");
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIRenderServiceTask");
|
||||
}, id);
|
||||
if (context != nullptr) {
|
||||
context->SetRSUIDirector(rsUiDirector);
|
||||
|
@ -409,7 +409,7 @@ bool JsiPaEngine::Initialize(BackendType type, SrcLanguage language)
|
||||
return;
|
||||
}
|
||||
paEngine->InitializeInner(type, language);
|
||||
}, "ArkUIPaEngineInit");
|
||||
}, "ArkUIPaEngineInit");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1546,7 +1546,7 @@ UIContentErrorCode UIContentImpl::CommonInitialize(
|
||||
rsUiDirector->SetUITaskRunner(
|
||||
[taskExecutor = container->GetTaskExecutor(), id](const std::function<void()>& task) {
|
||||
ContainerScope scope(id);
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIGetPipelineContext");
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIRenderServiceTask");
|
||||
}, id);
|
||||
auto context = AceType::DynamicCast<PipelineContext>(container->GetPipelineContext());
|
||||
if (context != nullptr) {
|
||||
|
@ -27,7 +27,7 @@ void AnrThread::Start() {}
|
||||
|
||||
void AnrThread::Stop() {}
|
||||
|
||||
bool AnrThread::PostTaskToTaskRunner(Task&& task, uint32_t delayTime, const std::string name)
|
||||
bool AnrThread::PostTaskToTaskRunner(Task&& task, uint32_t delayTime, const std::string& name)
|
||||
{
|
||||
CHECK_NULL_RETURN(task, false);
|
||||
if (delayTime > 0) {
|
||||
|
@ -230,7 +230,7 @@ void AceAbility::InitEnv()
|
||||
auto func = [taskExecutor = container->GetTaskExecutor(), id](const std::function<void()>& task) {
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
ContainerScope scope(id);
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIInitEnv");
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIRenderServiceTask");
|
||||
};
|
||||
director->SetUITaskRunner(func, id);
|
||||
director->Init();
|
||||
|
@ -314,7 +314,7 @@ UIContentErrorCode UIContentImpl::CommonInitialize(OHOS::Rosen::Window* window,
|
||||
auto func = [taskExecutor = container->GetTaskExecutor(), id](const std::function<void()>& task) {
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
ContainerScope scope(id);
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIGetContainerInstanceInitialize");
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIRenderServiceTask");
|
||||
};
|
||||
director->SetUITaskRunner(func, id);
|
||||
director->Init();
|
||||
|
@ -1083,7 +1083,7 @@ void JsiDeclarativeEngine::SetPostTask(NativeEngine* nativeEngine)
|
||||
}
|
||||
ContainerScope scope(id);
|
||||
nativeEngine->Loop(LOOP_NOWAIT, needSync);
|
||||
}, "ArkUISetNativeEngineLoop");
|
||||
}, "ArkUISetNativeEngineLoop");
|
||||
};
|
||||
nativeEngine_->SetPostTask(postTask);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ void AnrThread::Stop()
|
||||
g_anrThread.Reset();
|
||||
}
|
||||
|
||||
bool AnrThread::PostTaskToTaskRunner(Task&& task, uint32_t delayTime, const std::string name)
|
||||
bool AnrThread::PostTaskToTaskRunner(Task&& task, uint32_t delayTime, const std::string& name)
|
||||
{
|
||||
if (!g_anrThread || !task) {
|
||||
return false;
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS::Ace {
|
||||
class AnrThread {
|
||||
@ -26,7 +27,7 @@ public:
|
||||
static void Start();
|
||||
static void Stop();
|
||||
using Task = std::function<void()>;
|
||||
static bool PostTaskToTaskRunner(Task&& task, uint32_t delayTime, const std::string name);
|
||||
static bool PostTaskToTaskRunner(Task&& task, uint32_t delayTime, const std::string& name);
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
#endif
|
||||
|
@ -426,7 +426,7 @@ void CameraElement::CreateTexture()
|
||||
if (cameraElement) {
|
||||
cameraElement->OnError(errorcode, errormsg);
|
||||
}
|
||||
}, "ArkUICameraErrorCallback");
|
||||
}, "ArkUICameraErrorCallback");
|
||||
};
|
||||
texture_ = AceType::MakeRefPtr<Texture>(context_, errorCallback);
|
||||
|
||||
|
@ -114,8 +114,7 @@ bool OnJsCommonDialog(
|
||||
if (delegate) {
|
||||
jsResult = delegate->OnCommonDialog(param, dialogEventType);
|
||||
}
|
||||
},
|
||||
OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebClientCommonDialogEvent");
|
||||
}, OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebClientCommonDialogEvent");
|
||||
return jsResult;
|
||||
}
|
||||
|
||||
@ -185,8 +184,7 @@ bool WebClientImpl::OnConsoleLog(const std::shared_ptr<OHOS::NWeb::NWebConsoleLo
|
||||
if (delegate) {
|
||||
jsMessage = delegate->OnConsoleLog(message);
|
||||
}
|
||||
},
|
||||
OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebConsoleLog");
|
||||
}, OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebConsoleLog");
|
||||
|
||||
return jsMessage;
|
||||
}
|
||||
@ -311,8 +309,7 @@ void WebClientImpl::OnHttpError(std::shared_ptr<OHOS::NWeb::NWebUrlResourceReque
|
||||
if (delegate) {
|
||||
delegate->OnHttpErrorReceive(request, response);
|
||||
}
|
||||
},
|
||||
OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebHttpError");
|
||||
}, OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebHttpError");
|
||||
}
|
||||
|
||||
void WebClientImpl::OnMessage(const std::string& param)
|
||||
@ -367,7 +364,8 @@ bool WebClientImpl::OnHandleInterceptRequest(std::shared_ptr<OHOS::NWeb::NWebUrl
|
||||
if (task == nullptr) {
|
||||
return false;
|
||||
}
|
||||
task->PostSyncTask([&delegate, &webResponse, ¶m] {
|
||||
task->PostSyncTask(
|
||||
[&delegate, &webResponse, ¶m] {
|
||||
webResponse = delegate->OnInterceptRequest(param);
|
||||
}, OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebInterceptRequest");
|
||||
if (webResponse == nullptr) {
|
||||
@ -469,8 +467,7 @@ bool WebClientImpl::OnFileSelectorShow(
|
||||
if (delegate) {
|
||||
jsResult = delegate->OnFileSelectorShow(param);
|
||||
}
|
||||
},
|
||||
OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebFileSelectorShow");
|
||||
}, OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebFileSelectorShow");
|
||||
return jsResult;
|
||||
}
|
||||
|
||||
@ -491,8 +488,7 @@ void WebClientImpl::OnResource(const std::string& url)
|
||||
if (delegate) {
|
||||
delegate->OnResourceLoad(url);
|
||||
}
|
||||
},
|
||||
OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebResourceLoad");
|
||||
}, OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebResourceLoad");
|
||||
}
|
||||
|
||||
void WebClientImpl::OnScaleChanged(float oldScaleFactor, float newScaleFactor)
|
||||
@ -526,7 +522,8 @@ bool WebClientImpl::OnHttpAuthRequestByJS(std::shared_ptr<NWeb::NWebJSHttpAuthRe
|
||||
if (task == nullptr) {
|
||||
return false;
|
||||
}
|
||||
task->PostSyncTask([webClient = this, ¶m, &jsResult] {
|
||||
task->PostSyncTask(
|
||||
[webClient = this, ¶m, &jsResult] {
|
||||
if (!webClient) {
|
||||
return;
|
||||
}
|
||||
@ -549,7 +546,8 @@ bool WebClientImpl::OnSslErrorRequestByJS(std::shared_ptr<NWeb::NWebJSSslErrorRe
|
||||
if (task == nullptr) {
|
||||
return false;
|
||||
}
|
||||
task->PostSyncTask([webClient = this, ¶m, &jsResult] {
|
||||
task->PostSyncTask(
|
||||
[webClient = this, ¶m, &jsResult] {
|
||||
if (!webClient) {
|
||||
return;
|
||||
}
|
||||
@ -578,7 +576,8 @@ bool WebClientImpl::OnAllSslErrorRequestByJS(std::shared_ptr<NWeb::NWebJSAllSslE
|
||||
if (task == nullptr) {
|
||||
return false;
|
||||
}
|
||||
task->PostSyncTask([webClient = this, ¶m, &jsResult] {
|
||||
task->PostSyncTask(
|
||||
[webClient = this, ¶m, &jsResult] {
|
||||
if (!webClient) {
|
||||
return;
|
||||
}
|
||||
@ -607,7 +606,8 @@ bool WebClientImpl::OnSslSelectCertRequestByJS(
|
||||
return false;
|
||||
}
|
||||
|
||||
task->PostSyncTask([webClient = this, ¶m, &jsResult] {
|
||||
task->PostSyncTask(
|
||||
[webClient = this, ¶m, &jsResult] {
|
||||
if (!webClient) {
|
||||
return;
|
||||
}
|
||||
@ -656,8 +656,7 @@ bool WebClientImpl::RunContextMenu(
|
||||
if (delegate) {
|
||||
jsResult = delegate->OnContextMenuShow(param);
|
||||
}
|
||||
},
|
||||
OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebRunContextMenu");
|
||||
}, OHOS::Ace::TaskExecutor::TaskType::JS, "ArkUIWebRunContextMenu");
|
||||
return jsResult;
|
||||
}
|
||||
|
||||
|
@ -1597,7 +1597,7 @@ void WebDelegate::CreatePluginResource(
|
||||
webDelegate->BindRouterBackMethod();
|
||||
webDelegate->BindPopPageSuccessMethod();
|
||||
webDelegate->BindIsPagePathInvalidMethod();
|
||||
}, "ArkUIWebCreatePluginResource");
|
||||
}, "ArkUIWebCreatePluginResource");
|
||||
}
|
||||
|
||||
void WebDelegate::InitWebEvent()
|
||||
@ -2126,7 +2126,7 @@ void WebDelegate::SetWebCallBack()
|
||||
if (delegate) {
|
||||
delegate->Backward();
|
||||
}
|
||||
}, "ArkUIWebBackward");
|
||||
}, "ArkUIWebBackward");
|
||||
});
|
||||
webController->SetForwardImpl([weak = WeakClaim(this), uiTaskExecutor]() {
|
||||
uiTaskExecutor.PostTask([weak]() {
|
||||
@ -6383,7 +6383,7 @@ bool WebDelegate::OnHandleOverrideLoading(std::shared_ptr<OHOS::NWeb::NWebUrlRes
|
||||
auto webCom = delegate->webComponent_.Upgrade();
|
||||
CHECK_NULL_VOID(webCom);
|
||||
result = webCom->OnOverrideUrlLoading(param.get());
|
||||
}, "ArkUIWebHandleOverrideLoading");
|
||||
}, "ArkUIWebHandleOverrideLoading");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -586,7 +586,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co
|
||||
CHECK_NULL_VOID(gestureHub);
|
||||
gestureHub->SetPixelMap(customPixelMap);
|
||||
gestureHub->SetDragPreviewPixelMap(customPixelMap);
|
||||
}, TaskExecutor::TaskType::UI, "ArkUIDragSetPixelMap");
|
||||
}, TaskExecutor::TaskType::UI, "ArkUIDragSetPixelMap");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1042,7 +1042,7 @@ int32_t GestureEventHub::RegisterCoordinationListener(const RefPtr<PipelineBase>
|
||||
CHECK_NULL_VOID(taskScheduler);
|
||||
taskScheduler->PostTask([dragDropManager]() {
|
||||
dragDropManager->HideDragPreviewOverlay();
|
||||
}, TaskExecutor::TaskType::UI, "ArkUIGestureHideDragPreviewOverlay");
|
||||
}, TaskExecutor::TaskType::UI, "ArkUIGestureHideDragPreviewOverlay");
|
||||
};
|
||||
return InteractionInterface::GetInstance()->RegisterCoordinationListener(callback);
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ namespace OHOS::Ace::NG {
|
||||
class ImageUtils {
|
||||
public:
|
||||
static void PostToUI(
|
||||
std::function<void()> &&task, const std::string& name, const int32_t containerId = Container::CurrentId());
|
||||
std::function<void()>&& task, const std::string& name, const int32_t containerId = Container::CurrentId());
|
||||
static void PostToBg(
|
||||
std::function<void()> &&task, const std::string& name, const int32_t containerId = Container::CurrentId());
|
||||
std::function<void()>&& task, const std::string& name, const int32_t containerId = Container::CurrentId());
|
||||
|
||||
inline static std::string GenerateImageKey(const ImageSourceInfo& src, const NG::SizeF& targetSize)
|
||||
{
|
||||
|
@ -248,8 +248,7 @@ void SystemWindowScene::RegisterFocusCallback()
|
||||
CHECK_NULL_VOID(self);
|
||||
CHECK_NULL_VOID(self->GetSession());
|
||||
pipeline->RestoreDefault(self->GetSession()->GetPersistentId());
|
||||
},
|
||||
"ArkUIWindowUnfocus", TaskExecutor::TaskType::UI);
|
||||
}, "ArkUIWindowUnfocus", TaskExecutor::TaskType::UI);
|
||||
};
|
||||
session_->SetNotifyUILostFocusFunc(lostFocusCallback);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ FormRenderWindow::FormRenderWindow(RefPtr<TaskExecutor> taskExecutor, int32_t id
|
||||
rsUIDirector_->SetUITaskRunner([taskExecutor, id = id_](const std::function<void()>& task) {
|
||||
ContainerScope scope(id);
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIFormRenderWindowTask");
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIFormRenderServiceTask");
|
||||
}, id);
|
||||
#else
|
||||
taskExecutor_ = nullptr;
|
||||
|
@ -89,7 +89,7 @@ RosenWindow::RosenWindow(const OHOS::sptr<OHOS::Rosen::Window>& window, RefPtr<T
|
||||
rsUIDirector_->SetUITaskRunner([taskExecutor, id](const std::function<void()>& task) {
|
||||
ContainerScope scope(id);
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIRosenWindowTask");
|
||||
taskExecutor->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIRosenWindowRenderServiceTask");
|
||||
}, id);
|
||||
rsUIDirector_->SetRequestVsyncCallback([weak = weak_from_this()]() {
|
||||
auto self = weak.lock();
|
||||
|
@ -882,8 +882,7 @@ bool PipelineBase::MaybeRelease()
|
||||
} else {
|
||||
std::lock_guard lock(destructMutex_);
|
||||
LOGI("Post Destroy Pipeline Task to UI thread.");
|
||||
return !taskExecutor_->PostTask([this] { delete this; }, TaskExecutor::TaskType::UI,
|
||||
"ArkUIDestroyPipeline");
|
||||
return !taskExecutor_->PostTask([this] { delete this; }, TaskExecutor::TaskType::UI, "ArkUIDestroyPipeline");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user