fix: ensure that functions are not retained beyond their context being released (#23207)
This commit is contained in:
parent
aca2e4f968
commit
0cbcee6740
3 changed files with 50 additions and 1 deletions
|
@ -32,6 +32,16 @@ void RenderFrameFunctionStore::OnDestruct() {
|
|||
delete this;
|
||||
}
|
||||
|
||||
void RenderFrameFunctionStore::WillReleaseScriptContext(
|
||||
v8::Local<v8::Context> context,
|
||||
int32_t world_id) {
|
||||
base::EraseIf(functions_, [context](auto const& pair) {
|
||||
v8::Local<v8::Context> func_owning_context =
|
||||
std::get<1>(pair.second).Get(context->GetIsolate());
|
||||
return func_owning_context == context;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace context_bridge
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -29,6 +29,8 @@ class RenderFrameFunctionStore final : public content::RenderFrameObserver {
|
|||
|
||||
// RenderFrameObserver implementation.
|
||||
void OnDestruct() override;
|
||||
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
||||
int32_t world_id) override;
|
||||
|
||||
size_t take_func_id() { return next_func_id_++; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue