chore: fix IsolateData handling (#20918)
This commit is contained in:
parent
776cab96b1
commit
b194d5d0e2
4 changed files with 17 additions and 4 deletions
|
@ -336,9 +336,11 @@ node::Environment* NodeBindings::CreateEnvironment(
|
||||||
args.insert(args.begin() + 1, init_script);
|
args.insert(args.begin() + 1, init_script);
|
||||||
|
|
||||||
std::unique_ptr<const char*[]> c_argv = StringVectorToArgArray(args);
|
std::unique_ptr<const char*[]> c_argv = StringVectorToArgArray(args);
|
||||||
node::Environment* env = node::CreateEnvironment(
|
isolate_data_ =
|
||||||
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform),
|
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform);
|
||||||
context, args.size(), c_argv.get(), 0, nullptr, bootstrap_env);
|
node::Environment* env =
|
||||||
|
node::CreateEnvironment(isolate_data_, context, args.size(), c_argv.get(),
|
||||||
|
0, nullptr, bootstrap_env);
|
||||||
DCHECK(env);
|
DCHECK(env);
|
||||||
|
|
||||||
// Clean up the global _noBrowserGlobals that we unironically injected into
|
// Clean up the global _noBrowserGlobals that we unironically injected into
|
||||||
|
|
|
@ -19,6 +19,7 @@ class MessageLoop;
|
||||||
namespace node {
|
namespace node {
|
||||||
class Environment;
|
class Environment;
|
||||||
class MultiIsolatePlatform;
|
class MultiIsolatePlatform;
|
||||||
|
class IsolateData;
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
@ -54,6 +55,8 @@ class NodeBindings {
|
||||||
// Do message loop integration.
|
// Do message loop integration.
|
||||||
virtual void RunMessageLoop();
|
virtual void RunMessageLoop();
|
||||||
|
|
||||||
|
node::IsolateData* isolate_data() const { return isolate_data_; }
|
||||||
|
|
||||||
// Gets/sets the environment to wrap uv loop.
|
// Gets/sets the environment to wrap uv loop.
|
||||||
void set_uv_env(node::Environment* env) { uv_env_ = env; }
|
void set_uv_env(node::Environment* env) { uv_env_ = env; }
|
||||||
node::Environment* uv_env() const { return uv_env_; }
|
node::Environment* uv_env() const { return uv_env_; }
|
||||||
|
@ -106,6 +109,9 @@ class NodeBindings {
|
||||||
// Environment that to wrap the uv loop.
|
// Environment that to wrap the uv loop.
|
||||||
node::Environment* uv_env_ = nullptr;
|
node::Environment* uv_env_ = nullptr;
|
||||||
|
|
||||||
|
// Isolate data used in creating the environment
|
||||||
|
node::IsolateData* isolate_data_ = nullptr;
|
||||||
|
|
||||||
base::WeakPtrFactory<NodeBindings> weak_factory_;
|
base::WeakPtrFactory<NodeBindings> weak_factory_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NodeBindings);
|
DISALLOW_COPY_AND_ASSIGN(NodeBindings);
|
||||||
|
|
|
@ -176,8 +176,12 @@ void AtomRendererClient::WillReleaseScriptContext(
|
||||||
// avoid memory leaks
|
// avoid memory leaks
|
||||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
if (command_line->HasSwitch(switches::kNodeIntegrationInSubFrames) ||
|
if (command_line->HasSwitch(switches::kNodeIntegrationInSubFrames) ||
|
||||||
command_line->HasSwitch(switches::kDisableElectronSiteInstanceOverrides))
|
command_line->HasSwitch(
|
||||||
|
switches::kDisableElectronSiteInstanceOverrides)) {
|
||||||
node::FreeEnvironment(env);
|
node::FreeEnvironment(env);
|
||||||
|
if (env == node_bindings_->uv_env())
|
||||||
|
node::FreeIsolateData(node_bindings_->isolate_data());
|
||||||
|
}
|
||||||
|
|
||||||
// ElectronBindings is tracking node environments.
|
// ElectronBindings is tracking node environments.
|
||||||
electron_bindings_->EnvironmentDestroyed(env);
|
electron_bindings_->EnvironmentDestroyed(env);
|
||||||
|
|
|
@ -38,6 +38,7 @@ WebWorkerObserver::WebWorkerObserver()
|
||||||
WebWorkerObserver::~WebWorkerObserver() {
|
WebWorkerObserver::~WebWorkerObserver() {
|
||||||
lazy_tls.Pointer()->Set(nullptr);
|
lazy_tls.Pointer()->Set(nullptr);
|
||||||
node::FreeEnvironment(node_bindings_->uv_env());
|
node::FreeEnvironment(node_bindings_->uv_env());
|
||||||
|
node::FreeIsolateData(node_bindings_->isolate_data());
|
||||||
asar::ClearArchives();
|
asar::ClearArchives();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue