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.
29 #include "bindings/core/v8/ScriptValue.h"
30 #include "bindings/core/v8/ScriptWrappable.h"
31 #include "modules/indexeddb/IDBKey.h"
32 #include "modules/indexeddb/IDBRequest.h"
33 #include "modules/indexeddb/IndexedDB.h"
34 #include "public/platform/WebIDBCursor.h"
35 #include "public/platform/WebIDBTypes.h"
36 #include "wtf/PassRefPtr.h"
37 #include "wtf/RefPtr.h"
44 class ExecutionContext;
48 class IDBCursor : public GarbageCollectedFinalized<IDBCursor>, public ScriptWrappable {
49 DEFINE_WRAPPERTYPEINFO();
51 static WebIDBCursorDirection stringToDirection(const String& modeString, ExceptionState&);
53 static IDBCursor* create(PassOwnPtr<WebIDBCursor>, WebIDBCursorDirection, IDBRequest*, IDBAny* source, IDBTransaction*);
56 void contextWillBeDestroyed() { m_backend.clear(); }
59 const String& direction() const;
60 ScriptValue key(ScriptState*);
61 ScriptValue primaryKey(ScriptState*);
62 ScriptValue value(ScriptState*);
63 ScriptValue source(ScriptState*) const;
65 IDBRequest* update(ScriptState*, const ScriptValue&, ExceptionState&);
66 void advance(unsigned long, ExceptionState&);
67 void continueFunction(ScriptState*, const ScriptValue& key, ExceptionState&);
68 void continuePrimaryKey(ScriptState*, const ScriptValue& key, const ScriptValue& primaryKey, ExceptionState&);
69 IDBRequest* deleteFunction(ScriptState*, ExceptionState&);
71 bool isKeyDirty() const { return m_keyDirty; }
72 bool isPrimaryKeyDirty() const { return m_primaryKeyDirty; }
73 bool isValueDirty() const { return m_valueDirty; }
75 void continueFunction(IDBKey*, IDBKey* primaryKey, ExceptionState&);
76 void postSuccessHandlerCallback();
77 bool isDeleted() const;
79 void setValueReady(IDBKey*, IDBKey* primaryKey, PassRefPtr<SharedBuffer> value, PassOwnPtr<Vector<WebBlobInfo> >);
80 IDBKey* idbPrimaryKey() const { return m_primaryKey; }
81 IDBRequest* request() const { return m_request.get(); }
82 virtual bool isKeyCursor() const { return true; }
83 virtual bool isCursorWithValue() const { return false; }
86 IDBCursor(PassOwnPtr<WebIDBCursor>, WebIDBCursorDirection, IDBRequest*, IDBAny* source, IDBTransaction*);
89 IDBObjectStore* effectiveObjectStore() const;
90 void handleBlobAcks();
92 OwnPtr<WebIDBCursor> m_backend;
93 Member<IDBRequest> m_request;
94 const WebIDBCursorDirection m_direction;
95 Member<IDBAny> m_source;
96 Member<IDBTransaction> m_transaction;
99 bool m_primaryKeyDirty;
101 Member<IDBKey> m_key;
102 Member<IDBKey> m_primaryKey;
103 RefPtr<SharedBuffer> m_value;
104 OwnPtr<Vector<WebBlobInfo> > m_blobInfo;
109 #endif // IDBCursor_h