#ifndef WaitUntilObserver_h
#define WaitUntilObserver_h
#include "core/dom/ContextLifecycleObserver.h"
#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
#include "wtf/Forward.h"
#include "wtf/RefCounted.h"
namespace WebCore {
class ExecutionContext;
class ScriptValue;
class WaitUntilObserver FINAL :
public ContextLifecycleObserver,
public RefCounted<WaitUntilObserver> {
public:
enum EventType {
Activate,
Install
};
static PassRefPtr<WaitUntilObserver> create(ExecutionContext*, EventType, int eventID);
~WaitUntilObserver();
void willDispatchEvent();
void didDispatchEvent();
void waitUntil(const ScriptValue&);
private:
class ThenFunction;
WaitUntilObserver(ExecutionContext*, EventType, int eventID);
void reportError(const ScriptValue&);
void incrementPendingActivity();
void decrementPendingActivity();
EventType m_type;
int m_eventID;
int m_pendingActivity;
bool m_hasError;
};
}
#endif