Descriptions: napi接口和uv_queue接口传入taskName信息

Signed-off-by: zhaoyixin1998 <zhaoyixin5@huawei.com>
This commit is contained in:
zhaoyixin1998
2025-11-25 15:29:04 +08:00
committed by zhaoyixin1998
parent 8f6faf0858
commit 2575dff740
6 changed files with 27 additions and 22 deletions
@@ -57,7 +57,7 @@ struct DisconnectCallback {
napi_get_undefined(env_, &undefined);
napi_call_function(env_, undefined, handler, 0, &jsEvent, &callResult);
};
if (napi_send_event(env_, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env_, task, napi_eprio_high, "NotifyJS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -1099,7 +1099,7 @@ int EnableAbilityListsObserver::OnEnableAbilityListsStateChangedWork(uv_work_t *
HILOG_ERROR("loop or work is nullptr.");
return RET_ERR_FAILED;
}
int ret = uv_queue_work_with_qos(
int ret = uv_queue_work_with_qos_internal(
loop,
work,
[](uv_work_t *work) {},
@@ -1123,7 +1123,8 @@ int EnableAbilityListsObserver::OnEnableAbilityListsStateChangedWork(uv_work_t *
delete work;
work = nullptr;
},
uv_qos_default);
uv_qos_default,
"OnEnableAbilityListsStateChangedWork");
return ret;
}
@@ -143,7 +143,7 @@ void NAccessibilityConfigObserver::NotifyStateChanged2JS(bool enabled)
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyStateChangedJS napi_call_function result[%{public}d]", result);
};
if (napi_send_event(env_, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env_, task, napi_eprio_high, "NotifyStateChanged2JS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -188,7 +188,7 @@ void NAccessibilityConfigObserver::NotifyPropertyChanged2JS(const OHOS::Accessib
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyPropertyChangedJS napi_call_function result[%{public}d]", result);
};
if (napi_send_event(env_, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env_, task, napi_eprio_high, "NotifyPropertyChanged2JS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -230,7 +230,7 @@ void NAccessibilityConfigObserver::NotifyStringChanged2JS(const std::string& val
napi_get_value_string_utf8(callbackInfo->env_, callResult, buf, BUF_SIZE, &result);
HILOG_INFO("NotifyStringChanged2JSInner napi_call_function result[%{public}zu]", result);
};
if (napi_send_event(env_, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env_, task, napi_eprio_high, "NotifyStringChanged2JS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -273,7 +273,7 @@ void NAccessibilityConfigObserver::NotifyStringVectorChanged2JS(std::vector<std:
napi_get_value_string_utf8(callbackInfo->env_, callResult, buf, BUF_SIZE, &result);
HILOG_DEBUG("NotifyStringVectorChanged napi_call_function result[%{public}zu]", result);
};
if (napi_send_event(env_, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env_, task, napi_eprio_high, "NotifyStringVectorChanged2JS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -313,7 +313,7 @@ void NAccessibilityConfigObserver::NotifyIntChanged2JS(int32_t value)
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyIntChanged2JSInner napi_call_function result[%{public}d]", result);
};
if (napi_send_event(env_, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env_, task, napi_eprio_high, "NotifyIntChanged2JS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -353,7 +353,7 @@ void NAccessibilityConfigObserver::NotifyUintChanged2JS(uint32_t value)
napi_get_value_uint32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyUintChanged2JSInner napi_call_function result[%{public}d]", result);
};
if (napi_send_event(env_, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env_, task, napi_eprio_high, "NotifyUintChanged2JS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -392,7 +392,7 @@ void NAccessibilityConfigObserver::NotifyFloatChanged2JS(float value)
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
};
if (napi_send_event(env_, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env_, task, napi_eprio_high, "NotifyFloatChanged2JS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -194,7 +194,7 @@ void NAccessibilityExtension::OnAbilityConnected()
}
work->data = static_cast<void*>(callbackInfo);
int ret = uv_queue_work_with_qos(
int ret = uv_queue_work_with_qos_internal(
loop,
work,
[](uv_work_t *work) {},
@@ -207,7 +207,8 @@ void NAccessibilityExtension::OnAbilityConnected()
delete work;
work = nullptr;
},
uv_qos_user_initiated);
uv_qos_user_initiated,
"OnAbilityConnected");
if (ret) {
HILOG_ERROR("Failed to execute OnAbilityConnected work queue");
delete callbackInfo;
@@ -246,7 +247,7 @@ void NAccessibilityExtension::OnAbilityDisconnected()
work->data = static_cast<void*>(callbackInfo);
ffrt::future syncFuture = callbackInfo->syncPromise_.get_future();
int ret = uv_queue_work_with_qos(
int ret = uv_queue_work_with_qos_internal(
loop,
work,
[](uv_work_t *work) {},
@@ -260,7 +261,8 @@ void NAccessibilityExtension::OnAbilityDisconnected()
delete work;
work = nullptr;
},
uv_qos_user_initiated);
uv_qos_user_initiated,
"OnAbilityDisconnected");
if (ret) {
HILOG_ERROR("Failed to execute OnAbilityDisconnected work queue");
callbackInfo->syncPromise_.set_value();
@@ -433,7 +435,7 @@ int NAccessibilityExtension::OnAccessibilityEventExec(uv_work_t *work, uv_loop_t
if (loop == nullptr || work == nullptr) {
return RET_ERR_FAILED;
}
int ret = uv_queue_work_with_qos(
int ret = uv_queue_work_with_qos_internal(
loop,
work,
[](uv_work_t *work) {},
@@ -500,7 +502,8 @@ int NAccessibilityExtension::OnAccessibilityEventExec(uv_work_t *work, uv_loop_t
work = nullptr;
}
},
uv_qos_user_initiated);
uv_qos_user_initiated,
"OnAccessibilityEventExec");
return ret;
}
@@ -554,7 +557,7 @@ int NAccessibilityExtension::OnKeyPressEventExec(uv_work_t *work, uv_loop_t *loo
HILOG_ERROR("loop or work is nullptr.");
return RET_ERR_FAILED;
}
int ret = uv_queue_work_with_qos(
int ret = uv_queue_work_with_qos_internal(
loop,
work,
[](uv_work_t *work) {},
@@ -596,7 +599,8 @@ int NAccessibilityExtension::OnKeyPressEventExec(uv_work_t *work, uv_loop_t *loo
DeleteAndNullify(data);
DeleteAndNullify(work);
},
uv_qos_user_initiated);
uv_qos_user_initiated,
"OnKeyPressEventExec");
return ret;
}
@@ -839,7 +839,7 @@ private:
}
};
// NAccessibilityExtensionContext::OnStartAbility
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) {
if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high, "OnStartAbility")) {
napiAsyncTask->Reject(env, CreateJsError(env,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY),
ERROR_MESSAGE_SYSTEM_ABNORMALITY));
@@ -886,7 +886,7 @@ void StateListener::NotifyJS(napi_env env, bool state, napi_ref handlerRef)
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
};
if (napi_send_event(env, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env, task, napi_eprio_high, "NotifyJS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -923,7 +923,7 @@ void StateListener::NotifyJS(napi_env env, std::string mode, napi_ref handlerRef
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
};
if (napi_send_event(env, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env, task, napi_eprio_high, "NotifyJS") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}
@@ -1549,7 +1549,7 @@ void StateListenerImpl::DeleteObserverReference(napi_env env, std::shared_ptr<St
OHOS::Accessibility::TmpOpenScope(callbackInfo->env_), closeScope);
napi_delete_reference(tmpEnv, callbackInfo->ref_);
};
if (napi_send_event(env, task, napi_eprio_high) != napi_status::napi_ok) {
if (napi_send_event(env, task, napi_eprio_high, "DeleteObserverReference") != napi_status::napi_ok) {
HILOG_ERROR("failed to send event");
}
}