2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #ifndef IDBCursorBackend_h
28 #define IDBCursorBackend_h
30 #if ENABLE(INDEXED_DATABASE)
32 #include "IDBBackingStoreInterface.h"
33 #include "IDBDatabaseBackendImpl.h"
34 #include "IDBTransactionBackend.h"
35 #include "SharedBuffer.h"
36 #include <wtf/OwnPtr.h>
37 #include <wtf/PassOwnPtr.h>
38 #include <wtf/RefPtr.h>
44 class IDBCursorBackend : public RefCounted<IDBCursorBackend> {
46 static PassRefPtr<IDBCursorBackend> create(PassRefPtr<IDBBackingStoreCursorInterface> cursor, IndexedDB::CursorType cursorType, IDBTransactionBackend* transaction, int64_t objectStoreId)
48 return adoptRef(new IDBCursorBackend(cursor, cursorType, IDBDatabaseBackendInterface::NormalTask, transaction, objectStoreId));
50 static PassRefPtr<IDBCursorBackend> create(PassRefPtr<IDBBackingStoreCursorInterface> cursor, IndexedDB::CursorType cursorType, IDBDatabaseBackendInterface::TaskType taskType, IDBTransactionBackend* transaction, int64_t objectStoreId)
52 return adoptRef(new IDBCursorBackend(cursor, cursorType, taskType, transaction, objectStoreId));
56 void advance(unsigned long, PassRefPtr<IDBCallbacks>, ExceptionCode&);
57 void continueFunction(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, ExceptionCode&);
58 void deleteFunction(PassRefPtr<IDBCallbacks>, ExceptionCode&);
59 void prefetchContinue(int numberToFetch, PassRefPtr<IDBCallbacks>, ExceptionCode&);
60 void prefetchReset(int usedPrefetches, int unusedPrefetches);
61 void postSuccessHandlerCallback() { }
63 IDBKey* key() const { return m_cursor->key().get(); }
64 IDBKey* primaryKey() const { return m_cursor->primaryKey().get(); }
65 SharedBuffer* value() const { return (m_cursorType == IndexedDB::CursorKeyOnly) ? 0 : m_cursor->value().get(); }
70 IDBCursorBackend(PassRefPtr<IDBBackingStoreCursorInterface>, IndexedDB::CursorType, IDBDatabaseBackendInterface::TaskType, IDBTransactionBackend*, int64_t objectStoreId);
72 class CursorIterationOperation;
73 class CursorAdvanceOperation;
74 class CursorPrefetchIterationOperation;
76 IDBDatabaseBackendInterface::TaskType m_taskType;
77 IndexedDB::CursorType m_cursorType;
78 const RefPtr<IDBDatabaseBackendInterface> m_database;
79 RefPtr<IDBTransactionBackend> m_transaction;
80 const int64_t m_objectStoreId;
82 RefPtr<IDBBackingStoreCursorInterface> m_cursor; // Must be destroyed before m_transaction.
83 RefPtr<IDBBackingStoreCursorInterface> m_savedCursor; // Must be destroyed before m_transaction.
88 } // namespace WebCore
90 #endif // ENABLE(INDEXED_DATABASE)
92 #endif // IDBCursorBackend_h