diff --git a/bundle.json b/bundle.json index 1b8a8aa0588bf5ec0ccd93ddf544a9663b6240ba..fc4a384dd9d34529a865656e7c85274e82979ad4 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 4d51081641898d7d7b92800456991d12f617dfc2..3c0a5f57de9cb59d9c00bc2e9d17debe1efa0ff8 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 03d79b174d0d1b5e76ebc642f6b7f25d900c83c6..89f171b43b3b0b437675f8be82ec0b6bc08caaa7 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 35fc82c3ccebcb3a6f4b42641ecebd1d68f45387..83ecc80f4ed210d3182ac1b01faa4ad1af29b8ef 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");