refactor: replace V8 hidden values with WeakMap / WeakSet (#26659)
This commit is contained in:
parent
0be6c92aa9
commit
c8d77cae4a
4 changed files with 29 additions and 19 deletions
|
@ -56,6 +56,8 @@ function setCachedRendererFunction (id: RendererFunctionId, wc: electron.WebCont
|
|||
return value;
|
||||
}
|
||||
|
||||
const locationInfo = new WeakMap<Object, string>();
|
||||
|
||||
// Return the description of object's members:
|
||||
const getObjectMembers = function (object: any): ObjectMember[] {
|
||||
let names = Object.getOwnPropertyNames(object);
|
||||
|
@ -186,7 +188,7 @@ const throwRPCError = function (message: string) {
|
|||
};
|
||||
|
||||
const removeRemoteListenersAndLogWarning = (sender: any, callIntoRenderer: (...args: any[]) => void) => {
|
||||
const location = v8Util.getHiddenValue(callIntoRenderer, 'location');
|
||||
const location = locationInfo.get(callIntoRenderer);
|
||||
let message = 'Attempting to call a function in a renderer window that has been closed or released.' +
|
||||
`\nFunction provided here: ${location}`;
|
||||
|
||||
|
@ -269,7 +271,7 @@ const unwrapArgs = function (sender: electron.WebContents, frameId: number, cont
|
|||
removeRemoteListenersAndLogWarning(this, callIntoRenderer);
|
||||
}
|
||||
};
|
||||
v8Util.setHiddenValue(callIntoRenderer, 'location', meta.location);
|
||||
locationInfo.set(callIntoRenderer, meta.location);
|
||||
Object.defineProperty(callIntoRenderer, 'length', { value: meta.length });
|
||||
|
||||
setCachedRendererFunction(objectId, sender, frameId, callIntoRenderer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue