InspectorWorkerAgent.h [plain text]
#pragma once
#include "InspectorWebAgentBase.h"
#include "WorkerInspectorProxy.h"
#include <inspector/InspectorBackendDispatchers.h>
#include <inspector/InspectorFrontendDispatchers.h>
#include <wtf/HashMap.h>
namespace WebCore {
class Page;
class URL;
typedef String ErrorString;
class InspectorWorkerAgent final : public InspectorAgentBase, public Inspector::WorkerBackendDispatcherHandler, public WorkerInspectorProxy::PageChannel {
WTF_MAKE_NONCOPYABLE(InspectorWorkerAgent);
WTF_MAKE_FAST_ALLOCATED;
public:
InspectorWorkerAgent(PageAgentContext&);
virtual ~InspectorWorkerAgent() { }
void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
void enable(ErrorString&) override;
void disable(ErrorString&) override;
void initialized(ErrorString&, const String& workerId) override;
void sendMessageToWorker(ErrorString&, const String& workerId, const String& message) override;
void sendMessageFromWorkerToFrontend(WorkerInspectorProxy*, const String& message) override;
bool shouldWaitForDebuggerOnStart() const;
void workerStarted(WorkerInspectorProxy*, const URL&);
void workerTerminated(WorkerInspectorProxy*);
private:
void connectToAllWorkerInspectorProxiesForPage();
void disconnectFromAllWorkerInspectorProxies();
void connectToWorkerInspectorProxy(WorkerInspectorProxy*);
void disconnectFromWorkerInspectorProxy(WorkerInspectorProxy*);
std::unique_ptr<Inspector::WorkerFrontendDispatcher> m_frontendDispatcher;
RefPtr<Inspector::WorkerBackendDispatcher> m_backendDispatcher;
Page& m_page;
HashMap<String, WorkerInspectorProxy*> m_connectedProxies;
bool m_enabled { false };
};
}