#ifndef IDBIndex_h
#define IDBIndex_h
#include "bindings/v8/ScriptWrappable.h"
#include "modules/indexeddb/IDBCursor.h"
#include "modules/indexeddb/IDBKeyPath.h"
#include "modules/indexeddb/IDBKeyRange.h"
#include "modules/indexeddb/IDBMetadata.h"
#include "modules/indexeddb/IDBRequest.h"
#include "public/platform/WebIDBCursor.h"
#include "public/platform/WebIDBDatabase.h"
#include "wtf/Forward.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class ExceptionState;
class IDBObjectStore;
class IDBIndex : public ScriptWrappable, public RefCounted<IDBIndex> {
public:
static PassRefPtr<IDBIndex> create(const IDBIndexMetadata& metadata, IDBObjectStore* objectStore, IDBTransaction* transaction)
{
return adoptRef(new IDBIndex(metadata, objectStore, transaction));
}
~IDBIndex();
const String& name() const { return m_metadata.name; }
PassRefPtr<IDBObjectStore> objectStore() const { return m_objectStore; }
ScriptValue keyPath(ExecutionContext*) const;
bool unique() const { return m_metadata.unique; }
bool multiEntry() const { return m_metadata.multiEntry; }
PassRefPtr<IDBRequest> openCursor(ExecutionContext*, const ScriptValue& key, const String& direction, ExceptionState&);
PassRefPtr<IDBRequest> openKeyCursor(ExecutionContext*, const ScriptValue& range, const String& direction, ExceptionState&);
PassRefPtr<IDBRequest> count(ExecutionContext*, const ScriptValue& range, ExceptionState&);
PassRefPtr<IDBRequest> get(ExecutionContext*, const ScriptValue& key, ExceptionState&);
PassRefPtr<IDBRequest> getKey(ExecutionContext*, const ScriptValue& key, ExceptionState&);
void markDeleted() { m_deleted = true; }
bool isDeleted() const;
PassRefPtr<IDBRequest> openCursor(ExecutionContext*, PassRefPtr<IDBKeyRange>, blink::WebIDBCursor::Direction);
blink::WebIDBDatabase* backendDB() const;
private:
IDBIndex(const IDBIndexMetadata&, IDBObjectStore*, IDBTransaction*);
PassRefPtr<IDBRequest> getInternal(ExecutionContext*, const ScriptValue& key, ExceptionState&, bool keyOnly);
IDBIndexMetadata m_metadata;
RefPtr<IDBObjectStore> m_objectStore;
RefPtr<IDBTransaction> m_transaction;
bool m_deleted;
};
}
#endif