#ifndef IDBCursor_h
#define IDBCursor_h
#if ENABLE(INDEXED_DATABASE)
#include "IDBKey.h"
#include "IDBTransaction.h"
#include "IndexedDB.h"
#include "ScriptWrappable.h"
#include <bindings/ScriptValue.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class DOMRequestState;
class IDBAny;
class IDBCallbacks;
class IDBCursorBackend;
class IDBRequest;
class ScriptExecutionContext;
typedef int ExceptionCode;
class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor> {
public:
static const AtomicString& directionNext();
static const AtomicString& directionNextUnique();
static const AtomicString& directionPrev();
static const AtomicString& directionPrevUnique();
static IndexedDB::CursorDirection stringToDirection(const String& modeString, ExceptionCode&);
static const AtomicString& directionToString(IndexedDB::CursorDirection mode);
static Ref<IDBCursor> create(PassRefPtr<IDBCursorBackend>, IndexedDB::CursorDirection, IDBRequest*, IDBAny* source, IDBTransaction*);
virtual ~IDBCursor();
const String& direction() const;
const Deprecated::ScriptValue& key() const;
const Deprecated::ScriptValue& primaryKey() const;
const Deprecated::ScriptValue& value() const;
IDBAny* source() const;
PassRefPtr<IDBRequest> update(JSC::ExecState*, Deprecated::ScriptValue&, ExceptionCode&);
void advance(unsigned long, ExceptionCode&);
void continueFunction(ScriptExecutionContext*, ExceptionCode& ec) { continueFunction(static_cast<IDBKey*>(nullptr), ec); }
void continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&);
PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&);
void continueFunction(PassRefPtr<IDBKey>, ExceptionCode&);
void postSuccessHandlerCallback();
void close();
void setValueReady(DOMRequestState*, PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, Deprecated::ScriptValue&);
PassRefPtr<IDBKey> idbPrimaryKey() { return m_currentPrimaryKey; }
protected:
IDBCursor(PassRefPtr<IDBCursorBackend>, IndexedDB::CursorDirection, IDBRequest*, IDBAny* source, IDBTransaction*);
virtual bool isKeyCursor() const { return true; }
private:
PassRefPtr<IDBObjectStore> effectiveObjectStore();
RefPtr<IDBCursorBackend> m_backend;
RefPtr<IDBRequest> m_request;
const IndexedDB::CursorDirection m_direction;
RefPtr<IDBAny> m_source;
RefPtr<IDBTransaction> m_transaction;
IDBTransaction::OpenCursorNotifier m_transactionNotifier;
bool m_gotValue;
Deprecated::ScriptValue m_currentKeyValue;
Deprecated::ScriptValue m_currentPrimaryKeyValue;
RefPtr<IDBKey> m_currentKey;
RefPtr<IDBKey> m_currentPrimaryKey;
Deprecated::ScriptValue m_currentValue;
};
}
#endif
#endif // IDBCursor_h