2022-10-20 05:49:49 +00:00
|
|
|
// Copyright (c) 2022 Microsoft, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ELECTRON_SHELL_SERVICES_NODE_NODE_SERVICE_H_
|
|
|
|
#define ELECTRON_SHELL_SERVICES_NODE_NODE_SERVICE_H_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
|
|
|
#include "mojo/public/cpp/bindings/receiver.h"
|
|
|
|
#include "shell/services/node/public/mojom/node_service.mojom.h"
|
|
|
|
|
2023-08-23 13:56:16 +00:00
|
|
|
namespace node {
|
|
|
|
|
|
|
|
class Environment;
|
|
|
|
|
|
|
|
} // namespace node
|
|
|
|
|
2022-10-20 05:49:49 +00:00
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
class ElectronBindings;
|
|
|
|
class JavascriptEnvironment;
|
|
|
|
class NodeBindings;
|
|
|
|
|
|
|
|
class NodeService : public node::mojom::NodeService {
|
|
|
|
public:
|
|
|
|
explicit NodeService(
|
|
|
|
mojo::PendingReceiver<node::mojom::NodeService> receiver);
|
|
|
|
~NodeService() override;
|
|
|
|
|
|
|
|
NodeService(const NodeService&) = delete;
|
|
|
|
NodeService& operator=(const NodeService&) = delete;
|
|
|
|
|
|
|
|
// mojom::NodeService implementation:
|
|
|
|
void Initialize(node::mojom::NodeServiceParamsPtr params) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool node_env_stopped_ = false;
|
|
|
|
std::unique_ptr<JavascriptEnvironment> js_env_;
|
|
|
|
std::unique_ptr<NodeBindings> node_bindings_;
|
|
|
|
std::unique_ptr<ElectronBindings> electron_bindings_;
|
2023-08-23 13:56:16 +00:00
|
|
|
std::shared_ptr<node::Environment> node_env_;
|
2022-10-20 05:49:49 +00:00
|
|
|
mojo::Receiver<node::mojom::NodeService> receiver_{this};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
|
|
|
#endif // ELECTRON_SHELL_SERVICES_NODE_NODE_SERVICE_H_
|