1 #ifndef SRC_INSPECTOR_WORKER_AGENT_H_ 2 #define SRC_INSPECTOR_WORKER_AGENT_H_ 3 4 #include "node/inspector/protocol/NodeWorker.h" 5 #include "v8.h" 6 7 8 namespace node { 9 namespace inspector { 10 class WorkerManagerEventHandle; 11 class WorkerManager; 12 13 namespace protocol { 14 class NodeWorkers; 15 16 class WorkerAgent : public NodeWorker::Backend { 17 public: 18 explicit WorkerAgent(std::weak_ptr<WorkerManager> manager); 19 ~WorkerAgent() override = default; 20 21 void Wire(UberDispatcher* dispatcher); 22 23 DispatchResponse sendMessageToWorker(const String& message, 24 const String& sessionId) override; 25 26 DispatchResponse enable(bool waitForDebuggerOnStart) override; 27 DispatchResponse disable() override; 28 DispatchResponse detach(const String& sessionId) override; 29 30 private: 31 std::shared_ptr<NodeWorker::Frontend> frontend_; 32 std::weak_ptr<WorkerManager> manager_; 33 std::unique_ptr<WorkerManagerEventHandle> event_handle_; 34 std::shared_ptr<NodeWorkers> workers_; 35 }; 36 } // namespace protocol 37 } // namespace inspector 38 } // namespace node 39 40 #endif // SRC_INSPECTOR_WORKER_AGENT_H_ 41