RemoteInspectorServer.h [plain text]
#pragma once
#if ENABLE(REMOTE_INSPECTOR)
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/glib/GRefPtr.h>
typedef struct _GCancellable GCancellable;
typedef struct _GDBusConnection GDBusConnection;
typedef struct _GDBusInterfaceInfo GDBusInterfaceInfo;
typedef struct _GDBusInterfaceVTable GDBusInterfaceVTable;
typedef struct _GDBusNodeInfo GDBusNodeInfo;
typedef struct _GDBusServer GDBusServer;
typedef struct _GVariant GVariant;
namespace Inspector {
class RemoteInspectorServer {
public:
static RemoteInspectorServer& singleton();
~RemoteInspectorServer();
bool start(const char* address, unsigned port);
bool isRunning() const { return !!m_dbusServer; }
private:
GDBusInterfaceInfo* interfaceInfo();
static gboolean newConnectionCallback(GDBusServer*, GDBusConnection*, RemoteInspectorServer*);
static void connectionClosedCallback(GDBusConnection*, gboolean remotePeerVanished, GError*, RemoteInspectorServer*);
void newConnection(GDBusConnection*);
void connectionClosed(GDBusConnection*);
static const GDBusInterfaceVTable s_interfaceVTable;
void setTargetList(GDBusConnection*, GVariant*);
GVariant* setupInspectorClient(GDBusConnection*, const char* clientBackendCommandsHash);
void setup(GDBusConnection*, uint64_t connectionID, uint64_t targetID);
void close(GDBusConnection*, uint64_t connectionID, uint64_t targetID);
void clientConnectionClosed(GDBusConnection*);
void sendMessageToFrontend(GDBusConnection*, uint64_t target, const char*);
void sendMessageToBackend(GDBusConnection*, uint64_t connectionID, uint64_t targetID, const char*);
void startAutomationSession(GDBusConnection*, const char* sessionID);
static void clientConnectionClosedCallback(GDBusConnection*, gboolean remotePeerVanished, GError*, RemoteInspectorServer*);
GDBusNodeInfo* m_introspectionData { nullptr };
GRefPtr<GDBusServer> m_dbusServer;
GRefPtr<GCancellable> m_cancellable;
HashSet<GRefPtr<GDBusConnection>> m_connections;
HashMap<GDBusConnection*, uint64_t> m_remoteInspectorConnectionToIDMap;
HashMap<uint64_t, GDBusConnection*> m_idToRemoteInspectorConnectionMap;
GRefPtr<GDBusConnection> m_clientConnection;
HashSet<std::pair<uint64_t, uint64_t>> m_inspectionTargets;
GRefPtr<GDBusConnection> m_automationConnection;
HashSet<std::pair<uint64_t, uint64_t>> m_automationTargets;
};
}
#endif // ENABLE(REMOTE_INSPECTOR)