initial import
[vuplus_webkit] / Source / WebCore / storage / IDBCursorBackendImpl.h
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:
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     void close();
65
66 private:
67     IDBCursorBackendImpl(PassRefPtr<IDBBackingStore::Cursor>, IDBCursor::Direction, CursorType, IDBTransactionBackendInterface*, IDBObjectStoreBackendInterface*);
68
69     static void continueFunctionInternal(ScriptExecutionContext*, PassRefPtr<IDBCursorBackendImpl>, PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>);
70
71     RefPtr<IDBBackingStore::Cursor> m_cursor;
72     IDBCursor::Direction m_direction;
73     CursorType m_cursorType;
74     RefPtr<IDBTransactionBackendInterface> m_transaction;
75     RefPtr<IDBObjectStoreBackendInterface> m_objectStore;
76 };
77
78 } // namespace WebCore
79
80 #endif // ENABLE(INDEXED_DATABASE)
81
82 #endif // IDBCursorBackendImpl_h