mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
fix: net.isOnline always true in utility processes (#48111)
* fix: net.isOnline always true in utilityProcesses * Update shell/services/node/node_service.cc Co-authored-by: Robo <hop2deep@gmail.com> --------- Co-authored-by: Robo <hop2deep@gmail.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "base/process/process.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "electron/mas.h"
|
||||
#include "net/base/network_change_notifier.h"
|
||||
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
|
||||
#include "services/network/public/mojom/host_resolver.mojom.h"
|
||||
#include "services/network/public/mojom/network_context.mojom.h"
|
||||
@@ -127,6 +128,10 @@ void NodeService::Initialize(
|
||||
|
||||
node_bindings_->Initialize(isolate, isolate->GetCurrentContext());
|
||||
|
||||
network_change_notifier_ = net::NetworkChangeNotifier::CreateIfNeeded(
|
||||
net::NetworkChangeNotifier::CONNECTION_UNKNOWN,
|
||||
net::NetworkChangeNotifier::ConnectionSubtype::SUBTYPE_UNKNOWN);
|
||||
|
||||
// Append program path for process.argv0
|
||||
auto program = base::CommandLine::ForCurrentProcess()->GetProgram();
|
||||
#if defined(OS_WIN)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "net/base/network_change_notifier.h"
|
||||
#include "services/network/public/cpp/shared_url_loader_factory.h"
|
||||
#include "services/network/public/mojom/host_resolver.mojom.h"
|
||||
#include "services/network/public/mojom/url_loader_factory.mojom-forward.h"
|
||||
@@ -84,6 +85,8 @@ class NodeService : public node::mojom::NodeService {
|
||||
|
||||
// depends-on: js_env_'s isolate
|
||||
std::shared_ptr<node::Environment> node_env_;
|
||||
|
||||
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_;
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
||||
Reference in New Issue
Block a user