blob: 7345880324e03590bd21eec14093196ac807002b [file] [log] [blame]
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LegacyIndex_h
#define LegacyIndex_h
#include "IDBCursor.h"
#include "IDBDatabase.h"
#include "IDBDatabaseMetadata.h"
#include "IDBKeyPath.h"
#include "IDBKeyRange.h"
#include "IDBRequest.h"
#include "LegacyAny.h"
#include "LegacyObjectStore.h"
#include "LegacyRequest.h"
#include "LegacyTransaction.h"
#include "ScriptWrappable.h"
#include <wtf/Forward.h>
#include <wtf/text/WTFString.h>
#if ENABLE(INDEXED_DATABASE)
namespace WebCore {
class IDBObjectStore;
class LegacyIndex : public ScriptWrappable, public IDBIndex {
public:
static Ref<LegacyIndex> create(const IDBIndexMetadata& metadata, LegacyObjectStore* objectStore, LegacyTransaction* transaction)
{
return adoptRef(*new LegacyIndex(metadata, objectStore, transaction));
}
~LegacyIndex();
// Implement the IDL
virtual const String name() const override final { return m_metadata.name; }
virtual PassRefPtr<IDBObjectStore> objectStore() const override final { return m_objectStore; }
PassRefPtr<LegacyObjectStore> legacyObjectStore() const { return m_objectStore; }
virtual PassRefPtr<IDBAny> keyPathAny() const override final { return LegacyAny::create(m_metadata.keyPath); }
virtual const IDBKeyPath keyPath() const override final { return m_metadata.keyPath; }
virtual bool unique() const override final { return m_metadata.unique; }
virtual bool multiEntry() const override final { return m_metadata.multiEntry; }
virtual int64_t id() const override final { return m_metadata.id; }
// FIXME: Try to modify the code generator so this is unneeded.
virtual PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) override final { return openCursor(context, static_cast<IDBKeyRange*>(nullptr), ec); }
virtual PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) override final { return openCursor(context, keyRange, IDBCursor::directionNext(), ec); }
virtual PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCode& ec) override final { return openCursor(context, key, IDBCursor::directionNext(), ec); }
virtual PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, const String& direction, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> count(ScriptExecutionContext* context, ExceptionCode& ec) override final { return count(context, static_cast<IDBKeyRange*>(nullptr), ec); }
virtual PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> count(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, ExceptionCode& ec) override final { return openKeyCursor(context, static_cast<IDBKeyRange*>(nullptr), ec); }
virtual PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) override final { return openKeyCursor(context, keyRange, IDBCursor::directionNext(), ec); }
virtual PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCode& ec) override final { return openKeyCursor(context, key, IDBCursor::directionNext(), ec); }
virtual PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, const String& direction, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext*, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> get(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> getKey(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&) override final;
virtual PassRefPtr<IDBRequest> getKey(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
void markDeleted() { m_deleted = true; }
IDBDatabaseBackend* backendDB() const;
private:
LegacyIndex(const IDBIndexMetadata&, LegacyObjectStore*, LegacyTransaction*);
IDBIndexMetadata m_metadata;
RefPtr<LegacyObjectStore> m_objectStore;
RefPtr<LegacyTransaction> m_transaction;
bool m_deleted;
};
} // namespace WebCore
#endif
#endif // LegacyIndex_h