InspectorReplayAgent.h [plain text]
#ifndef InspectorReplayAgent_h
#define InspectorReplayAgent_h
#if ENABLE(INSPECTOR) && ENABLE(WEB_REPLAY)
#include "InspectorWebAgentBase.h"
#include "InspectorWebBackendDispatchers.h"
#include "InspectorWebFrontendDispatchers.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
class DocumentLoader;
class Event;
class Frame;
class InspectorPageAgent;
class InstrumentingAgents;
class Page;
class ReplaySession;
class ReplaySessionSegment;
enum class SessionState;
struct ReplayPosition;
typedef String ErrorString;
typedef int SessionIdentifier;
typedef int SegmentIdentifier;
class InspectorReplayAgent final
: public InspectorAgentBase
, public Inspector::InspectorReplayBackendDispatcherHandler {
WTF_MAKE_NONCOPYABLE(InspectorReplayAgent);
public:
InspectorReplayAgent(InstrumentingAgents*, InspectorPageAgent*);
~InspectorReplayAgent();
virtual void didCreateFrontendAndBackend(Inspector::InspectorFrontendChannel*, Inspector::InspectorBackendDispatcher*) override;
virtual void willDestroyFrontendAndBackend(Inspector::InspectorDisconnectReason) override;
void frameNavigated(DocumentLoader*);
void frameDetached(Frame*);
void willDispatchEvent(const Event&, Frame*);
void sessionCreated(PassRefPtr<ReplaySession>);
void sessionModified(PassRefPtr<ReplaySession>);
void sessionLoaded(PassRefPtr<ReplaySession>);
void segmentCreated(PassRefPtr<ReplaySessionSegment>);
void segmentCompleted(PassRefPtr<ReplaySessionSegment>);
void segmentLoaded(PassRefPtr<ReplaySessionSegment>);
void segmentUnloaded();
void captureStarted();
void captureStopped();
void playbackStarted();
void playbackPaused(const ReplayPosition&);
void playbackHitPosition(const ReplayPosition&);
void playbackFinished();
virtual void startCapturing(ErrorString*) override;
virtual void stopCapturing(ErrorString*) override;
virtual void replayToPosition(ErrorString*, const RefPtr<Inspector::InspectorObject>&, bool shouldFastForward) override;
virtual void replayToCompletion(ErrorString*, bool shouldFastForward) override;
virtual void pausePlayback(ErrorString*) override;
virtual void cancelPlayback(ErrorString*) override;
virtual void switchSession(ErrorString*, SessionIdentifier) override;
virtual void insertSessionSegment(ErrorString*, SessionIdentifier, SegmentIdentifier, int segmentIndex) override;
virtual void removeSessionSegment(ErrorString*, SessionIdentifier, int segmentIndex) override;
virtual void getAvailableSessions(ErrorString*, RefPtr<Inspector::TypeBuilder::Array<SessionIdentifier>>&) override;
virtual void getSerializedSession(ErrorString*, SessionIdentifier, RefPtr<Inspector::TypeBuilder::Replay::ReplaySession>&) override;
virtual void getSerializedSegment(ErrorString*, SegmentIdentifier, RefPtr<Inspector::TypeBuilder::Replay::SessionSegment>&) override;
private:
PassRefPtr<ReplaySession> findSession(ErrorString*, SessionIdentifier);
PassRefPtr<ReplaySessionSegment> findSegment(ErrorString*, SegmentIdentifier);
SessionState sessionState() const;
std::unique_ptr<Inspector::InspectorReplayFrontendDispatcher> m_frontendDispatcher;
RefPtr<Inspector::InspectorReplayBackendDispatcher> m_backendDispatcher;
Page& m_page;
HashMap<int, RefPtr<ReplaySession>, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> m_sessionsMap;
HashMap<int, RefPtr<ReplaySessionSegment>, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> m_segmentsMap;
};
}
#endif // ENABLE(INSPECTOR) && ENABLE(WEB_REPLAY)
#endif // InspectorReplayAgent_h