CommandLineAPIHost.h [plain text]
#pragma once
#include "InstrumentingAgents.h"
#include <JavaScriptCore/PerGlobalObjectWrapperWorld.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace JSC {
class JSValue;
}
namespace WebCore {
class Database;
class EventTarget;
class JSDOMGlobalObject;
class Storage;
struct EventListenerInfo;
class CommandLineAPIHost : public RefCounted<CommandLineAPIHost> {
public:
static Ref<CommandLineAPIHost> create();
~CommandLineAPIHost();
void init(RefPtr<InstrumentingAgents> instrumentingAgents)
{
m_instrumentingAgents = instrumentingAgents;
}
void disconnect();
void clearConsoleMessages();
void copyText(const String& text);
class InspectableObject {
WTF_MAKE_FAST_ALLOCATED;
public:
virtual JSC::JSValue get(JSC::JSGlobalObject&);
virtual ~InspectableObject() = default;
};
void addInspectedObject(std::unique_ptr<InspectableObject>);
JSC::JSValue inspectedObject(JSC::JSGlobalObject&);
void inspect(JSC::JSGlobalObject&, JSC::JSValue objectToInspect, JSC::JSValue hints);
struct ListenerEntry {
JSC::Strong<JSC::JSObject> listener;
bool useCapture;
bool passive;
bool once;
};
using EventListenersRecord = Vector<WTF::KeyValuePair<String, Vector<ListenerEntry>>>;
EventListenersRecord getEventListeners(JSC::JSGlobalObject&, EventTarget&);
String databaseId(Database&);
String storageId(Storage&);
JSC::JSValue wrapper(JSC::JSGlobalObject*, JSDOMGlobalObject*);
void clearAllWrappers();
private:
CommandLineAPIHost();
RefPtr<InstrumentingAgents> m_instrumentingAgents;
std::unique_ptr<InspectableObject> m_inspectedObject; Inspector::PerGlobalObjectWrapperWorld m_wrappers;
};
}