зеркало из https://github.com/electron/electron.git
chore: fix IsolateData handling (#20918)
This commit is contained in:
Родитель
776cab96b1
Коммит
b194d5d0e2
|
@ -336,9 +336,11 @@ node::Environment* NodeBindings::CreateEnvironment(
|
|||
args.insert(args.begin() + 1, init_script);
|
||||
|
||||
std::unique_ptr<const char*[]> c_argv = StringVectorToArgArray(args);
|
||||
node::Environment* env = node::CreateEnvironment(
|
||||
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform),
|
||||
context, args.size(), c_argv.get(), 0, nullptr, bootstrap_env);
|
||||
isolate_data_ =
|
||||
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform);
|
||||
node::Environment* env =
|
||||
node::CreateEnvironment(isolate_data_, context, args.size(), c_argv.get(),
|
||||
0, nullptr, bootstrap_env);
|
||||
DCHECK(env);
|
||||
|
||||
// Clean up the global _noBrowserGlobals that we unironically injected into
|
||||
|
|
|
@ -19,6 +19,7 @@ class MessageLoop;
|
|||
namespace node {
|
||||
class Environment;
|
||||
class MultiIsolatePlatform;
|
||||
class IsolateData;
|
||||
} // namespace node
|
||||
|
||||
namespace electron {
|
||||
|
@ -54,6 +55,8 @@ class NodeBindings {
|
|||
// Do message loop integration.
|
||||
virtual void RunMessageLoop();
|
||||
|
||||
node::IsolateData* isolate_data() const { return isolate_data_; }
|
||||
|
||||
// Gets/sets the environment to wrap uv loop.
|
||||
void set_uv_env(node::Environment* env) { uv_env_ = env; }
|
||||
node::Environment* uv_env() const { return uv_env_; }
|
||||
|
@ -106,6 +109,9 @@ class NodeBindings {
|
|||
// Environment that to wrap the uv loop.
|
||||
node::Environment* uv_env_ = nullptr;
|
||||
|
||||
// Isolate data used in creating the environment
|
||||
node::IsolateData* isolate_data_ = nullptr;
|
||||
|
||||
base::WeakPtrFactory<NodeBindings> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NodeBindings);
|
||||
|
|
|
@ -176,8 +176,12 @@ void AtomRendererClient::WillReleaseScriptContext(
|
|||
// avoid memory leaks
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kNodeIntegrationInSubFrames) ||
|
||||
command_line->HasSwitch(switches::kDisableElectronSiteInstanceOverrides))
|
||||
command_line->HasSwitch(
|
||||
switches::kDisableElectronSiteInstanceOverrides)) {
|
||||
node::FreeEnvironment(env);
|
||||
if (env == node_bindings_->uv_env())
|
||||
node::FreeIsolateData(node_bindings_->isolate_data());
|
||||
}
|
||||
|
||||
// ElectronBindings is tracking node environments.
|
||||
electron_bindings_->EnvironmentDestroyed(env);
|
||||
|
|
|
@ -38,6 +38,7 @@ WebWorkerObserver::WebWorkerObserver()
|
|||
WebWorkerObserver::~WebWorkerObserver() {
|
||||
lazy_tls.Pointer()->Set(nullptr);
|
||||
node::FreeEnvironment(node_bindings_->uv_env());
|
||||
node::FreeIsolateData(node_bindings_->isolate_data());
|
||||
asar::ClearArchives();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче