#ifndef InspectorInstrumentation_h
#define InspectorInstrumentation_h
#include "bindings/v8/ScriptString.h"
#include "core/css/CSSSelector.h"
#include "core/css/CSSStyleDeclaration.h"
#include "core/css/CSSStyleSheet.h"
#include "core/dom/CharacterData.h"
#include "core/dom/Element.h"
#include "core/dom/ExecutionContext.h"
#include "core/events/NodeEventContext.h"
#include "core/frame/LocalFrame.h"
#include "core/inspector/ConsoleAPITypes.h"
#include "core/page/Page.h"
#include "core/rendering/HitTestResult.h"
#include "core/rendering/RenderImage.h"
#include "core/storage/StorageArea.h"
#include "platform/network/FormData.h"
#include "platform/network/WebSocketHandshakeRequest.h"
#include "platform/network/WebSocketHandshakeResponse.h"
#include "wtf/RefPtr.h"
namespace WebCore {
struct CSSParserString;
class Document;
class Element;
class EventTarget;
class ExecutionContext;
class GraphicsContext;
class GraphicsLayer;
class InspectorTimelineAgent;
class InstrumentingAgents;
class RenderLayer;
class ThreadableLoaderClient;
class WorkerGlobalScope;
class WorkerGlobalScopeProxy;
#define FAST_RETURN_IF_NO_FRONTENDS(value) if (!hasFrontends()) return value;
class InspectorInstrumentationCookie {
public:
InspectorInstrumentationCookie();
InspectorInstrumentationCookie(InstrumentingAgents*, int);
InspectorInstrumentationCookie(const InspectorInstrumentationCookie&);
InspectorInstrumentationCookie& operator=(const InspectorInstrumentationCookie&);
~InspectorInstrumentationCookie();
InstrumentingAgents* instrumentingAgents() const { return m_instrumentingAgents.get(); }
bool isValid() const { return !!m_instrumentingAgents; }
bool hasMatchingTimelineAgentId(int id) const { return m_timelineAgentId == id; }
private:
RefPtr<InstrumentingAgents> m_instrumentingAgents;
int m_timelineAgentId;
};
namespace InspectorInstrumentation {
class FrontendCounter {
private:
friend void frontendCreated();
friend void frontendDeleted();
friend bool hasFrontends();
static int s_frontendCounter;
};
inline void frontendCreated() { FrontendCounter::s_frontendCounter += 1; }
inline void frontendDeleted() { FrontendCounter::s_frontendCounter -= 1; }
inline bool hasFrontends() { return FrontendCounter::s_frontendCounter; }
void registerInstrumentingAgents(InstrumentingAgents*);
void unregisterInstrumentingAgents(InstrumentingAgents*);
InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
InstrumentingAgents* instrumentingAgentsFor(Page*);
InstrumentingAgents* instrumentingAgentsFor(LocalFrame*);
InstrumentingAgents* instrumentingAgentsFor(EventTarget*);
InstrumentingAgents* instrumentingAgentsFor(ExecutionContext*);
InstrumentingAgents* instrumentingAgentsFor(Document&);
InstrumentingAgents* instrumentingAgentsFor(Document*);
InstrumentingAgents* instrumentingAgentsFor(RenderObject*);
InstrumentingAgents* instrumentingAgentsFor(Node*);
InstrumentingAgents* instrumentingAgentsFor(WorkerGlobalScope*);
InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ExecutionContext*);
}
namespace InstrumentationEvents {
extern const char PaintSetup[];
extern const char RasterTask[];
extern const char Paint[];
extern const char Layer[];
extern const char RequestMainThreadFrame[];
extern const char BeginFrame[];
extern const char DrawFrame[];
extern const char ActivateLayerTree[];
extern const char EmbedderCallback[];
};
namespace InstrumentationEventArguments {
extern const char FrameId[];
extern const char LayerId[];
extern const char LayerTreeId[];
extern const char PageId[];
extern const char CallbackName[];
};
namespace InspectorInstrumentation {
inline InstrumentingAgents* instrumentingAgentsFor(ExecutionContext* context)
{
if (!context)
return 0;
return context->isDocument() ? instrumentingAgentsFor(*toDocument(context)) : instrumentingAgentsForNonDocumentContext(context);
}
inline InstrumentingAgents* instrumentingAgentsFor(LocalFrame* frame)
{
return frame ? instrumentingAgentsFor(frame->page()) : 0;
}
inline InstrumentingAgents* instrumentingAgentsFor(Document& document)
{
Page* page = document.page();
if (!page && document.templateDocumentHost())
page = document.templateDocumentHost()->page();
return instrumentingAgentsFor(page);
}
inline InstrumentingAgents* instrumentingAgentsFor(Document* document)
{
return document ? instrumentingAgentsFor(*document) : 0;
}
inline InstrumentingAgents* instrumentingAgentsFor(CSSStyleSheet* styleSheet)
{
return styleSheet ? instrumentingAgentsFor(styleSheet->ownerDocument()) : 0;
}
inline InstrumentingAgents* instrumentingAgentsFor(Node* node)
{
return node ? instrumentingAgentsFor(node->document()) : 0;
}
inline InstrumentingAgents* instrumentingAgentsFor(CSSStyleDeclaration* declaration)
{
return declaration ? instrumentingAgentsFor(declaration->parentStyleSheet()) : 0;
}
}
InstrumentingAgents* instrumentationForPage(Page*);
InstrumentingAgents* instrumentationForWorkerGlobalScope(WorkerGlobalScope*);
}
#include "InspectorInstrumentationInl.h"
#include "InspectorInstrumentationCustomInl.h"
#include "InspectorOverridesInl.h"
#endif