Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
ce876990
C
communication_ipc
项目概览
OpenHarmony
/
communication_ipc
大约 1 年 前同步成功
通知
20
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
communication_ipc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ce876990
编写于
6月 19, 2023
作者:
马
马根堂
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
NAPIRemoteObject内存泄露修改
Signed-off-by:
N
马根堂
<
magentang4@huawei.com
>
上级
4a82acc0
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
42 addition
and
38 deletion
+42
-38
ipc/native/src/core/source/ipc_object_proxy.cpp
ipc/native/src/core/source/ipc_object_proxy.cpp
+3
-0
ipc/native/src/core/source/ipc_object_stub.cpp
ipc/native/src/core/source/ipc_object_stub.cpp
+2
-2
ipc/native/src/napi_common/include/napi_remote_object_holder.h
...ative/src/napi_common/include/napi_remote_object_holder.h
+6
-5
ipc/native/src/napi_common/include/napi_remote_object_internal.h
...ive/src/napi_common/include/napi_remote_object_internal.h
+2
-1
ipc/native/src/napi_common/source/napi_remote_object.cpp
ipc/native/src/napi_common/source/napi_remote_object.cpp
+16
-24
ipc/native/src/napi_common/source/napi_remote_object_holder.cpp
...tive/src/napi_common/source/napi_remote_object_holder.cpp
+13
-6
未找到文件。
ipc/native/src/core/source/ipc_object_proxy.cpp
浏览文件 @
ce876990
...
@@ -530,6 +530,9 @@ int IPCObjectProxy::GetProtoInfo()
...
@@ -530,6 +530,9 @@ int IPCObjectProxy::GetProtoInfo()
switch
(
reply
.
ReadUint32
())
{
switch
(
reply
.
ReadUint32
())
{
case
IRemoteObject
::
IF_PROT_BINDER
:
{
case
IRemoteObject
::
IF_PROT_BINDER
:
{
remoteDescriptor_
=
reply
.
ReadString16
();
ZLOGD
(
LABEL
,
"it is normal binder, handle:%{public}u desc:%{public}s"
,
handle_
,
Str16ToStr8
(
remoteDescriptor_
).
c_str
());
break
;
break
;
}
}
case
IRemoteObject
::
IF_PROT_DATABUS
:
{
case
IRemoteObject
::
IF_PROT_DATABUS
:
{
...
...
ipc/native/src/core/source/ipc_object_stub.cpp
浏览文件 @
ce876990
...
@@ -371,8 +371,8 @@ int IPCObjectStub::GetObjectType() const
...
@@ -371,8 +371,8 @@ int IPCObjectStub::GetObjectType() const
int32_t
IPCObjectStub
::
ProcessProto
(
uint32_t
code
,
MessageParcel
&
data
,
MessageParcel
&
reply
,
MessageOption
&
option
)
int32_t
IPCObjectStub
::
ProcessProto
(
uint32_t
code
,
MessageParcel
&
data
,
MessageParcel
&
reply
,
MessageOption
&
option
)
{
{
int
result
=
ERR_NONE
;
int
result
=
ERR_NONE
;
ZLOGD
(
LABEL
,
"IPCObjectStub::ProcessProto called, type = 0, normal stub object
"
);
ZLOGD
(
LABEL
,
"IPCObjectStub::ProcessProto called, type = 0, normal stub object
,descriptor_=%{public}s"
,
Str16ToStr8
(
descriptor_
).
c_str
()
);
if
(
!
reply
.
WriteUint32
(
IRemoteObject
::
IF_PROT_BINDER
))
{
if
(
!
reply
.
WriteUint32
(
IRemoteObject
::
IF_PROT_BINDER
)
||
!
reply
.
WriteString16
(
descriptor_
)
)
{
ZLOGE
(
LABEL
,
"write to parcel fail"
);
ZLOGE
(
LABEL
,
"write to parcel fail"
);
result
=
IPC_STUB_WRITE_PARCEL_ERR
;
result
=
IPC_STUB_WRITE_PARCEL_ERR
;
}
}
...
...
ipc/native/src/napi_common/include/napi_remote_object_holder.h
浏览文件 @
ce876990
...
@@ -26,13 +26,13 @@
...
@@ -26,13 +26,13 @@
namespace
OHOS
{
namespace
OHOS
{
class
NAPIRemoteObjectHolder
:
public
RefBase
{
class
NAPIRemoteObjectHolder
:
public
RefBase
{
public:
public:
explicit
NAPIRemoteObjectHolder
(
napi_env
env
,
const
std
::
u16string
&
descriptor
);
explicit
NAPIRemoteObjectHolder
(
napi_env
env
,
const
std
::
u16string
&
descriptor
,
napi_value
thisVar
);
~
NAPIRemoteObjectHolder
();
~
NAPIRemoteObjectHolder
();
sptr
<
NAPIRemoteObject
>
Get
(
napi_value
object
);
sptr
<
NAPIRemoteObject
>
Get
();
void
Set
(
sptr
<
NAPIRemoteObject
>
object
);
void
Set
(
sptr
<
NAPIRemoteObject
>
object
);
void
attachLocalInterface
(
napi_value
localInterface
,
std
::
string
&
descriptor
);
void
attachLocalInterface
(
napi_value
localInterface
,
std
::
string
&
descriptor
);
napi_value
queryLocalInterface
(
std
::
string
&
descriptor
);
napi_value
queryLocalInterface
(
std
::
string
&
descriptor
);
/*
void Lock()
void
Lock
()
{
{
mutex_
.
lock
();
mutex_
.
lock
();
};
};
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
std
::
u16string
GetDescriptor
()
std
::
u16string
GetDescriptor
()
{
{
return
descriptor_
;
return
descriptor_
;
};
*/
};
private:
private:
std
::
mutex
mutex_
;
std
::
mutex
mutex_
;
...
@@ -67,7 +67,8 @@ private:
...
@@ -67,7 +67,8 @@ private:
sptr
<
NAPIRemoteObject
>
sptrCachedObject_
;
sptr
<
NAPIRemoteObject
>
sptrCachedObject_
;
wptr
<
NAPIRemoteObject
>
wptrCachedObject_
;
wptr
<
NAPIRemoteObject
>
wptrCachedObject_
;
napi_ref
localInterfaceRef_
;
napi_ref
localInterfaceRef_
;
//int32_t attachCount_;
int32_t
attachCount_
;
napi_ref
jsObjectRef_
=
nullptr
;
};
};
}
// namespace OHOS
}
// namespace OHOS
#endif // NAPI_REMOTE_OBJECT_HOLDER_H
#endif // NAPI_REMOTE_OBJECT_HOLDER_H
\ No newline at end of file
ipc/native/src/napi_common/include/napi_remote_object_internal.h
浏览文件 @
ce876990
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
namespace
OHOS
{
namespace
OHOS
{
class
NAPIRemoteObject
:
public
IPCObjectStub
{
class
NAPIRemoteObject
:
public
IPCObjectStub
{
public:
public:
NAPIRemoteObject
(
napi_env
env
,
napi_
value
thisVar
,
const
std
::
u16string
&
descriptor
);
NAPIRemoteObject
(
napi_env
env
,
napi_
ref
jsObjectRef
,
const
std
::
u16string
&
descriptor
);
~
NAPIRemoteObject
()
override
;
~
NAPIRemoteObject
()
override
;
...
@@ -38,6 +38,7 @@ public:
...
@@ -38,6 +38,7 @@ public:
napi_ref
GetJsObjectRef
()
const
;
napi_ref
GetJsObjectRef
()
const
;
private:
private:
std
::
u16string
desc_
;
napi_env
env_
=
nullptr
;
napi_env
env_
=
nullptr
;
napi_value
thisVar_
=
nullptr
;
napi_value
thisVar_
=
nullptr
;
static
napi_value
ThenCallback
(
napi_env
env
,
napi_callback_info
info
);
static
napi_value
ThenCallback
(
napi_env
env
,
napi_callback_info
info
);
...
...
ipc/native/src/napi_common/source/napi_remote_object.cpp
浏览文件 @
ce876990
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#include "napi_rpc_error.h"
#include "napi_rpc_error.h"
#include "napi/native_api.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
#include "napi/native_node_api.h"
//
#include "native_engine/native_value.h"
#include "native_engine/native_value.h"
namespace
OHOS
{
namespace
OHOS
{
static
constexpr
OHOS
::
HiviewDFX
::
HiLogLabel
LOG_LABEL
=
{
LOG_CORE
,
LOG_ID_IPC
,
"napi_remoteObject"
};
static
constexpr
OHOS
::
HiviewDFX
::
HiLogLabel
LOG_LABEL
=
{
LOG_CORE
,
LOG_ID_IPC
,
"napi_remoteObject"
};
...
@@ -45,7 +45,7 @@ static const uint64_t HITRACE_TAG_RPC = (1ULL << 46); // RPC and IPC tag.
...
@@ -45,7 +45,7 @@ static const uint64_t HITRACE_TAG_RPC = (1ULL << 46); // RPC and IPC tag.
static
std
::
atomic
<
int32_t
>
bytraceId
=
1000
;
static
std
::
atomic
<
int32_t
>
bytraceId
=
1000
;
static
NapiError
napiErr
;
static
NapiError
napiErr
;
/*
template<class T>
template
<
class
T
>
inline
T
*
ConvertNativeValueTo
(
NativeValue
*
value
)
inline
T
*
ConvertNativeValueTo
(
NativeValue
*
value
)
{
{
return
(
value
!=
nullptr
)
?
static_cast
<
T
*>
(
value
->
GetInterface
(
T
::
INTERFACE_ID
))
:
nullptr
;
return
(
value
!=
nullptr
)
?
static_cast
<
T
*>
(
value
->
GetInterface
(
T
::
INTERFACE_ID
))
:
nullptr
;
...
@@ -60,6 +60,7 @@ static void RemoteObjectHolderFinalizeCb(napi_env env, void *data, void *hint)
...
@@ -60,6 +60,7 @@ static void RemoteObjectHolderFinalizeCb(napi_env env, void *data, void *hint)
}
}
holder
->
Lock
();
holder
->
Lock
();
int32_t
curAttachCount
=
holder
->
DecAttachCount
();
int32_t
curAttachCount
=
holder
->
DecAttachCount
();
ZLOGW
(
LOG_LABEL
,
"NAPIRemoteObjectHolder destructed by js callback, curAttachCount:%{public}d"
,
curAttachCount
);
if
(
curAttachCount
==
0
)
{
if
(
curAttachCount
==
0
)
{
delete
holder
;
delete
holder
;
}
}
...
@@ -111,7 +112,7 @@ static NativeValue *RemoteObjectAttachCb(NativeEngine *engine, void *value, void
...
@@ -111,7 +112,7 @@ static NativeValue *RemoteObjectAttachCb(NativeEngine *engine, void *value, void
holder
->
IncAttachCount
();
holder
->
IncAttachCount
();
holder
->
Unlock
();
holder
->
Unlock
();
return
reinterpret_cast
<
NativeValue
*>
(
jsRemoteObject
);
return
reinterpret_cast
<
NativeValue
*>
(
jsRemoteObject
);
}
*/
}
napi_value
RemoteObject_JS_Constructor
(
napi_env
env
,
napi_callback_info
info
)
napi_value
RemoteObject_JS_Constructor
(
napi_env
env
,
napi_callback_info
info
)
{
{
...
@@ -134,35 +135,28 @@ napi_value RemoteObject_JS_Constructor(napi_env env, napi_callback_info info)
...
@@ -134,35 +135,28 @@ napi_value RemoteObject_JS_Constructor(napi_env env, napi_callback_info info)
napi_get_value_string_utf8
(
env
,
argv
[
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
napi_get_value_string_utf8
(
env
,
argv
[
0
],
stringValue
,
bufferSize
+
1
,
&
jsStringLength
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
NAPI_ASSERT
(
env
,
jsStringLength
==
bufferSize
,
"string length wrong"
);
std
::
string
descriptor
=
stringValue
;
std
::
string
descriptor
=
stringValue
;
auto
holder
=
new
NAPIRemoteObjectHolder
(
env
,
Str8ToStr16
(
descriptor
));
auto
holder
=
new
NAPIRemoteObjectHolder
(
env
,
Str8ToStr16
(
descriptor
)
,
thisVar
);
/*
auto nativeObj = ConvertNativeValueTo<NativeObject>(reinterpret_cast<NativeValue *>(thisVar));
auto
nativeObj
=
ConvertNativeValueTo
<
NativeObject
>
(
reinterpret_cast
<
NativeValue
*>
(
thisVar
));
if
(
nativeObj
==
nullptr
)
{
if
(
nativeObj
==
nullptr
)
{
ZLOGE
(
LOG_LABEL
,
"Failed to get RemoteObject native object"
);
ZLOGE
(
LOG_LABEL
,
"Failed to get RemoteObject native object"
);
delete
holder
;
delete
holder
;
return
nullptr
;
return
nullptr
;
}
}
nativeObj->ConvertToNativeBindingObject(env, RemoteObjectDetachCb, RemoteObjectAttachCb, holder, nullptr);
*/
nativeObj
->
ConvertToNativeBindingObject
(
env
,
RemoteObjectDetachCb
,
RemoteObjectAttachCb
,
holder
,
nullptr
);
// connect native object to js thisVar
// connect native object to js thisVar
napi_status
status
=
napi_wrap
(
napi_status
status
=
napi_wrap
(
env
,
thisVar
,
holder
,
RemoteObjectHolderFinalizeCb
,
nullptr
,
nullptr
);
env
,
thisVar
,
holder
,
[](
napi_env
env
,
void
*
data
,
void
*
hint
)
{
ZLOGI
(
LOG_LABEL
,
"NAPIRemoteObjectHolder destructed by js callback"
);
delete
(
reinterpret_cast
<
NAPIRemoteObjectHolder
*>
(
data
));
},
nullptr
,
nullptr
);
//napi_status status = napi_wrap(env, thisVar, holder, RemoteObjectHolderFinalizeCb, nullptr, nullptr);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"wrap js RemoteObject and native holder failed"
);
NAPI_ASSERT
(
env
,
status
==
napi_ok
,
"wrap js RemoteObject and native holder failed"
);
/*if (NAPI_ohos_rpc_getNativeRemoteObject(env, thisVar) == nullptr) {
ZLOGE(LOG_LABEL, "RemoteObject_JS_Constructor create native object failed");
return nullptr;
}*/
return
thisVar
;
return
thisVar
;
}
}
NAPIRemoteObject
::
NAPIRemoteObject
(
napi_env
env
,
napi_
value
thisVar
,
const
std
::
u16string
&
descriptor
)
NAPIRemoteObject
::
NAPIRemoteObject
(
napi_env
env
,
napi_
ref
jsObjectRef
,
const
std
::
u16string
&
descriptor
)
:
IPCObjectStub
(
descriptor
)
:
IPCObjectStub
(
descriptor
)
{
{
env_
=
env
;
env_
=
env
;
desc_
=
descriptor
;
napi_value
thisVar
=
nullptr
;
napi_get_reference_value
(
env
,
jsObjectRef
,
&
thisVar
);
NAPI_ASSERT_RETURN_VOID
(
env
,
thisVar
!=
nullptr
,
"failed to get value from js RemoteObject ref"
);
thisVar_
=
thisVar
;
thisVar_
=
thisVar
;
napi_create_reference
(
env
,
thisVar_
,
1
,
&
thisVarRef_
);
napi_create_reference
(
env
,
thisVar_
,
1
,
&
thisVarRef_
);
NAPI_ASSERT_RETURN_VOID
(
env
,
thisVarRef_
!=
nullptr
,
"failed to create ref to js RemoteObject"
);
NAPI_ASSERT_RETURN_VOID
(
env
,
thisVarRef_
!=
nullptr
,
"failed to create ref to js RemoteObject"
);
...
@@ -170,7 +164,7 @@ NAPIRemoteObject::NAPIRemoteObject(napi_env env, napi_value thisVar, const std::
...
@@ -170,7 +164,7 @@ NAPIRemoteObject::NAPIRemoteObject(napi_env env, napi_value thisVar, const std::
NAPIRemoteObject
::~
NAPIRemoteObject
()
NAPIRemoteObject
::~
NAPIRemoteObject
()
{
{
ZLOGI
(
LOG_LABEL
,
"NAPIRemoteObject
Destructor"
);
ZLOGI
(
LOG_LABEL
,
"NAPIRemoteObject
destroyed, desc:%{public}s"
,
Str16ToStr8
(
desc_
).
c_str
()
);
if
(
thisVarRef_
!=
nullptr
)
{
if
(
thisVarRef_
!=
nullptr
)
{
napi_status
status
=
napi_delete_reference
(
env_
,
thisVarRef_
);
napi_status
status
=
napi_delete_reference
(
env_
,
thisVarRef_
);
NAPI_ASSERT_RETURN_VOID
(
env_
,
status
==
napi_ok
,
"failed to delete ref to js RemoteObject"
);
NAPI_ASSERT_RETURN_VOID
(
env_
,
status
==
napi_ok
,
"failed to delete ref to js RemoteObject"
);
...
@@ -603,9 +597,8 @@ napi_value NAPI_ohos_rpc_CreateJsRemoteObject(napi_env env, const sptr<IRemoteOb
...
@@ -603,9 +597,8 @@ napi_value NAPI_ohos_rpc_CreateJsRemoteObject(napi_env env, const sptr<IRemoteOb
if
(
target
->
CheckObjectLegality
())
{
if
(
target
->
CheckObjectLegality
())
{
IPCObjectStub
*
tmp
=
static_cast
<
IPCObjectStub
*>
(
target
.
GetRefPtr
());
IPCObjectStub
*
tmp
=
static_cast
<
IPCObjectStub
*>
(
target
.
GetRefPtr
());
uint32_t
objectType
=
tmp
->
GetObjectType
();
uint32_t
objectType
=
tmp
->
GetObjectType
();
ZLOGI
(
LOG_LABEL
,
"
[mgttest]
object type:%{public}d"
,
objectType
);
ZLOGI
(
LOG_LABEL
,
"object type:%{public}d"
,
objectType
);
if
(
objectType
==
IPCObjectStub
::
OBJECT_TYPE_JAVASCRIPT
||
objectType
==
IPCObjectStub
::
OBJECT_TYPE_NATIVE
)
{
if
(
objectType
==
IPCObjectStub
::
OBJECT_TYPE_JAVASCRIPT
||
objectType
==
IPCObjectStub
::
OBJECT_TYPE_NATIVE
)
{
//ZLOGI(LOG_LABEL, "napi create js remote object");
sptr
<
NAPIRemoteObject
>
object
=
static_cast
<
NAPIRemoteObject
*>
(
target
.
GetRefPtr
());
sptr
<
NAPIRemoteObject
>
object
=
static_cast
<
NAPIRemoteObject
*>
(
target
.
GetRefPtr
());
// retrieve js remote object constructor
// retrieve js remote object constructor
napi_value
global
=
nullptr
;
napi_value
global
=
nullptr
;
...
@@ -630,7 +623,6 @@ napi_value NAPI_ohos_rpc_CreateJsRemoteObject(napi_env env, const sptr<IRemoteOb
...
@@ -630,7 +623,6 @@ napi_value NAPI_ohos_rpc_CreateJsRemoteObject(napi_env env, const sptr<IRemoteOb
NAPIRemoteObjectHolder
*
holder
=
nullptr
;
NAPIRemoteObjectHolder
*
holder
=
nullptr
;
napi_unwrap
(
env
,
jsRemoteObject
,
(
void
**
)
&
holder
);
napi_unwrap
(
env
,
jsRemoteObject
,
(
void
**
)
&
holder
);
NAPI_ASSERT
(
env
,
holder
!=
nullptr
,
"failed to get napi remote object holder"
);
NAPI_ASSERT
(
env
,
holder
!=
nullptr
,
"failed to get napi remote object holder"
);
ZLOGI
(
LOG_LABEL
,
"[mgttest]ipc object, save as wptr"
);
holder
->
Set
(
object
);
holder
->
Set
(
object
);
return
jsRemoteObject
;
return
jsRemoteObject
;
}
}
...
@@ -668,7 +660,7 @@ sptr<IRemoteObject> NAPI_ohos_rpc_getNativeRemoteObject(napi_env env, napi_value
...
@@ -668,7 +660,7 @@ sptr<IRemoteObject> NAPI_ohos_rpc_getNativeRemoteObject(napi_env env, napi_value
NAPIRemoteObjectHolder
*
holder
=
nullptr
;
NAPIRemoteObjectHolder
*
holder
=
nullptr
;
napi_unwrap
(
env
,
object
,
(
void
**
)
&
holder
);
napi_unwrap
(
env
,
object
,
(
void
**
)
&
holder
);
NAPI_ASSERT
(
env
,
holder
!=
nullptr
,
"failed to get napi remote object holder"
);
NAPI_ASSERT
(
env
,
holder
!=
nullptr
,
"failed to get napi remote object holder"
);
return
holder
!=
nullptr
?
holder
->
Get
(
object
)
:
nullptr
;
return
holder
!=
nullptr
?
holder
->
Get
()
:
nullptr
;
}
}
napi_value
proxyConstructor
=
nullptr
;
napi_value
proxyConstructor
=
nullptr
;
...
...
ipc/native/src/napi_common/source/napi_remote_object_holder.cpp
浏览文件 @
ce876990
...
@@ -18,10 +18,17 @@
...
@@ -18,10 +18,17 @@
#include <string_ex.h>
#include <string_ex.h>
namespace
OHOS
{
namespace
OHOS
{
NAPIRemoteObjectHolder
::
NAPIRemoteObjectHolder
(
napi_env
env
,
const
std
::
u16string
&
descriptor
)
NAPIRemoteObjectHolder
::
NAPIRemoteObjectHolder
(
napi_env
env
,
const
std
::
u16string
&
descriptor
,
napi_value
thisVar
)
:
env_
(
env
),
descriptor_
(
descriptor
),
cachedObject_
(
nullptr
),
localInterfaceRef_
(
nullptr
)
{
// : env_(env), descriptor_(descriptor), cachedObject_(nullptr), localInterfaceRef_(nullptr), attachCount_(1)
ZLOGE
(
LOG_LABEL
,
"[memtest]NAPIRemoteObjectHolder created"
);
{}
env_
=
env
;
descriptor_
=
descriptor
;
sptrCachedObject_
=
nullptr
;
wptrCachedObject_
=
nullptr
;
localInterfaceRef_
=
nullptr
;
attachCount_
=
1
;
napi_create_reference
(
env
,
thisVar
,
0
,
&
jsObjectRef_
);
}
NAPIRemoteObjectHolder
::~
NAPIRemoteObjectHolder
()
NAPIRemoteObjectHolder
::~
NAPIRemoteObjectHolder
()
{
{
...
@@ -33,7 +40,7 @@ NAPIRemoteObjectHolder::~NAPIRemoteObjectHolder()
...
@@ -33,7 +40,7 @@ NAPIRemoteObjectHolder::~NAPIRemoteObjectHolder()
}
}
}
}
sptr
<
NAPIRemoteObject
>
NAPIRemoteObjectHolder
::
Get
(
napi_value
jsRemoteObject
)
sptr
<
NAPIRemoteObject
>
NAPIRemoteObjectHolder
::
Get
()
{
{
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
mutex_
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
mutex_
);
// grab an strong reference to the object,
// grab an strong reference to the object,
...
@@ -43,7 +50,7 @@ sptr<NAPIRemoteObject> NAPIRemoteObjectHolder::Get(napi_value jsRemoteObject)
...
@@ -43,7 +50,7 @@ sptr<NAPIRemoteObject> NAPIRemoteObjectHolder::Get(napi_value jsRemoteObject)
}
}
sptr
<
NAPIRemoteObject
>
tmp
=
wptrCachedObject_
.
promote
();
sptr
<
NAPIRemoteObject
>
tmp
=
wptrCachedObject_
.
promote
();
if
(
tmp
==
nullptr
)
{
if
(
tmp
==
nullptr
)
{
tmp
=
new
NAPIRemoteObject
(
env_
,
js
RemoteObject
,
descriptor_
);
tmp
=
new
NAPIRemoteObject
(
env_
,
js
ObjectRef_
,
descriptor_
);
wptrCachedObject_
=
tmp
;
wptrCachedObject_
=
tmp
;
}
}
return
tmp
;
return
tmp
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录