18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/* 22daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch * Copyright (C) 2011 Google Inc. All rights reserved. 38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without 58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions 68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met: 78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer. 108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * documentation and/or other materials provided with the distribution. 138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 255af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 26db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block#ifndef IDBIndexBackendImpl_h 27db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block#define IDBIndexBackendImpl_h 285af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 29dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#if ENABLE(INDEXED_DATABASE) 308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch#include "IDBCursorBackendInterface.h" 3281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch#include "IDBIndexBackendInterface.h" 3381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore { 358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochclass IDBBackingStore; 375abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrickclass IDBKey; 38e8b154fd68f9b33be40a3590e58347f353835f5cSteve Blockclass IDBObjectStoreBackendImpl; 39a94275402997c11dd2e778633dacf4b7e630a35dBen Murdochclass ScriptExecutionContext; 40e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block 41db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Blockclass IDBIndexBackendImpl : public IDBIndexBackendInterface { 425af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkepublic: 432daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique) 445af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke { 452daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return adoptRef(new IDBIndexBackendImpl(backingStore, databaseId, objectStoreBackend, id, name, storeName, keyPath, unique)); 465af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke } 472daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& storeName, const String& keyPath, bool unique) 48a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch { 492daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return adoptRef(new IDBIndexBackendImpl(backingStore, databaseId, objectStoreBackend, name, storeName, keyPath, unique)); 50a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch } 51db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block virtual ~IDBIndexBackendImpl(); 525af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 53a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch int64_t id() const 54a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch { 55a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch ASSERT(m_id != InvalidId); 56a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch return m_id; 57a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch } 58a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch void setId(int64_t id) { m_id = id; } 5981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch bool hasValidId() const { return m_id != InvalidId; }; 60a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 615abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick bool addingKeyAllowed(IDBKey*); 625abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 63db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block // Implements IDBIndexBackendInterface. 645af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke virtual String name() { return m_name; } 6528040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu virtual String storeName() { return m_storeName; } 665af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke virtual String keyPath() { return m_keyPath; } 675af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke virtual bool unique() { return m_unique; } 685af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 69a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); 70a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual void openKeyCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); 71a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual void get(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); 72a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual void getKey(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); 7368513a70bcd92384395513322f1b801e7bf9c729Steve Block 745af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkeprivate: 752daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, const IDBObjectStoreBackendImpl*, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique); 762daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, const IDBObjectStoreBackendImpl*, const String& name, const String& storeName, const String& keyPath, bool unique); 77e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block 7881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKeyRange>, unsigned short direction, IDBCursorBackendInterface::CursorType, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>); 79a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch static void getInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKey>, bool getObject, PassRefPtr<IDBCallbacks>); 80a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 81a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch static const int64_t InvalidId = 0; 82a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 8381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch RefPtr<IDBBackingStore> m_backingStore; 845af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 852daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch int64_t m_databaseId; 862daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch const IDBObjectStoreBackendImpl* m_objectStoreBackend; 87e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block int64_t m_id; 885af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke String m_name; 8928040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu String m_storeName; 905af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke String m_keyPath; 915af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke bool m_unique; 925af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke}; 938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} // namespace WebCore 958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 965af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#endif 97dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 98db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block#endif // IDBIndexBackendImpl_h 99