#ifndef RespondWithObserver_h
#define RespondWithObserver_h
#include "core/dom/ContextLifecycleObserver.h"
#include "wtf/Forward.h"
#include "wtf/RefCounted.h"
namespace WebCore {
class ExecutionContext;
class Response;
class ScriptValue;
class RespondWithObserver FINAL : public ContextLifecycleObserver, public RefCounted<RespondWithObserver> {
public:
static PassRefPtr<RespondWithObserver> create(ExecutionContext*, int eventID);
~RespondWithObserver();
virtual void contextDestroyed() OVERRIDE;
void didDispatchEvent();
void respondWith(const ScriptValue&);
void responseWasRejected();
void responseWasFulfilled(const ScriptValue&);
private:
class ThenFunction;
RespondWithObserver(ExecutionContext*, int eventID);
void sendResponse(PassRefPtr<Response>);
int m_eventID;
enum State { Initial, Pending, Done };
State m_state;
};
}
#endif