1 /* 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 27 #ifndef IDBCursorBackendImpl_h 28 #define IDBCursorBackendImpl_h 29 30 #if ENABLE(INDEXED_DATABASE) 31 32 #include "IDBBackingStore.h" 33 #include "IDBCursor.h" 34 #include "IDBCursorBackendInterface.h" 35 #include <wtf/OwnPtr.h> 36 #include <wtf/PassOwnPtr.h> 37 #include <wtf/RefPtr.h> 38 39 namespace WebCore { 40 41 class IDBDatabaseBackendImpl; 42 class IDBIndexBackendImpl; 43 class IDBKeyRange; 44 class IDBObjectStoreBackendInterface; 45 class IDBBackingStore; 46 class IDBTransactionBackendInterface; 47 class SerializedScriptValue; 48 49 class IDBCursorBackendImpl : public IDBCursorBackendInterface { 50 public: create(PassRefPtr<IDBBackingStore::Cursor> cursor,IDBCursor::Direction direction,CursorType cursorType,IDBTransactionBackendInterface * transaction,IDBObjectStoreBackendInterface * objectStore)51 static PassRefPtr<IDBCursorBackendImpl> create(PassRefPtr<IDBBackingStore::Cursor> cursor, IDBCursor::Direction direction, CursorType cursorType, IDBTransactionBackendInterface* transaction, IDBObjectStoreBackendInterface* objectStore) 52 { 53 return adoptRef(new IDBCursorBackendImpl(cursor, direction, cursorType, transaction, objectStore)); 54 } 55 virtual ~IDBCursorBackendImpl(); 56 57 virtual unsigned short direction() const; 58 virtual PassRefPtr<IDBKey> key() const; 59 virtual PassRefPtr<IDBKey> primaryKey() const; 60 virtual PassRefPtr<SerializedScriptValue> value() const; 61 virtual void update(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBCallbacks>, ExceptionCode&); 62 virtual void continueFunction(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, ExceptionCode&); 63 virtual void deleteFunction(PassRefPtr<IDBCallbacks>, ExceptionCode&); 64 65 private: 66 IDBCursorBackendImpl(PassRefPtr<IDBBackingStore::Cursor>, IDBCursor::Direction, CursorType, IDBTransactionBackendInterface*, IDBObjectStoreBackendInterface*); 67 68 static void continueFunctionInternal(ScriptExecutionContext*, PassRefPtr<IDBCursorBackendImpl>, PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>); 69 70 RefPtr<IDBBackingStore::Cursor> m_cursor; 71 IDBCursor::Direction m_direction; 72 CursorType m_cursorType; 73 RefPtr<IDBTransactionBackendInterface> m_transaction; 74 RefPtr<IDBObjectStoreBackendInterface> m_objectStore; 75 }; 76 77 } // namespace WebCore 78 79 #endif // ENABLE(INDEXED_DATABASE) 80 81 #endif // IDBCursorBackendImpl_h 82