| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "modules/indexeddb/IDBKey.h" | 31 #include "modules/indexeddb/IDBKey.h" |
| 32 #include "modules/indexeddb/IDBRequest.h" | 32 #include "modules/indexeddb/IDBRequest.h" |
| 33 #include "modules/indexeddb/IndexedDB.h" | 33 #include "modules/indexeddb/IndexedDB.h" |
| 34 #include "public/platform/WebIDBCursor.h" | 34 #include "public/platform/WebIDBCursor.h" |
| 35 #include "public/platform/WebIDBTypes.h" | 35 #include "public/platform/WebIDBTypes.h" |
| 36 #include "wtf/PassRefPtr.h" | 36 #include "wtf/PassRefPtr.h" |
| 37 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class WebBlobInfo; | |
| 42 | |
| 43 } // namespace blink | |
| 44 | |
| 45 namespace blink { | |
| 46 | |
| 47 class ExceptionState; | 41 class ExceptionState; |
| 48 class IDBAny; | 42 class IDBAny; |
| 49 class IDBTransaction; | 43 class IDBTransaction; |
| 50 class ExecutionContext; | 44 class ExecutionContext; |
| 51 class SharedBuffer; | 45 class SharedBuffer; |
| 46 class WebBlobInfo; |
| 52 | 47 |
| 53 class IDBCursor : public GarbageCollectedFinalized<IDBCursor>, public ScriptWrap
pable { | 48 class IDBCursor : public GarbageCollectedFinalized<IDBCursor>, public ScriptWrap
pable { |
| 54 public: | 49 public: |
| 55 static const AtomicString& directionNext(); | 50 static const AtomicString& directionNext(); |
| 56 static const AtomicString& directionNextUnique(); | 51 static const AtomicString& directionNextUnique(); |
| 57 static const AtomicString& directionPrev(); | 52 static const AtomicString& directionPrev(); |
| 58 static const AtomicString& directionPrevUnique(); | 53 static const AtomicString& directionPrevUnique(); |
| 59 | 54 |
| 60 static blink::WebIDBCursorDirection stringToDirection(const String& modeStri
ng, ExceptionState&); | 55 static WebIDBCursorDirection stringToDirection(const String& modeString, Exc
eptionState&); |
| 61 static const AtomicString& directionToString(unsigned short mode); | 56 static const AtomicString& directionToString(unsigned short mode); |
| 62 | 57 |
| 63 static IDBCursor* create(PassOwnPtr<blink::WebIDBCursor>, blink::WebIDBCurso
rDirection, IDBRequest*, IDBAny* source, IDBTransaction*); | 58 static IDBCursor* create(PassOwnPtr<WebIDBCursor>, WebIDBCursorDirection, ID
BRequest*, IDBAny* source, IDBTransaction*); |
| 64 virtual ~IDBCursor(); | 59 virtual ~IDBCursor(); |
| 65 void trace(Visitor*); | 60 void trace(Visitor*); |
| 66 void contextWillBeDestroyed() { m_backend.clear(); } | 61 void contextWillBeDestroyed() { m_backend.clear(); } |
| 67 | 62 |
| 68 // Implement the IDL | 63 // Implement the IDL |
| 69 const String& direction() const { return directionToString(m_direction); } | 64 const String& direction() const { return directionToString(m_direction); } |
| 70 ScriptValue key(ScriptState*); | 65 ScriptValue key(ScriptState*); |
| 71 ScriptValue primaryKey(ScriptState*); | 66 ScriptValue primaryKey(ScriptState*); |
| 72 ScriptValue value(ScriptState*); | 67 ScriptValue value(ScriptState*); |
| 73 ScriptValue source(ScriptState*) const; | 68 ScriptValue source(ScriptState*) const; |
| 74 | 69 |
| 75 IDBRequest* update(ScriptState*, ScriptValue&, ExceptionState&); | 70 IDBRequest* update(ScriptState*, ScriptValue&, ExceptionState&); |
| 76 void advance(unsigned long, ExceptionState&); | 71 void advance(unsigned long, ExceptionState&); |
| 77 void continueFunction(ScriptState*, const ScriptValue& key, ExceptionState&)
; | 72 void continueFunction(ScriptState*, const ScriptValue& key, ExceptionState&)
; |
| 78 void continuePrimaryKey(ScriptState*, const ScriptValue& key, const ScriptVa
lue& primaryKey, ExceptionState&); | 73 void continuePrimaryKey(ScriptState*, const ScriptValue& key, const ScriptVa
lue& primaryKey, ExceptionState&); |
| 79 IDBRequest* deleteFunction(ScriptState*, ExceptionState&); | 74 IDBRequest* deleteFunction(ScriptState*, ExceptionState&); |
| 80 | 75 |
| 81 bool isKeyDirty() const { return m_keyDirty; } | 76 bool isKeyDirty() const { return m_keyDirty; } |
| 82 bool isPrimaryKeyDirty() const { return m_primaryKeyDirty; } | 77 bool isPrimaryKeyDirty() const { return m_primaryKeyDirty; } |
| 83 bool isValueDirty() const { return m_valueDirty; } | 78 bool isValueDirty() const { return m_valueDirty; } |
| 84 | 79 |
| 85 void continueFunction(IDBKey*, IDBKey* primaryKey, ExceptionState&); | 80 void continueFunction(IDBKey*, IDBKey* primaryKey, ExceptionState&); |
| 86 void postSuccessHandlerCallback(); | 81 void postSuccessHandlerCallback(); |
| 87 bool isDeleted() const; | 82 bool isDeleted() const; |
| 88 void close(); | 83 void close(); |
| 89 void setValueReady(IDBKey*, IDBKey* primaryKey, PassRefPtr<SharedBuffer> val
ue, PassOwnPtr<Vector<blink::WebBlobInfo> >); | 84 void setValueReady(IDBKey*, IDBKey* primaryKey, PassRefPtr<SharedBuffer> val
ue, PassOwnPtr<Vector<WebBlobInfo> >); |
| 90 IDBKey* idbPrimaryKey() const { return m_primaryKey; } | 85 IDBKey* idbPrimaryKey() const { return m_primaryKey; } |
| 91 IDBRequest* request() const { return m_request.get(); } | 86 IDBRequest* request() const { return m_request.get(); } |
| 92 virtual bool isKeyCursor() const { return true; } | 87 virtual bool isKeyCursor() const { return true; } |
| 93 virtual bool isCursorWithValue() const { return false; } | 88 virtual bool isCursorWithValue() const { return false; } |
| 94 | 89 |
| 95 protected: | 90 protected: |
| 96 IDBCursor(PassOwnPtr<blink::WebIDBCursor>, blink::WebIDBCursorDirection, IDB
Request*, IDBAny* source, IDBTransaction*); | 91 IDBCursor(PassOwnPtr<WebIDBCursor>, WebIDBCursorDirection, IDBRequest*, IDBA
ny* source, IDBTransaction*); |
| 97 | 92 |
| 98 private: | 93 private: |
| 99 IDBObjectStore* effectiveObjectStore() const; | 94 IDBObjectStore* effectiveObjectStore() const; |
| 100 void handleBlobAcks(); | 95 void handleBlobAcks(); |
| 101 | 96 |
| 102 OwnPtr<blink::WebIDBCursor> m_backend; | 97 OwnPtr<WebIDBCursor> m_backend; |
| 103 Member<IDBRequest> m_request; | 98 Member<IDBRequest> m_request; |
| 104 const blink::WebIDBCursorDirection m_direction; | 99 const WebIDBCursorDirection m_direction; |
| 105 Member<IDBAny> m_source; | 100 Member<IDBAny> m_source; |
| 106 Member<IDBTransaction> m_transaction; | 101 Member<IDBTransaction> m_transaction; |
| 107 bool m_gotValue; | 102 bool m_gotValue; |
| 108 bool m_keyDirty; | 103 bool m_keyDirty; |
| 109 bool m_primaryKeyDirty; | 104 bool m_primaryKeyDirty; |
| 110 bool m_valueDirty; | 105 bool m_valueDirty; |
| 111 Member<IDBKey> m_key; | 106 Member<IDBKey> m_key; |
| 112 Member<IDBKey> m_primaryKey; | 107 Member<IDBKey> m_primaryKey; |
| 113 RefPtr<SharedBuffer> m_value; | 108 RefPtr<SharedBuffer> m_value; |
| 114 OwnPtr<Vector<blink::WebBlobInfo> > m_blobInfo; | 109 OwnPtr<Vector<WebBlobInfo> > m_blobInfo; |
| 115 }; | 110 }; |
| 116 | 111 |
| 117 } // namespace blink | 112 } // namespace blink |
| 118 | 113 |
| 119 #endif // IDBCursor_h | 114 #endif // IDBCursor_h |
| OLD | NEW |