fix: early GC of WebFrameMain instances (#27648)
This commit is contained in:
parent
bc7c290601
commit
1bbfa934f0
2 changed files with 13 additions and 2 deletions
|
@ -57,6 +57,9 @@ WebFrameMain::~WebFrameMain() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrameMain::MarkRenderFrameDisposed() {
|
void WebFrameMain::MarkRenderFrameDisposed() {
|
||||||
|
if (render_frame_disposed_)
|
||||||
|
return;
|
||||||
|
Unpin();
|
||||||
g_render_frame_map.Get().erase(render_frame_);
|
g_render_frame_map.Get().erase(render_frame_);
|
||||||
render_frame_disposed_ = true;
|
render_frame_disposed_ = true;
|
||||||
}
|
}
|
||||||
|
@ -305,8 +308,14 @@ gin::Handle<WebFrameMain> WebFrameMain::From(v8::Isolate* isolate,
|
||||||
if (rfh == nullptr)
|
if (rfh == nullptr)
|
||||||
return gin::Handle<WebFrameMain>();
|
return gin::Handle<WebFrameMain>();
|
||||||
auto* web_frame = FromRenderFrameHost(rfh);
|
auto* web_frame = FromRenderFrameHost(rfh);
|
||||||
auto handle = gin::CreateHandle(
|
if (web_frame)
|
||||||
isolate, web_frame == nullptr ? new WebFrameMain(rfh) : web_frame);
|
return gin::CreateHandle(isolate, web_frame);
|
||||||
|
|
||||||
|
auto handle = gin::CreateHandle(isolate, new WebFrameMain(rfh));
|
||||||
|
|
||||||
|
// Prevent garbage collection of frame until it has been deleted internally.
|
||||||
|
handle->Pin(isolate);
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "gin/handle.h"
|
#include "gin/handle.h"
|
||||||
#include "gin/wrappable.h"
|
#include "gin/wrappable.h"
|
||||||
#include "shell/common/gin_helper/constructible.h"
|
#include "shell/common/gin_helper/constructible.h"
|
||||||
|
#include "shell/common/gin_helper/pinnable.h"
|
||||||
|
|
||||||
class GURL;
|
class GURL;
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ namespace api {
|
||||||
|
|
||||||
// Bindings for accessing frames from the main process.
|
// Bindings for accessing frames from the main process.
|
||||||
class WebFrameMain : public gin::Wrappable<WebFrameMain>,
|
class WebFrameMain : public gin::Wrappable<WebFrameMain>,
|
||||||
|
public gin_helper::Pinnable<WebFrameMain>,
|
||||||
public gin_helper::Constructible<WebFrameMain> {
|
public gin_helper::Constructible<WebFrameMain> {
|
||||||
public:
|
public:
|
||||||
// Create a new WebFrameMain and return the V8 wrapper of it.
|
// Create a new WebFrameMain and return the V8 wrapper of it.
|
||||||
|
|
Loading…
Add table
Reference in a new issue