#ifndef InspectorCanvasAgent_h
#define InspectorCanvasAgent_h
#include "InspectorFrontend.h"
#include "InspectorTypeBuilder.h"
#include "bindings/v8/ScriptState.h"
#include "core/inspector/InspectorBaseAgent.h"
#include "wtf/HashMap.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class LocalFrame;
class DocumentLoader;
class InjectedScriptCanvasModule;
class InjectedScriptManager;
class InspectorPageAgent;
class InstrumentingAgents;
class ScriptObject;
typedef String ErrorString;
class InspectorCanvasAgent FINAL : public InspectorBaseAgent<InspectorCanvasAgent>, public InspectorBackendDispatcher::CanvasCommandHandler {
public:
static PassOwnPtr<InspectorCanvasAgent> create(InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager)
{
return adoptPtr(new InspectorCanvasAgent(pageAgent, injectedScriptManager));
}
virtual ~InspectorCanvasAgent();
virtual void setFrontend(InspectorFrontend*) OVERRIDE;
virtual void clearFrontend() OVERRIDE;
virtual void restore() OVERRIDE;
void didCommitLoad(LocalFrame*, DocumentLoader*);
void frameDetachedFromParent(LocalFrame*);
void didBeginFrame();
ScriptObject wrapCanvas2DRenderingContextForInstrumentation(const ScriptObject&);
ScriptObject wrapWebGLRenderingContextForInstrumentation(const ScriptObject&);
virtual void enable(ErrorString*) OVERRIDE;
virtual void disable(ErrorString*) OVERRIDE;
virtual void dropTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&) OVERRIDE;
virtual void hasUninstrumentedCanvases(ErrorString*, bool*) OVERRIDE;
virtual void captureFrame(ErrorString*, const TypeBuilder::Page::FrameId*, TypeBuilder::Canvas::TraceLogId*) OVERRIDE;
virtual void startCapturing(ErrorString*, const TypeBuilder::Page::FrameId*, TypeBuilder::Canvas::TraceLogId*) OVERRIDE;
virtual void stopCapturing(ErrorString*, const TypeBuilder::Canvas::TraceLogId&) OVERRIDE;
virtual void getTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const int*, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>&) OVERRIDE;
virtual void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>&, double*) OVERRIDE;
virtual void getResourceState(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceState>&) OVERRIDE;
virtual void evaluateTraceLogCallArgument(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, int, const String*, RefPtr<TypeBuilder::Runtime::RemoteObject>&, RefPtr<TypeBuilder::Canvas::ResourceState>&) OVERRIDE;
private:
InspectorCanvasAgent(InspectorPageAgent*, InjectedScriptManager*);
InjectedScriptCanvasModule injectedScriptCanvasModule(ErrorString*, ScriptState*);
InjectedScriptCanvasModule injectedScriptCanvasModule(ErrorString*, const ScriptObject&);
InjectedScriptCanvasModule injectedScriptCanvasModule(ErrorString*, const String&);
void findFramesWithUninstrumentedCanvases();
bool checkIsEnabled(ErrorString*) const;
ScriptObject notifyRenderingContextWasWrapped(const ScriptObject&);
InspectorPageAgent* m_pageAgent;
InjectedScriptManager* m_injectedScriptManager;
InspectorFrontend::Canvas* m_frontend;
bool m_enabled;
typedef HashMap<LocalFrame*, bool> FramesWithUninstrumentedCanvases;
FramesWithUninstrumentedCanvases m_framesWithUninstrumentedCanvases;
};
}
#endif