From 9f91b3991344184efadec5849989d1bfc061cac7 Mon Sep 17 00:00:00 2001 From: hexian233 Date: Fri, 24 May 2024 11:18:02 +0800 Subject: [PATCH] =?UTF-8?q?read\open=E5=90=8C=E6=AD=A5\=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9Etrace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hexian233 --- bundle.json | 1 + interfaces/kits/js/BUILD.gn | 2 ++ interfaces/kits/js/src/mod_fs/properties/open.cpp | 7 +++++++ .../kits/js/src/mod_fs/properties/prop_n_exporter.cpp | 10 ++++++++++ 4 files changed, 20 insertions(+) diff --git a/bundle.json b/bundle.json index 1b8a8aa05..fc4a384dd 100644 --- a/bundle.json +++ b/bundle.json @@ -36,6 +36,7 @@ "dfs_service", "eventhandler", "hilog", + "hitrace", "ipc", "init", "napi", diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 4d5108164..3c0a5f57d 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -179,6 +179,7 @@ ohos_shared_library("fs") { ] if (!use_mingw_win && !use_mac) { + defines = [ "FILE_API_TRACE" ] branch_protector_ret = "pac_ret" sanitize = { integer_overflow = true @@ -231,6 +232,7 @@ ohos_shared_library("fs") { "data_share:datashare_common", "data_share:datashare_consumer", "dfs_service:distributed_file_daemon_kit_inner", + "hitrace:hitrace_meter", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/interfaces/kits/js/src/mod_fs/properties/open.cpp b/interfaces/kits/js/src/mod_fs/properties/open.cpp index 03d79b174..89f171b43 100644 --- a/interfaces/kits/js/src/mod_fs/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/open.cpp @@ -24,6 +24,7 @@ #include "common_func.h" #include "filemgmt_libhilog.h" #include "file_utils.h" +#include "hitrace_meter.h" #if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) #include "ability.h" #include "ability_manager_client.h" @@ -216,6 +217,9 @@ static tuple OpenFileByUri(const string &path, unsigned int mode) napi_value Open::Sync(napi_env env, napi_callback_info info) { +#ifdef FILE_API_TRACE + HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); +#endif NFuncArg funcArg(env, info); if (!funcArg.InitArgs(NARG_CNT::ONE, NARG_CNT::TWO)) { HILOGE("Number of arguments unmatched"); @@ -286,6 +290,9 @@ static NError AsyncCbExec(shared_ptr arg, const string &path, napi_value Open::Async(napi_env env, napi_callback_info info) { +#ifdef FILE_API_TRACE + HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); +#endif NFuncArg funcArg(env, info); if (!funcArg.InitArgs(NARG_CNT::ONE, NARG_CNT::THREE)) { HILOGE("Number of arguments unmatched"); diff --git a/interfaces/kits/js/src/mod_fs/properties/prop_n_exporter.cpp b/interfaces/kits/js/src/mod_fs/properties/prop_n_exporter.cpp index 35fc82c3c..83ecc80f4 100644 --- a/interfaces/kits/js/src/mod_fs/properties/prop_n_exporter.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/prop_n_exporter.cpp @@ -62,6 +62,10 @@ #include "disconnectdfs.h" #endif +#ifdef FILE_API_TRACE +#include "hitrace_meter.h" +#endif + namespace OHOS { namespace FileManagement { namespace ModuleFileIO { @@ -403,6 +407,9 @@ napi_value PropNExporter::MkdirSync(napi_env env, napi_callback_info info) napi_value PropNExporter::ReadSync(napi_env env, napi_callback_info info) { +#ifdef FILE_API_TRACE + HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); +#endif NFuncArg funcArg(env, info); if (!funcArg.InitArgs(NARG_CNT::TWO, NARG_CNT::THREE)) { @@ -469,6 +476,9 @@ static NError ReadExec(shared_ptr arg, char *buf, size_t len, in napi_value PropNExporter::Read(napi_env env, napi_callback_info info) { +#ifdef FILE_API_TRACE + HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); +#endif NFuncArg funcArg(env, info); if (!funcArg.InitArgs(NARG_CNT::TWO, NARG_CNT::FOUR)) { HILOGE("Number of arguments unmatched"); -- Gitee