Changeset 117817 in webkit
- Timestamp:
- May 21, 2012 2:34:39 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 63 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r117816 r117817 1 2012-05-21 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: Store key paths in IDBKeyPath type instead of String 4 https://bugs.webkit.org/show_bug.cgi?id=85298 5 6 Reviewed by Tony Chang, Kentaro Hara and James Robinson. 7 8 * storage/indexeddb/keypath-basics-expected.txt: 9 * storage/indexeddb/resources/keypath-basics.js: 10 1 11 2012-05-21 Joshua Bell <jsbell@chromium.org> 2 12 -
trunk/LayoutTests/storage/indexeddb/keypath-basics-expected.txt
r114672 r117817 10 10 request = db.setVersion('1') 11 11 Deleted all object stores. 12 globalKeyPath = 'null' 13 db.createObjectStore('name', {keyPath: globalKeyPath}) 12 store = db.createObjectStore('name') 13 PASS store.keyPath is null 14 14 Deleted all object stores. 15 globalKeyPath = 'undefined' 16 db.createObjectStore('name', {keyPath: globalKeyPath}) 15 store = db.createObjectStore('name', {keyPath: null}) 16 PASS store.keyPath is null 17 index = store.createIndex('name', null) 18 PASS index.keyPath is 'null' 17 19 Deleted all object stores. 18 globalKeyPath = '' 19 db.createObjectStore('name', {keyPath: globalKeyPath}) 20 store = db.createObjectStore('name', {keyPath: undefined}) 21 PASS store.keyPath is null 22 index = store.createIndex('name', undefined) 23 PASS index.keyPath is 'undefined' 20 24 Deleted all object stores. 21 globalKeyPath = 'foo' 22 db.createObjectStore('name', {keyPath: globalKeyPath}) 25 store = db.createObjectStore('name', {keyPath: ''}) 26 PASS store.keyPath is '' 27 index = store.createIndex('name', '') 28 PASS index.keyPath is '' 23 29 Deleted all object stores. 24 globalKeyPath = 'foo.bar.baz' 25 db.createObjectStore('name', {keyPath: globalKeyPath}) 30 store = db.createObjectStore('name', {keyPath: 'foo'}) 31 PASS store.keyPath is 'foo' 32 index = store.createIndex('name', 'foo') 33 PASS index.keyPath is 'foo' 26 34 Deleted all object stores. 27 globalKeyPath = 'null' 28 store = db.createObjectStore('storeName') 29 store.createIndex('name', globalKeyPath) 30 Deleted all object stores. 31 globalKeyPath = 'undefined' 32 store = db.createObjectStore('storeName') 33 store.createIndex('name', globalKeyPath) 34 Deleted all object stores. 35 globalKeyPath = '' 36 store = db.createObjectStore('storeName') 37 store.createIndex('name', globalKeyPath) 38 Deleted all object stores. 39 globalKeyPath = 'foo' 40 store = db.createObjectStore('storeName') 41 store.createIndex('name', globalKeyPath) 42 Deleted all object stores. 43 globalKeyPath = 'foo.bar.baz' 44 store = db.createObjectStore('storeName') 45 store.createIndex('name', globalKeyPath) 35 store = db.createObjectStore('name', {keyPath: 'foo.bar.baz'}) 36 PASS store.keyPath is 'foo.bar.baz' 37 index = store.createIndex('name', 'foo.bar.baz') 38 PASS index.keyPath is 'foo.bar.baz' 46 39 Deleted all object stores. 47 40 Deleted all object stores. -
trunk/LayoutTests/storage/indexeddb/resources/keypath-basics.js
r114672 r117817 28 28 deleteAllObjectStores(db); 29 29 30 testKeyPaths = [null, undefined, '']; 31 testKeyPaths.forEach(function (keyPath) { 32 globalKeyPath = keyPath; 33 debug("globalKeyPath = '" + globalKeyPath + "'"); 34 evalAndLog("db.createObjectStore('name', {keyPath: globalKeyPath})"); 35 deleteAllObjectStores(db); 36 }); 30 evalAndLog("store = db.createObjectStore('name')"); 31 shouldBeNull("store.keyPath"); 32 deleteAllObjectStores(db); 37 33 38 testKeyPaths = [ 'foo', 'foo.bar.baz'];39 testKeyPaths.forEach(function (keyPath) {40 globalKeyPath = keyPath;41 debug("globalKeyPath = '" + globalKeyPath + "'");42 evalAndLog("db.createObjectStore('name', {keyPath: globalKeyPath})");43 deleteAllObjectStores(db);44 });34 testKeyPaths = [ 35 { keyPath: "null", storeExpected: "null", indexExpected: "'null'" }, 36 { keyPath: "undefined", storeExpected: "null", indexExpected: "'undefined'" }, 37 { keyPath: "''", storeExpected: "''", indexExpected: "''" }, 38 { keyPath: "'foo'", storeExpected: "'foo'", indexExpected: "'foo'" }, 39 { keyPath: "'foo.bar.baz'", storeExpected: "'foo.bar.baz'", indexExpected: "'foo.bar.baz'" } 40 ]; 45 41 46 testKeyPaths = [null, undefined, '', 'foo', 'foo.bar.baz']; 47 testKeyPaths.forEach(function (keyPath) { 48 globalKeyPath = keyPath; 49 debug("globalKeyPath = '" + globalKeyPath + "'"); 50 store = evalAndLog("store = db.createObjectStore('storeName')"); 51 evalAndLog("store.createIndex('name', globalKeyPath)"); 42 testKeyPaths.forEach(function (testCase) { 43 evalAndLog("store = db.createObjectStore('name', {keyPath: " + testCase.keyPath + "})"); 44 shouldBe("store.keyPath", testCase.storeExpected); 45 evalAndLog("index = store.createIndex('name', " + testCase.keyPath + ")"); 46 shouldBe("index.keyPath", testCase.indexExpected); 52 47 deleteAllObjectStores(db); 53 48 }); -
trunk/Source/WebCore/ChangeLog
r117814 r117817 1 2012-05-21 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: Store key paths in IDBKeyPath type instead of String 4 https://bugs.webkit.org/show_bug.cgi?id=85298 5 6 Reviewed by Tony Chang, Kentaro Hara and James Robinson. 7 8 Migrate from storing key paths as (nullable) Strings to a dedicated IDBKeyPath 9 type. Prep work for supporting array-type key paths: http://webkit.org/b/84207 10 11 Only functional change is handling of null/undefined parameters for key paths, 12 to align with IDB spec, covered by layout test. 13 14 Test: storage/indexeddb/keypath-basics.html 15 Test: WebKit/chromium/IDBLevelDBCodingTest.cpp 16 17 * Modules/indexeddb/IDBAny.cpp: Allow IDBAny to yield DOMStrings. 18 (WebCore::IDBAny::createString): 19 (WebCore): 20 (WebCore::IDBAny::string): 21 (WebCore::IDBAny::set): 22 * Modules/indexeddb/IDBAny.h: 23 (IDBAny): 24 * Modules/indexeddb/IDBBackingStore.h: Switch from String to IDBKeyPath. 25 (IDBBackingStore): 26 * Modules/indexeddb/IDBDatabase.cpp: Switch from String to IDBKeyPath. 27 (WebCore::IDBDatabase::createObjectStore): 28 * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: Switch from String to IDBKeyPath. 29 (WebCore::IDBDatabaseBackendImpl::createObjectStore): 30 (WebCore::IDBDatabaseBackendImpl::loadObjectStores): 31 * Modules/indexeddb/IDBDatabaseBackendImpl.h: Switch from String to IDBKeyPath. 32 (IDBDatabaseBackendImpl): 33 * Modules/indexeddb/IDBDatabaseBackendInterface.h: Switch from String to IDBKeyPath. 34 (WebCore): 35 (IDBDatabaseBackendInterface): 36 * Modules/indexeddb/IDBIndex.h: Switch from String to IDBAny (via IDBKeyPath). 37 (WebCore::IDBIndex::keyPath): 38 * Modules/indexeddb/IDBIndex.idl: Switch from DOMString? to IDBAny. 39 * Modules/indexeddb/IDBIndexBackendImpl.cpp: Switch from String to IDBKeyPath. 40 (WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl): 41 * Modules/indexeddb/IDBIndexBackendImpl.h: Switch from String to IDBKeyPath. 42 (WebCore::IDBIndexBackendImpl::create): 43 (WebCore::IDBIndexBackendImpl::keyPath): 44 (IDBIndexBackendImpl): 45 * Modules/indexeddb/IDBIndexBackendInterface.h: Switch from String to IDBKeyPath. 46 (WebCore): 47 (IDBIndexBackendInterface): 48 * Modules/indexeddb/IDBKeyPath.cpp: Non-trivial method implementations. 49 (WebCore::IDBKeyPath::isValid): 50 (WebCore): 51 (WebCore::IDBKeyPath::operator PassRefPtr<IDBAny>): 52 * Modules/indexeddb/IDBKeyPath.h: Introduce IDBKeyPath type. 53 (IDBKeyPath): 54 (WebCore::IDBKeyPath::IDBKeyPath): 55 (WebCore::IDBKeyPath::type): 56 (WebCore::IDBKeyPath::array): 57 (WebCore::IDBKeyPath::string): 58 (WebCore::IDBKeyPath::isNull): 59 (WebCore): 60 * Modules/indexeddb/IDBKeyPathBackendImpl.cpp: Switch from String to IDBKeyPath. 61 (WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath): 62 (WebCore::IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue): 63 * Modules/indexeddb/IDBKeyPathBackendImpl.h: Switch from String to IDBKeyPath. 64 (WebCore): 65 (IDBKeyPathBackendImpl): 66 * Modules/indexeddb/IDBLevelDBBackingStore.cpp: Switch from String to IDBKeyPath, with back-compat. 67 (WebCore): 68 (WebCore::putIDBKeyPath): 69 (WebCore::IDBLevelDBBackingStore::getObjectStores): 70 (WebCore::IDBLevelDBBackingStore::createObjectStore): 71 (WebCore::IDBLevelDBBackingStore::getIndexes): 72 (WebCore::IDBLevelDBBackingStore::createIndex): 73 * Modules/indexeddb/IDBLevelDBBackingStore.h: 74 (IDBLevelDBBackingStore): 75 * Modules/indexeddb/IDBLevelDBCoding.cpp: New coding scheme for key paths (with back-compat). 76 (IDBLevelDBCoding): 77 (WebCore::IDBLevelDBCoding::encodeIDBKeyPath): 78 (WebCore::IDBLevelDBCoding::decodeIDBKeyPath): 79 * Modules/indexeddb/IDBLevelDBCoding.h: Add key-path-specific methods. 80 (WebCore): 81 (IDBLevelDBCoding): 82 * Modules/indexeddb/IDBObjectStore.cpp: Switch from String to IDBKeyPath. 83 (WebCore::IDBObjectStore::keyPath): 84 (WebCore::IDBObjectStore::createIndex): 85 (WebCore): 86 * Modules/indexeddb/IDBObjectStore.h: Switch from String to IDBAny (via IDBKeyPath). 87 (IDBObjectStore): 88 * Modules/indexeddb/IDBObjectStore.idl: Switch from DOMString? to IDBAny. 89 * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp: Switch from String to IDBKeyPath. 90 (WebCore::IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl): 91 (WebCore::fetchKeyFromKeyPath): 92 (WebCore::injectKeyIntoKeyPath): 93 (WebCore::IDBObjectStoreBackendImpl::createIndex): 94 (WebCore::IDBObjectStoreBackendImpl::loadIndexes): 95 * Modules/indexeddb/IDBObjectStoreBackendImpl.h: Switch from String to IDBKeyPath. 96 (WebCore::IDBObjectStoreBackendImpl::create): 97 (WebCore::IDBObjectStoreBackendImpl::keyPath): 98 (IDBObjectStoreBackendImpl): 99 * Modules/indexeddb/IDBObjectStoreBackendInterface.h: Switch from String to IDBKeyPath. 100 (WebCore): 101 (IDBObjectStoreBackendInterface): 102 * bindings/v8/Dictionary.cpp: Add getter for DOMString[] (i.e. Vector<String>) 103 (WebCore): 104 (WebCore::Dictionary::get): 105 * bindings/v8/Dictionary.h: 106 (Dictionary): 107 * bindings/v8/IDBBindingUtilities.cpp: Switch from String to IDBKeyPath. 108 (WebCore::createIDBKeyFromSerializedValueAndKeyPath): 109 (WebCore::injectIDBKeyIntoSerializedValue): 110 * bindings/v8/IDBBindingUtilities.h: Switch from String to IDBKeyPath. 111 (WebCore): 112 * bindings/v8/custom/V8IDBAnyCustom.cpp: Support String/DOMString. 113 (WebCore::toV8): 114 * dom/DOMStringList.h: Allow easy (const) access to strings. 115 (WebCore::DOMStringList::operator const Vector<String>&): 116 (DOMStringList): 117 * inspector/InspectorIndexedDBAgent.cpp: Temporary shim for non-strings: see http://webkit.org/b/84303 118 (WebCore): 119 * platform/chromium/PlatformSupport.h: Switch from String to IDBKeyPath. 120 (WebCore): 121 (PlatformSupport): 122 * storage/chromium/IDBKeyPathBackendImpl.cpp: Switch from String to IDBKeyPath. 123 (WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath): 124 (WebCore::IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue): 125 1 126 2012-05-21 Zhenyao Mo <zmo@google.com> 2 127 -
trunk/Source/WebCore/Modules/indexeddb/IDBAny.cpp
r109493 r117817 50 50 } 51 51 52 PassRefPtr<IDBAny> IDBAny::createString(const String& value) 53 { 54 RefPtr<IDBAny> idbAny = adoptRef(new IDBAny()); 55 idbAny->set(value); 56 return idbAny.release(); 57 } 58 52 59 IDBAny::IDBAny() 53 60 : m_type(UndefinedType) … … 119 126 } 120 127 128 const String& IDBAny::string() 129 { 130 ASSERT(m_type == StringType); 131 return m_string; 132 } 133 121 134 void IDBAny::setNull() 122 135 { … … 195 208 } 196 209 210 void IDBAny::set(const String& value) 211 { 212 ASSERT(m_type == UndefinedType); 213 m_type = StringType; 214 m_string = value; 215 } 216 197 217 } // namespace WebCore 198 218 -
trunk/Source/WebCore/Modules/indexeddb/IDBAny.h
r109493 r117817 29 29 #if ENABLE(INDEXED_DATABASE) 30 30 31 #include "PlatformString.h" 31 32 #include <wtf/PassRefPtr.h> 32 33 #include <wtf/RefCounted.h> … … 50 51 static PassRefPtr<IDBAny> createInvalid(); 51 52 static PassRefPtr<IDBAny> createNull(); 53 static PassRefPtr<IDBAny> createString(const String&); 52 54 template<typename T> 53 55 static PassRefPtr<IDBAny> create(T* idbObject) … … 78 80 IDBObjectStoreType, 79 81 IDBTransactionType, 80 SerializedScriptValueType 82 SerializedScriptValueType, 83 StringType, 81 84 }; 82 85 … … 93 96 PassRefPtr<IDBTransaction> idbTransaction(); 94 97 PassRefPtr<SerializedScriptValue> serializedScriptValue(); 98 const String& string(); 95 99 96 100 // Set can only be called once. … … 106 110 void set(PassRefPtr<IDBTransaction>); 107 111 void set(PassRefPtr<SerializedScriptValue>); 112 void set(const String&); 108 113 109 114 private: … … 123 128 RefPtr<IDBTransaction> m_idbTransaction; 124 129 RefPtr<SerializedScriptValue> m_serializedScriptValue; 130 String m_string; 125 131 }; 126 132 -
trunk/Source/WebCore/Modules/indexeddb/IDBBackingStore.h
r116562 r117817 53 53 virtual bool deleteDatabase(const String& name) = 0; 54 54 55 virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector< String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) = 0;56 virtual bool createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) = 0;55 virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) = 0; 56 virtual bool createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath&, bool autoIncrement, int64_t& assignedObjectStoreId) = 0; 57 57 virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId) = 0; 58 58 … … 78 78 virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) = 0; 79 79 80 virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector< String>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags) = 0;81 virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId) = 0;80 virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags) = 0; 81 virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry, int64_t& indexId) = 0; 82 82 virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId) = 0; 83 83 virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) = 0; -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
r116337 r117817 93 93 } 94 94 95 String keyPath; 96 bool keyPathExists = options.getWithUndefinedOrNullCheck("keyPath", keyPath); 97 if (keyPathExists && !IDBIsValidKeyPath(keyPath)) { 95 IDBKeyPath keyPath; 96 if (!options.isUndefinedOrNull()) { 97 String keyPathString; 98 if (options.getWithUndefinedOrNullCheck("keyPath", keyPathString)) 99 keyPath = IDBKeyPath(keyPathString); 100 } 101 102 if (!keyPath.isNull() && !keyPath.isValid()) { 98 103 ec = IDBDatabaseException::NON_TRANSIENT_ERR; 99 104 return 0; -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
r113622 r117817 138 138 } 139 139 140 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)140 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(const String& name, const IDBKeyPath& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec) 141 141 { 142 142 ASSERT(transactionPtr->mode() == IDBTransaction::VERSION_CHANGE); … … 377 377 Vector<int64_t> ids; 378 378 Vector<String> names; 379 Vector< String> keyPaths;379 Vector<IDBKeyPath> keyPaths; 380 380 Vector<bool> autoIncrementFlags; 381 381 m_backingStore->getObjectStores(m_id, ids, names, keyPaths, autoIncrementFlags); -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h
r110539 r117817 66 66 virtual PassRefPtr<DOMStringList> objectStoreNames() const; 67 67 68 virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&);68 virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&); 69 69 virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&); 70 70 virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, ExceptionCode&); -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h
r109493 r117817 39 39 class IDBCallbacks; 40 40 class IDBDatabaseCallbacks; 41 class IDBKeyPath; 41 42 class IDBObjectStoreBackendInterface; 42 43 class IDBTransactionBackendInterface; … … 56 57 virtual PassRefPtr<DOMStringList> objectStoreNames() const = 0; 57 58 58 virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&) = 0;59 virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&) = 0; 59 60 virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&) = 0; 60 61 virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, ExceptionCode&) = 0; -
trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h
r116337 r117817 29 29 #include "IDBCursor.h" 30 30 #include "IDBIndexBackendInterface.h" 31 #include "IDBKeyPath.h" 31 32 #include "IDBKeyRange.h" 32 33 #include "IDBRequest.h" … … 51 52 String name() const { return m_backend->name(); } 52 53 IDBObjectStore* objectStore() const { return m_objectStore.get(); } 53 StringkeyPath() const { return m_backend->keyPath(); }54 PassRefPtr<IDBAny> keyPath() const { return m_backend->keyPath(); } 54 55 bool unique() const { return m_backend->unique(); } 55 56 bool multiEntry() const { return m_backend->multiEntry(); } -
trunk/Source/WebCore/Modules/indexeddb/IDBIndex.idl
r116337 r117817 31 31 readonly attribute DOMString name; 32 32 readonly attribute IDBObjectStore objectStore; 33 readonly attribute DOMStringkeyPath;33 readonly attribute IDBAny keyPath; 34 34 readonly attribute boolean unique; 35 35 readonly attribute boolean multiEntry; -
trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp
r117512 r117817 42 42 namespace WebCore { 43 43 44 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& keyPath, bool unique, bool multiEntry)44 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry) 45 45 : m_backingStore(backingStore) 46 46 , m_databaseId(databaseId) … … 54 54 } 55 55 56 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& keyPath, bool unique, bool multiEntry)56 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry) 57 57 : m_backingStore(backingStore) 58 58 , m_databaseId(databaseId) -
trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h
r117512 r117817 31 31 #include "IDBCursorBackendInterface.h" 32 32 #include "IDBIndexBackendInterface.h" 33 #include "IDBKeyPath.h" 33 34 34 35 namespace WebCore { … … 41 42 class IDBIndexBackendImpl : public IDBIndexBackendInterface { 42 43 public: 43 static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& keyPath, bool unique, bool multiEntry)44 static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry) 44 45 { 45 46 return adoptRef(new IDBIndexBackendImpl(backingStore, databaseId, objectStoreBackend, id, name, keyPath, unique, multiEntry)); 46 47 } 47 static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& keyPath, bool unique, bool multiEntry)48 static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry) 48 49 { 49 50 return adoptRef(new IDBIndexBackendImpl(backingStore, databaseId, objectStoreBackend, name, keyPath, unique, multiEntry)); … … 63 64 // Implements IDBIndexBackendInterface. 64 65 virtual String name() { return m_name; } 65 virtual StringkeyPath() { return m_keyPath; }66 virtual IDBKeyPath keyPath() { return m_keyPath; } 66 67 virtual bool unique() { return m_unique; } 67 68 virtual bool multiEntry() { return m_multiEntry; } … … 76 77 77 78 private: 78 IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, IDBObjectStoreBackendImpl*, int64_t id, const String& name, const String& keyPath, bool unique, bool multiEntry);79 IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, IDBObjectStoreBackendImpl*, const String& name, const String& keyPath, bool unique, bool multiEntry);79 IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, IDBObjectStoreBackendImpl*, int64_t id, const String& name, const IDBKeyPath&, bool unique, bool multiEntry); 80 IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, IDBObjectStoreBackendImpl*, const String& name, const IDBKeyPath&, bool unique, bool multiEntry); 80 81 81 82 static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKeyRange>, unsigned short direction, IDBCursorBackendInterface::CursorType, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>); … … 97 98 int64_t m_id; 98 99 String m_name; 99 Stringm_keyPath;100 IDBKeyPath m_keyPath; 100 101 bool m_unique; 101 102 bool m_multiEntry; -
trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendInterface.h
r117512 r117817 37 37 class IDBCallbacks; 38 38 class IDBKey; 39 class IDBKeyPath; 39 40 class IDBKeyRange; 40 41 class IDBTransactionBackendInterface; … … 47 48 48 49 virtual String name() = 0; 49 virtual StringkeyPath() = 0;50 virtual IDBKeyPath keyPath() = 0; 50 51 virtual bool unique() = 0; 51 52 virtual bool multiEntry() = 0; -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp
r109493 r117817 29 29 #if ENABLE(INDEXED_DATABASE) 30 30 31 #include "DOMStringList.h" 31 32 #include <wtf/ASCIICType.h> 32 33 #include <wtf/dtoa.h> … … 180 181 } 181 182 183 IDBKeyPath::IDBKeyPath(const String& string) 184 : m_type(StringType) 185 , m_string(string) 186 { 187 ASSERT(!m_string.isNull()); 188 } 189 190 IDBKeyPath::IDBKeyPath(const Vector<String>& array) 191 : m_type(ArrayType) 192 , m_array(array) 193 { 194 #ifndef NDEBUG 195 for (size_t i = 0; i < m_array.size(); ++i) 196 ASSERT(!m_array[i].isNull()); 197 #endif 198 } 199 200 bool IDBKeyPath::isValid() const 201 { 202 switch (m_type) { 203 case NullType: 204 return false; 205 206 case StringType: 207 return IDBIsValidKeyPath(m_string); 208 209 case ArrayType: 210 for (size_t i = 0; i < m_array.size(); ++i) { 211 if (!IDBIsValidKeyPath(m_array[i])) 212 return false; 213 } 214 return true; 215 } 216 ASSERT_NOT_REACHED(); 217 return false; 218 } 219 220 IDBKeyPath::operator PassRefPtr<IDBAny>() const 221 { 222 switch (m_type) { 223 case NullType: 224 return IDBAny::createNull(); 225 case StringType: 226 return IDBAny::createString(m_string); 227 case ArrayType: 228 RefPtr<DOMStringList> keyPaths = DOMStringList::create(); 229 for (Vector<String>::const_iterator it = m_array.begin(); it != m_array.end(); ++it) 230 keyPaths->append(*it); 231 return IDBAny::create(static_cast<PassRefPtr<DOMStringList> >(keyPaths)); 232 } 233 ASSERT_NOT_REACHED(); 234 return 0; 235 } 236 237 182 238 } // namespace WebCore 183 239 -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.h
r109493 r117817 29 29 #if ENABLE(INDEXED_DATABASE) 30 30 31 #include <wtf/PassRefPtr.h>32 #include <wtf/RefCounted.h>31 #include "IDBAny.h" 32 #include "PlatformString.h" 33 33 #include <wtf/Vector.h> 34 #include <wtf/text/WTFString.h>35 34 36 35 namespace WebCore { … … 43 42 }; 44 43 45 bool IDBIsValidKeyPath(const String&);46 44 void IDBParseKeyPath(const String&, Vector<String>&, IDBKeyPathParseError&); 45 46 class IDBKeyPath { 47 public: 48 IDBKeyPath() : m_type(NullType) { } 49 IDBKeyPath(const String&); 50 IDBKeyPath(const Vector<String>& array); 51 52 enum Type { 53 NullType = 0, 54 StringType, 55 ArrayType 56 }; 57 58 Type type() const { return m_type; } 59 60 const Vector<String>& array() const 61 { 62 ASSERT(m_type == ArrayType); 63 return m_array; 64 } 65 66 const String& string() const 67 { 68 ASSERT(m_type == StringType); 69 return m_string; 70 } 71 72 bool isNull() const { return m_type == NullType; } 73 bool isValid() const; 74 operator PassRefPtr<IDBAny>() const; 75 76 private: 77 Type m_type; 78 String m_string; 79 Vector<String> m_array; 80 }; 47 81 48 82 } // namespace WebCore -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyPathBackendImpl.cpp
r110539 r117817 39 39 namespace WebCore { 40 40 41 void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>&, const String&, Vector<RefPtr<IDBKey>, 0>&)41 void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>&, const IDBKeyPath&, Vector<RefPtr<IDBKey>, 0>&) 42 42 { 43 43 // FIXME: Implement this method once JSC supports WireFormat for SerializedScriptValue. 44 44 } 45 45 46 PassRefPtr<SerializedScriptValue> IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const String&)46 PassRefPtr<SerializedScriptValue> IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&) 47 47 { 48 48 // FIXME: Implement this method once JSC supports WireFormat for SerializedScriptValue. -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyPathBackendImpl.h
r109493 r117817 34 34 35 35 class IDBKey; 36 class IDBKeyPath; 36 37 class SerializedScriptValue; 37 38 38 39 class IDBKeyPathBackendImpl { 39 40 public: 40 static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const String& keyPath, Vector<RefPtr<IDBKey>, 0>& keys);41 static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const String& keyPath);41 static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const IDBKeyPath&, Vector<RefPtr<IDBKey>, 0>& keys); 42 static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&); 42 43 }; 43 44 -
trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp
r116562 r117817 33 33 #include "FileSystem.h" 34 34 #include "IDBFactoryBackendImpl.h" 35 #include "IDBKeyPath.h" 35 36 #include "IDBKeyRange.h" 36 37 #include "IDBLevelDBCoding.h" … … 99 100 } 100 101 102 template <typename DBOrTransaction> 103 static bool putIDBKeyPath(DBOrTransaction* db, const Vector<char> key, const IDBKeyPath& value) 104 { 105 if (!db->put(key, encodeIDBKeyPath(value))) 106 return false; 107 return true; 108 } 109 101 110 static int compareKeys(const LevelDBSlice& a, const LevelDBSlice& b) 102 111 { … … 328 337 } 329 338 330 void IDBLevelDBBackingStore::getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector< String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags)339 void IDBLevelDBBackingStore::getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) 331 340 { 332 341 const Vector<char> startKey = ObjectStoreMetaDataKey::encode(databaseId, 1, 0); … … 364 373 return; 365 374 } 366 String keyPath = decodeString(it->value().begin(), it->value().end()); 367 bool hasKeyPath = true; 375 IDBKeyPath keyPath = decodeIDBKeyPath(it->value().begin(), it->value().end()); 368 376 369 377 it->next(); … … 394 402 it->next(); // [optional] has key path (is not null) 395 403 if (checkObjectStoreAndMetaDataType(it.get(), stopKey, objectStoreId, ObjectStoreMetaDataKey::kHasKeyPath)) { 396 hasKeyPath = decodeBool(it->value().begin(), it->value().end()); 397 if (!hasKeyPath && !keyPath.isEmpty()) { 404 bool hasKeyPath = decodeBool(it->value().begin(), it->value().end()); 405 // This check accounts for two layers of legacy coding: 406 // (1) Initially, hasKeyPath was added to distinguish null vs. string. 407 // (2) Later, null vs. string vs. array was stored in the keyPath itself. 408 // So this check is only relevant for string-type keyPaths. 409 if (!hasKeyPath && (keyPath.type() == IDBKeyPath::StringType && !keyPath.string().isEmpty())) { 398 410 LOG_ERROR("Internal Indexed DB error."); 399 411 return; 400 412 } 413 if (!hasKeyPath) 414 keyPath = IDBKeyPath(); 401 415 it->next(); 402 416 } … … 404 418 foundIds.append(objectStoreId); 405 419 foundNames.append(objectStoreName); 406 foundKeyPaths.append( hasKeyPath ? keyPath : String());420 foundKeyPaths.append(keyPath); 407 421 foundAutoIncrementFlags.append(autoIncrement); 408 422 } … … 425 439 } 426 440 427 bool IDBLevelDBBackingStore::createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId)441 bool IDBLevelDBBackingStore::createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) 428 442 { 429 443 ASSERT(m_currentTransaction); … … 447 461 } 448 462 449 ok = put String(m_currentTransaction.get(), keyPathKey, keyPath);463 ok = putIDBKeyPath(m_currentTransaction.get(), keyPathKey, keyPath); 450 464 if (!ok) { 451 465 LOG_ERROR("Internal Indexed DB error."); … … 718 732 719 733 720 void IDBLevelDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector< String>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags)734 void IDBLevelDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags) 721 735 { 722 736 const Vector<char> startKey = IndexMetaDataKey::encode(databaseId, objectStoreId, 0, 0); … … 761 775 return; 762 776 } 763 String keyPath = decodeString(it->value().begin(), it->value().end());777 IDBKeyPath keyPath = decodeIDBKeyPath(it->value().begin(), it->value().end()); 764 778 765 779 it->next(); // [optional] multiEntry flag … … 794 808 } 795 809 796 bool IDBLevelDBBackingStore::createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId)810 bool IDBLevelDBBackingStore::createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId) 797 811 { 798 812 ASSERT(m_currentTransaction); … … 818 832 } 819 833 820 ok = put String(m_currentTransaction.get(), keyPathKey, keyPath);834 ok = putIDBKeyPath(m_currentTransaction.get(), keyPathKey, keyPath); 821 835 if (!ok) { 822 836 LOG_ERROR("Internal Indexed DB error."); -
trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h
r116562 r117817 51 51 virtual bool deleteDatabase(const String& name); 52 52 53 virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector< String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags);54 virtual bool createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId);53 virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags); 54 virtual bool createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath&, bool autoIncrement, int64_t& assignedObjectStoreId); 55 55 virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId); 56 56 virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier(); … … 64 64 virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&); 65 65 66 virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector< String>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags);67 virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId);66 virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags); 67 virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry, int64_t& indexId); 68 68 virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId); 69 69 virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*); -
trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.cpp
r116333 r117817 31 31 32 32 #include "IDBKey.h" 33 #include "IDBKeyPath.h" 33 34 #include "LevelDBSlice.h" 34 35 #include <wtf/text/StringBuilder.h> … … 142 143 static const unsigned char kIDBKeyArrayTypeByte = 4; 143 144 static const unsigned char kIDBKeyMinKeyTypeByte = 5; 145 146 static const unsigned char kIDBKeyPathTypeCodedByte1 = 0; 147 static const unsigned char kIDBKeyPathTypeCodedByte2 = 0; 144 148 145 149 static const unsigned char kObjectStoreDataIndexId = 1; … … 627 631 } 628 632 633 Vector<char> encodeIDBKeyPath(const IDBKeyPath& keyPath) 634 { 635 // May be typed, or may be a raw string. An invalid leading 636 // byte is used to identify typed coding. New records are 637 // always written as typed. 638 Vector<char> ret; 639 ret.append(kIDBKeyPathTypeCodedByte1); 640 ret.append(kIDBKeyPathTypeCodedByte2); 641 ret.append(static_cast<char>(keyPath.type())); 642 switch (keyPath.type()) { 643 case IDBKeyPath::NullType: 644 break; 645 case IDBKeyPath::StringType: 646 ret.append(encodeStringWithLength(keyPath.string())); 647 break; 648 case IDBKeyPath::ArrayType: { 649 const Vector<String>& array = keyPath.array(); 650 size_t count = array.size(); 651 ret.append(encodeVarInt(count)); 652 for (size_t i = 0; i < count; ++i) 653 ret.append(encodeStringWithLength(array[i])); 654 break; 655 } 656 } 657 return ret; 658 } 659 660 IDBKeyPath decodeIDBKeyPath(const char* p, const char* limit) 661 { 662 // May be typed, or may be a raw string. An invalid leading 663 // byte sequence is used to identify typed coding. New records are 664 // always written as typed. 665 if (p == limit || (limit - p >= 2 && (*p != kIDBKeyPathTypeCodedByte1 || *(p + 1) != kIDBKeyPathTypeCodedByte2))) 666 return IDBKeyPath(decodeString(p, limit)); 667 p += 2; 668 669 ASSERT(p != limit); 670 IDBKeyPath::Type type = static_cast<IDBKeyPath::Type>(*p++); 671 switch (type) { 672 case IDBKeyPath::NullType: 673 ASSERT(p == limit); 674 return IDBKeyPath(); 675 case IDBKeyPath::StringType: { 676 String string; 677 p = decodeStringWithLength(p, limit, string); 678 ASSERT(p == limit); 679 return IDBKeyPath(string); 680 } 681 case IDBKeyPath::ArrayType: { 682 Vector<String> array; 683 int64_t count; 684 p = decodeVarInt(p, limit, count); 685 ASSERT(p); 686 ASSERT(count >= 0); 687 while (count--) { 688 String string; 689 p = decodeStringWithLength(p, limit, string); 690 ASSERT(p); 691 array.append(string); 692 } 693 ASSERT(p == limit); 694 return IDBKeyPath(array); 695 } 696 } 697 ASSERT_NOT_REACHED(); 698 return IDBKeyPath(); 699 } 700 629 701 namespace { 630 702 template<typename KeyType> -
trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.h
r116170 r117817 37 37 38 38 class IDBKey; 39 class IDBKeyPath; 39 40 class LevelDBSlice; 40 41 … … 64 65 const char* extractEncodedIDBKey(const char* start, const char* limit, Vector<char>* result); 65 66 int compareEncodedIDBKeys(const Vector<char>&, const Vector<char>&); 67 Vector<char> encodeIDBKeyPath(const IDBKeyPath&); 68 IDBKeyPath decodeIDBKeyPath(const char*, const char*); 66 69 67 70 int compare(const LevelDBSlice&, const LevelDBSlice&, bool indexKeys = false); -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
r117509 r117817 61 61 } 62 62 63 StringIDBObjectStore::keyPath() const63 PassRefPtr<IDBAny> IDBObjectStore::keyPath() const 64 64 { 65 65 IDB_TRACE("IDBObjectStore::keyPath"); … … 212 212 PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const String& keyPath, const Dictionary& options, ExceptionCode& ec) 213 213 { 214 return createIndex(name, IDBKeyPath(keyPath), options, ec); 215 } 216 217 PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const IDBKeyPath& keyPath, const Dictionary& options, ExceptionCode& ec) 218 { 214 219 IDB_TRACE("IDBObjectStore::createIndex"); 215 if (! IDBIsValidKeyPath(keyPath)) {220 if (!keyPath.isValid()) { 216 221 ec = IDBDatabaseException::NON_TRANSIENT_ERR; 217 222 return 0; -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h
r117509 r117817 58 58 // Implement the IDBObjectStore IDL 59 59 String name() const; 60 StringkeyPath() const;60 PassRefPtr<IDBAny> keyPath() const; 61 61 PassRefPtr<DOMStringList> indexNames() const; 62 62 IDBTransaction* transaction() const; … … 80 80 81 81 PassRefPtr<IDBIndex> createIndex(const String& name, const String& keyPath, const Dictionary&, ExceptionCode&); 82 PassRefPtr<IDBIndex> createIndex(const String&, const IDBKeyPath&, const Dictionary&, ExceptionCode&); 83 82 84 PassRefPtr<IDBIndex> index(const String& name, ExceptionCode&); 83 85 void deleteIndex(const String& name, ExceptionCode&); -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl
r117509 r117817 30 30 ] IDBObjectStore { 31 31 readonly attribute [TreatReturnedNullStringAs=Null] DOMString name; 32 readonly attribute [TreatReturnedNullStringAs=Null] DOMStringkeyPath;32 readonly attribute IDBAny keyPath; 33 33 readonly attribute DOMStringList indexNames; 34 34 readonly attribute IDBTransaction transaction; -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp
r117808 r117817 52 52 } 53 53 54 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement)54 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const IDBKeyPath& keyPath, bool autoIncrement) 55 55 : m_backingStore(backingStore) 56 56 , m_databaseId(databaseId) … … 64 64 } 65 65 66 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement)66 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement) 67 67 : m_backingStore(backingStore) 68 68 , m_databaseId(databaseId) … … 138 138 } 139 139 140 static PassRefPtr<IDBKey> fetchKeyFromKeyPath(SerializedScriptValue* value, const String& keyPath)140 static PassRefPtr<IDBKey> fetchKeyFromKeyPath(SerializedScriptValue* value, const IDBKeyPath& keyPath) 141 141 { 142 142 IDB_TRACE("IDBObjectStoreBackendImpl::fetchKeyFromKeyPath"); 143 ASSERT(!keyPath.isNull()); 144 143 145 Vector<RefPtr<SerializedScriptValue> > values; 144 146 values.append(value); … … 151 153 } 152 154 153 static PassRefPtr<SerializedScriptValue> injectKeyIntoKeyPath(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const String& keyPath)155 static PassRefPtr<SerializedScriptValue> injectKeyIntoKeyPath(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath) 154 156 { 155 157 IDB_TRACE("IDBObjectStoreBackendImpl::injectKeyIntoKeyPath"); … … 498 500 } 499 501 500 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)502 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) 501 503 { 502 504 if (name.isNull()) { … … 649 651 Vector<int64_t> ids; 650 652 Vector<String> names; 651 Vector< String> keyPaths;653 Vector<IDBKeyPath> keyPaths; 652 654 Vector<bool> uniqueFlags; 653 655 Vector<bool> multiEntryFlags; -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h
r117334 r117817 27 27 #define IDBObjectStoreBackendImpl_h 28 28 29 #include "IDBKeyPath.h" 29 30 #include "IDBObjectStoreBackendInterface.h" 30 31 #include <wtf/HashMap.h> … … 43 44 class IDBObjectStoreBackendImpl : public IDBObjectStoreBackendInterface { 44 45 public: 45 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement)46 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const IDBKeyPath& keyPath, bool autoIncrement) 46 47 { 47 48 return adoptRef(new IDBObjectStoreBackendImpl(backingStore, databaseId, id, name, keyPath, autoIncrement)); 48 49 } 49 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement)50 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement) 50 51 { 51 52 return adoptRef(new IDBObjectStoreBackendImpl(backingStore, databaseId, name, keyPath, autoIncrement)); … … 62 63 63 64 virtual String name() const { return m_name; } 64 virtual StringkeyPath() const { return m_keyPath; }65 virtual IDBKeyPath keyPath() const { return m_keyPath; } 65 66 virtual PassRefPtr<DOMStringList> indexNames() const; 66 67 virtual bool autoIncrement() const { return m_autoIncrement; } … … 73 74 virtual void clear(PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&); 74 75 75 virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&);76 virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const IDBKeyPath&, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&); 76 77 virtual PassRefPtr<IDBIndexBackendInterface> index(const String& name, ExceptionCode&); 77 78 virtual void deleteIndex(const String& name, IDBTransactionBackendInterface*, ExceptionCode&); … … 83 84 84 85 private: 85 IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement);86 IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement);86 IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, int64_t id, const String& name, const IDBKeyPath&, bool autoIncrement); 87 IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, const String& name, const IDBKeyPath&, bool autoIncrement); 87 88 88 89 void loadIndexes(); … … 113 114 int64_t m_id; 114 115 String m_name; 115 Stringm_keyPath;116 IDBKeyPath m_keyPath; 116 117 bool m_autoIncrement; 117 118 -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendInterface.h
r117509 r117817 38 38 class IDBIndexBackendInterface; 39 39 class IDBKey; 40 class IDBKeyPath; 40 41 class IDBKeyRange; 41 42 class IDBTransactionBackendInterface; … … 49 50 50 51 virtual String name() const = 0; 51 virtual StringkeyPath() const = 0;52 virtual IDBKeyPath keyPath() const = 0; 52 53 virtual PassRefPtr<DOMStringList> indexNames() const = 0; 53 54 virtual bool autoIncrement() const = 0; … … 66 67 virtual void clear(PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) = 0; 67 68 68 virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&) = 0;69 virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const IDBKeyPath&, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&) = 0; 69 70 virtual PassRefPtr<IDBIndexBackendInterface> index(const String& name, ExceptionCode&) = 0; 70 71 virtual void deleteIndex(const String& name, IDBTransactionBackendInterface*, ExceptionCode&) = 0; -
trunk/Source/WebCore/bindings/v8/Dictionary.cpp
r115264 r117817 425 425 } 426 426 427 bool Dictionary::get(const String& key, Vector<String>& value) const 428 { 429 v8::Local<v8::Value> v8Value; 430 if (!getKey(key, v8Value)) 431 return false; 432 433 if (!v8Value->IsArray()) 434 return false; 435 436 v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value); 437 for (size_t i = 0; i < v8Array->Length(); ++i) { 438 v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Uint32::New(i)); 439 value.append(v8ValueToWebCoreString(indexedValue)); 440 } 441 442 return true; 443 } 427 444 428 445 bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& hashMap) const -
trunk/Source/WebCore/bindings/v8/Dictionary.h
r115264 r117817 34 34 #include <wtf/HashMap.h> 35 35 #include <wtf/HashSet.h> 36 #include <wtf/Vector.h> 36 37 #include <wtf/text/AtomicString.h> 37 38 38 39 namespace WebCore { 39 40 40 class DOMStringList;41 41 class DOMWindow; 42 42 class IDBKeyRange; … … 86 86 bool get(const String&, HashSet<AtomicString>&) const; 87 87 bool get(const String&, Dictionary&) const; 88 bool get(const String&, Vector<String>&) const; 88 89 bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const; 89 90 -
trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp
r113395 r117817 154 154 } // anonymous namespace 155 155 156 PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const Vector<String>& keyPath)156 PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath) 157 157 { 158 158 IDB_TRACE("createIDBKeyFromSerializedValueAndKeyPath"); 159 ASSERT(keyPath.type() == IDBKeyPath::StringType); 160 Vector<String> keyPathElements; 161 IDBKeyPathParseError error; 162 IDBParseKeyPath(keyPath.string(), keyPathElements, error); 163 ASSERT(error == IDBKeyPathParseErrorNone); 164 159 165 V8AuxiliaryContext context; 160 166 v8::Handle<v8::Value> v8Value(value->deserialize()); 161 v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPath , keyPath.size()));167 v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size())); 162 168 if (v8Key.IsEmpty()) 163 169 return 0; … … 165 171 } 166 172 167 PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const Vector<String>& keyPath)173 PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath) 168 174 { 169 175 IDB_TRACE("injectIDBKeyIntoSerializedValue"); 176 177 ASSERT(keyPath.type() == IDBKeyPath::StringType); 178 Vector<String> keyPathElements; 179 IDBKeyPathParseError error; 180 IDBParseKeyPath(keyPath.string(), keyPathElements, error); 181 ASSERT(error == IDBKeyPathParseErrorNone); 182 183 if (!keyPathElements.size()) 184 return 0; 185 170 186 V8AuxiliaryContext context; 171 if (!keyPath.size())172 return 0;173 174 187 v8::Handle<v8::Value> v8Value(value->deserialize()); 175 v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPath , keyPath.size() - 1));188 v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1)); 176 189 if (parent.IsEmpty()) 177 190 return 0; 178 191 179 if (!set(parent, keyPath .last(), toV8(key.get())))192 if (!set(parent, keyPathElements.last(), toV8(key.get()))) 180 193 return 0; 181 194 -
trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.h
r95901 r117817 35 35 36 36 class IDBKey; 37 class IDBKeyPath; 37 38 class SerializedScriptValue; 38 39 39 40 PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value>); 40 PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue>, const Vector<String, 0>&);41 PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const Vector<String, 0>&);41 PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue>, const IDBKeyPath&); 42 PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&); 42 43 43 44 } -
trunk/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp
r117381 r117817 33 33 34 34 #include "SerializedScriptValue.h" 35 #include "V8Binding.h" 35 36 #include "V8DOMStringList.h" 36 37 #include "V8IDBCursor.h" … … 75 76 case IDBAny::SerializedScriptValueType: 76 77 return impl->serializedScriptValue()->deserialize(0, isolate); 78 case IDBAny::StringType: 79 return v8String(impl->string()); 77 80 } 78 81 -
trunk/Source/WebCore/dom/DOMStringList.h
r109305 r117817 53 53 bool contains(const String& str) const; 54 54 55 operator const Vector<String>&() const { return m_strings; } 56 55 57 private: 56 58 DOMStringList() { } -
trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp
r117338 r117817 47 47 #include "IDBIndexBackendInterface.h" 48 48 #include "IDBKey.h" 49 #include "IDBKeyPath.h" 49 50 #include "IDBKeyRange.h" 50 51 #include "IDBObjectStoreBackendInterface.h" … … 226 227 } 227 228 229 static String keyPathToString(const IDBKeyPath& keyPath) 230 { 231 // FIXME: Replace with handlers for null/string/array types. 232 // https://bugs.webkit.org/show_bug.cgi?id=84303 233 switch (keyPath.type()) { 234 case IDBKeyPath::NullType: 235 return "(none)"; 236 break; 237 case IDBKeyPath::StringType: 238 return keyPath.string(); 239 break; 240 case IDBKeyPath::ArrayType: 241 return "[...]"; 242 break; 243 } 244 ASSERT_NOT_REACHED(); 245 return String(); 246 } 247 228 248 class DatabaseLoaderCallback : public ExecutableWithDatabase { 229 249 public: … … 261 281 RefPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::create() 262 282 .setName(idbIndex->name()) 263 .setKeyPath( idbIndex->keyPath())283 .setKeyPath(keyPathToString(idbIndex->keyPath())) 264 284 .setUnique(idbIndex->unique()) 265 285 .setMultiEntry(idbIndex->multiEntry()); … … 269 289 RefPtr<ObjectStore> objectStore = ObjectStore::create() 270 290 .setName(idbObjectStore->name()) 271 .setKeyPath( idbObjectStore->keyPath())291 .setKeyPath(keyPathToString(idbObjectStore->keyPath())) 272 292 .setIndexes(indexes); 273 293 objectStores->addItem(objectStore); -
trunk/Source/WebCore/platform/chromium/PlatformSupport.h
r117766 r117817 79 79 class IDBFactoryBackendInterface; 80 80 class IDBKey; 81 class IDBKeyPath; 81 82 class IntRect; 82 83 class KURL; … … 179 180 static PassRefPtr<IDBFactoryBackendInterface> idbFactory(); 180 181 // Extracts keyPath from values and returns the corresponding keys. 181 static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys);182 static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const IDBKeyPath&, Vector<RefPtr<IDBKey> >& keys); 182 183 // Injects key via keyPath into value. Returns true on success. 183 static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const String& keyPath);184 static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&); 184 185 185 186 // JavaScript --------------------------------------------------------- -
trunk/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp
r95901 r117817 35 35 namespace WebCore { 36 36 37 void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const String& keyPath, Vector<RefPtr<IDBKey>, 0>& keys)37 void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const IDBKeyPath& keyPath, Vector<RefPtr<IDBKey>, 0>& keys) 38 38 { 39 39 PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath(values, keyPath, keys); 40 40 } 41 41 42 PassRefPtr<SerializedScriptValue> IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const String& keyPath)42 PassRefPtr<SerializedScriptValue> IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath) 43 43 { 44 44 return PlatformSupport::injectIDBKeyIntoSerializedValue(key, value, keyPath); -
trunk/Source/WebKit/chromium/ChangeLog
r117802 r117817 1 2012-05-21 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: Store key paths in IDBKeyPath type instead of String 4 https://bugs.webkit.org/show_bug.cgi?id=85298 5 6 Reviewed by Tony Chang, Kentaro Hara and James Robinson. 7 8 No functional changes, just finish migration from String to IDBKeyPath 9 for storing key paths, for eventual array support http://webkit.org/b/84207 10 11 * public/WebIDBDatabase.h: Remove temporary overload. 12 (WebKit): 13 (WebKit::WebIDBDatabase::objectStoreNames): 14 * public/WebIDBIndex.h: Remove temporary method. 15 (WebKit::WebIDBIndex::keyPath): 16 * public/WebIDBKeyPath.h: Remove obsolete methods, wrap WebCore::IDBKeyPath 17 (WebIDBKeyPath): 18 (WebKit::WebIDBKeyPath::WebIDBKeyPath): 19 * public/WebIDBObjectStore.h: Remove temporary method and overload. 20 (WebKit::WebIDBObjectStore::keyPath): 21 * public/platform/WebKitPlatformSupport.h: Remove temporary overloads. 22 (WebKit): 23 * src/AssertMatchingEnums.cpp: WebIDBKeyPath vs. IDBKeyPath enums. 24 * src/IDBDatabaseBackendProxy.cpp: Switch from String to IDBKeyPath. 25 (WebKit::IDBDatabaseBackendProxy::createObjectStore): 26 * src/IDBDatabaseBackendProxy.h: Switch from String to IDBKeyPath. 27 (IDBDatabaseBackendProxy): 28 * src/IDBIndexBackendProxy.cpp: Switch from String to IDBKeyPath. 29 (WebKit::IDBIndexBackendProxy::keyPath): 30 * src/IDBIndexBackendProxy.h: Switch from String to IDBKeyPath. 31 (IDBIndexBackendProxy): 32 * src/IDBObjectStoreBackendProxy.cpp: Switch from String to IDBKeyPath. 33 (WebKit::IDBObjectStoreBackendProxy::keyPath): 34 (WebKit::IDBObjectStoreBackendProxy::createIndex): 35 * src/IDBObjectStoreBackendProxy.h: Switch from String to IDBKeyPath. 36 (IDBObjectStoreBackendProxy): 37 * src/PlatformSupport.cpp: Switch from String to IDBKeyPath. 38 (WebCore::PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath): 39 (WebCore::PlatformSupport::injectIDBKeyIntoSerializedValue): 40 * src/WebIDBDatabaseImpl.cpp: Switch from String to IDBKeyPath. 41 (WebKit::WebIDBDatabaseImpl::createObjectStore): 42 * src/WebIDBDatabaseImpl.h: Remove temporary overload. 43 (WebIDBDatabaseImpl): 44 * src/WebIDBIndexImpl.cpp: Remove temporary method. 45 * src/WebIDBIndexImpl.h: Remove temporary method. 46 (WebIDBIndexImpl): 47 * src/WebIDBKeyPath.cpp: Remove most logic; just a wrapper for WebCore::IDBKeyPath. 48 (WebKit::WebIDBKeyPath::~WebIDBKeyPath): 49 (WebKit::WebIDBKeyPath::create): 50 (WebKit::WebIDBKeyPath::createNull): 51 (WebKit::WebIDBKeyPath::isValid): 52 (WebKit::WebIDBKeyPath::type): 53 (WebKit): 54 (WebKit::WebIDBKeyPath::array): 55 (WebKit::WebIDBKeyPath::string): 56 (WebKit::WebIDBKeyPath::WebIDBKeyPath): 57 (WebKit::WebIDBKeyPath::operator=): 58 (WebKit::WebIDBKeyPath::operator const WebCore::IDBKeyPath&): 59 * src/WebIDBObjectStoreImpl.cpp: Remove temporary method and overload. 60 (WebKit::WebIDBObjectStoreImpl::keyPath): 61 (WebKit::WebIDBObjectStoreImpl::createIndex): 62 * src/WebIDBObjectStoreImpl.h: Remove temporary method and overload. 63 (WebIDBObjectStoreImpl): 64 * tests/IDBBindingUtilitiesTest.cpp: Use IDBKeyPath. 65 (WebCore::checkKeyFromValueAndKeyPathInternal): 66 (WebCore::injectKey): 67 * tests/IDBLevelDBCodingTest.cpp: Added EncodeIDBKeyPath and DecodeIDBKeyPath tests. 68 (IDBLevelDBCoding::TEST): 69 (IDBLevelDBCoding): 70 * tests/IDBKeyPathTest.cpp: 71 (WebCore::checkKeyPath): Test IDBKeyPath validity. 72 1 73 2012-05-18 Michael Nordman <michaeln@google.com> 2 74 -
trunk/Source/WebKit/chromium/public/WebIDBDatabase.h
r115339 r117817 29 29 #include "WebDOMStringList.h" 30 30 #include "WebExceptionCode.h" 31 #include "WebIDBKeyPath.h"32 31 #include "platform/WebCommon.h" 33 32 … … 37 36 class WebIDBCallbacks; 38 37 class WebIDBDatabaseCallbacks; 38 class WebIDBKeyPath; 39 39 class WebIDBObjectStore; 40 40 class WebIDBTransaction; … … 59 59 WEBKIT_ASSERT_NOT_REACHED(); 60 60 return WebDOMStringList(); 61 }62 // FIXME: Remove WebString keyPath overload once callers are updated.63 // http://webkit.org/b/8420764 virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec)65 {66 return createObjectStore(name, WebIDBKeyPath(keyPath), autoIncrement, transaction, ec);67 61 } 68 62 virtual WebIDBObjectStore* createObjectStore(const WebString&, const WebIDBKeyPath&, bool, const WebIDBTransaction&, WebExceptionCode&) -
trunk/Source/WebKit/chromium/public/WebIDBIndex.h
r117727 r117817 50 50 virtual WebIDBKeyPath keyPath() const 51 51 { 52 return WebIDBKeyPath(keyPathString());53 }54 // FIXME: Remove method once callers are updated.55 // http://webkit.org/b/8420756 virtual WebString keyPathString() const57 {58 52 WEBKIT_ASSERT_NOT_REACHED(); 59 return Web String();53 return WebIDBKeyPath::createNull(); 60 54 } 61 55 virtual bool unique() const -
trunk/Source/WebKit/chromium/public/WebIDBKeyPath.h
r115339 r117817 37 37 } 38 38 39 namespace WebCore { class IDBKeyPath; } 40 39 41 namespace WebKit { 40 42 … … 45 47 WEBKIT_EXPORT static WebIDBKeyPath createNull(); 46 48 WEBKIT_EXPORT WebIDBKeyPath(const WebIDBKeyPath&); 47 ~WebIDBKeyPath() { reset(); }49 WEBKIT_EXPORT ~WebIDBKeyPath(); 48 50 49 51 enum Type { … … 55 57 WEBKIT_EXPORT bool isValid() const; 56 58 WEBKIT_EXPORT Type type() const; 57 // FIXME: Array-type key paths not yet supported. http://webkit.org/b/84207 58 WebVector<WebString> array() const { WEBKIT_ASSERT_NOT_REACHED(); return WebVector<WebString>(); } 59 WEBKIT_EXPORT WebString string() const; 60 61 // FIXME: Remove these once callers are updated. http://webkit.org/b/84207 62 WEBKIT_EXPORT WebIDBKeyPath(const WebString&); 63 operator const WebString () const { return string(); } 64 WEBKIT_EXPORT int parseError() const; 65 WEBKIT_EXPORT void assign(const WebIDBKeyPath&); 66 WEBKIT_EXPORT void reset(); 59 WEBKIT_EXPORT WebVector<WebString> array() const; // Only valid for ArrayType. 60 WEBKIT_EXPORT WebString string() const; // Only valid for StringType. 67 61 68 62 #if WEBKIT_IMPLEMENTATION 69 operator const WTF::Vector<WTF::String, 0>& () const; 63 WebIDBKeyPath(const WebCore::IDBKeyPath&); 64 WebIDBKeyPath& operator=(const WebCore::IDBKeyPath&); 65 operator const WebCore::IDBKeyPath&() const; 70 66 #endif 71 67 72 68 private: 73 WebIDBKeyPath(); 74 75 #if WEBKIT_IMPLEMENTATION 76 WebIDBKeyPath(const WTF::Vector<WTF::String, 0>&, int parseError); 77 #endif 78 79 WebPrivateOwnPtr<WTF::Vector<WTF::String, 0> > m_private; 80 int m_parseError; 69 WebPrivateOwnPtr<WebCore::IDBKeyPath> m_private; 81 70 }; 82 71 -
trunk/Source/WebKit/chromium/public/WebIDBObjectStore.h
r117341 r117817 31 31 #include "WebIDBCallbacks.h" 32 32 #include "WebIDBKeyPath.h" 33 #include "WebIDBTransaction.h"34 33 #include "platform/WebCommon.h" 35 34 #include "platform/WebString.h" … … 52 51 virtual WebIDBKeyPath keyPath() const 53 52 { 54 return WebIDBKeyPath(keyPathString());55 }56 virtual WebString keyPathString() const57 {58 53 WEBKIT_ASSERT_NOT_REACHED(); 59 return Web String();54 return WebIDBKeyPath::createNull(); 60 55 } 61 56 virtual WebDOMStringList indexNames() const … … 82 77 virtual void deleteFunction(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } 83 78 virtual void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } 84 85 // FIXME: Remove WebString keyPath overload once callers are updated.86 // http://webkit.org/b/8420787 virtual WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec)88 {89 return createIndex(name, WebIDBKeyPath(keyPath), unique, multiEntry, transaction, ec);90 }91 79 virtual WebIDBIndex* createIndex(const WebString&, const WebIDBKeyPath&, bool, bool, const WebIDBTransaction&, WebExceptionCode&) 92 80 { -
trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h
r117797 r117817 32 32 #define WebKitPlatformSupport_h 33 33 34 #include "../WebIDBKeyPath.h" // FIXME: Remove with: http://webkit.org/b/8420735 34 #include "WebCommon.h" 36 35 #include "WebGraphicsContext3D.h" … … 54 53 class WebIDBFactory; // FIXME: Does this belong in platform? 55 54 class WebIDBKey; // FIXME: Does this belong in platform? 55 class WebIDBKeyPath; // FIXME: Does this belong in platform? 56 56 class WebMessagePortChannel; // FIXME: Does this belong in platform? 57 57 class WebPluginListBuilder; // FIXME: Does this belong in platform? … … 107 107 108 108 virtual WebIDBFactory* idbFactory() { return 0; } 109 // FIXME: Remove WebString keyPath overload once callers are updated.110 // http://webkit.org/b/84207111 virtual void createIDBKeysFromSerializedValuesAndKeyPath(const WebVector<WebSerializedScriptValue>& values, const WebString& keyPath, WebVector<WebIDBKey>& keys) { createIDBKeysFromSerializedValuesAndKeyPath(values, WebIDBKeyPath(keyPath), keys); }112 109 virtual void createIDBKeysFromSerializedValuesAndKeyPath(const WebVector<WebSerializedScriptValue>& values, const WebIDBKeyPath& keyPath, WebVector<WebIDBKey>& keys) { } 113 // FIXME: Remove WebString keyPath overload once callers are updated.114 // http://webkit.org/b/84207115 virtual WebSerializedScriptValue injectIDBKeyIntoSerializedValue(const WebIDBKey& key, const WebSerializedScriptValue& value, const WebString& keyPath) { return injectIDBKeyIntoSerializedValue(key, value, WebIDBKeyPath(keyPath)); }116 110 virtual WebSerializedScriptValue injectIDBKeyIntoSerializedValue(const WebIDBKey& key, const WebSerializedScriptValue& value, const WebIDBKeyPath& keyPath) { return WebSerializedScriptValue(); } 117 111 -
trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
r117529 r117817 53 53 #include "IDBFactoryBackendInterface.h" 54 54 #include "IDBKey.h" 55 #include "IDBKeyPath.h" 55 56 #include "IceOptions.h" 56 57 #include "IconURL.h" … … 87 88 #include "WebIDBFactory.h" 88 89 #include "WebIDBKey.h" 90 #include "WebIDBKeyPath.h" 89 91 #include "WebIconURL.h" 90 92 #include "WebInputElement.h" … … 468 470 COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionQuotaError, IDBDatabaseException::QUOTA_ERR); 469 471 472 #if ENABLE(INDEXED_DATABASE) 470 473 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::InvalidType, IDBKey::InvalidType); 471 474 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::ArrayType, IDBKey::ArrayType); … … 473 476 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::DateType, IDBKey::DateType); 474 477 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::NumberType, IDBKey::NumberType); 478 479 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::NullType, IDBKeyPath::NullType); 480 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::StringType, IDBKeyPath::StringType); 481 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::ArrayType, IDBKeyPath::ArrayType); 482 #endif 475 483 476 484 #if ENABLE(FILE_SYSTEM) -
trunk/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp
r95901 r117817 76 76 } 77 77 78 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendProxy::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)78 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendProxy::createObjectStore(const String& name, const IDBKeyPath& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) 79 79 { 80 80 // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, -
trunk/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h
r95901 r117817 47 47 virtual PassRefPtr<WebCore::DOMStringList> objectStoreNames() const; 48 48 49 virtual PassRefPtr<WebCore::IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);49 virtual PassRefPtr<WebCore::IDBObjectStoreBackendInterface> createObjectStore(const String& name, const WebCore::IDBKeyPath&, bool autoIncrement, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); 50 50 virtual void deleteObjectStore(const String& name, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); 51 51 virtual void setVersion(const String& version, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, WebCore::ExceptionCode&); -
trunk/Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp
r117512 r117817 30 30 31 31 #include "IDBCallbacks.h" 32 #include "IDBKeyPath.h" 32 33 #include "IDBKeyRange.h" 33 34 #include "IDBTransactionBackendProxy.h" … … 61 62 } 62 63 63 StringIDBIndexBackendProxy::keyPath()64 IDBKeyPath IDBIndexBackendProxy::keyPath() 64 65 { 65 return m_webIDBIndex->keyPath() .string();66 return m_webIDBIndex->keyPath(); 66 67 } 67 68 -
trunk/Source/WebKit/chromium/src/IDBIndexBackendProxy.h
r117512 r117817 30 30 31 31 #include "IDBIndexBackendInterface.h" 32 #include "IDBKeyPath.h" 32 33 #include <wtf/OwnPtr.h> 33 34 #include <wtf/PassOwnPtr.h> … … 43 44 44 45 virtual String name(); 45 virtual StringkeyPath();46 virtual WebCore::IDBKeyPath keyPath(); 46 47 virtual bool unique(); 47 48 virtual bool multiEntry(); -
trunk/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp
r117509 r117817 65 65 } 66 66 67 StringIDBObjectStoreBackendProxy::keyPath() const67 IDBKeyPath IDBObjectStoreBackendProxy::keyPath() const 68 68 { 69 return m_webIDBObjectStore->keyPath() .string();69 return m_webIDBObjectStore->keyPath(); 70 70 } 71 71 … … 120 120 } 121 121 122 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendProxy::createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)122 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendProxy::createIndex(const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) 123 123 { 124 124 // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, -
trunk/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h
r117509 r117817 29 29 #if ENABLE(INDEXED_DATABASE) 30 30 31 #include "IDBKeyPath.h" 31 32 #include "IDBObjectStoreBackendInterface.h" 32 33 #include <wtf/OwnPtr.h> … … 44 45 45 46 virtual String name() const; 46 virtual StringkeyPath() const;47 virtual WebCore::IDBKeyPath keyPath() const; 47 48 virtual PassRefPtr<WebCore::DOMStringList> indexNames() const; 48 49 virtual bool autoIncrement() const; … … 54 55 virtual void clear(PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); 55 56 56 PassRefPtr<WebCore::IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);57 PassRefPtr<WebCore::IDBIndexBackendInterface> createIndex(const String& name, const WebCore::IDBKeyPath&, bool unique, bool multiEntry, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); 57 58 PassRefPtr<WebCore::IDBIndexBackendInterface> index(const String& name, WebCore::ExceptionCode&); 58 59 void deleteIndex(const String& name, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); -
trunk/Source/WebKit/chromium/src/PlatformSupport.cpp
r117766 r117817 41 41 #include "WebFrameImpl.h" 42 42 #include "WebIDBKey.h" 43 #include "WebIDBKeyPath.h" 43 44 #include "WebKit.h" 44 45 #include "WebPluginContainerImpl.h" … … 496 497 } 497 498 498 void PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys)499 void PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const IDBKeyPath& keyPath, Vector<RefPtr<IDBKey> >& keys) 499 500 { 500 501 WebVector<WebSerializedScriptValue> webValues = values; … … 508 509 } 509 510 510 PassRefPtr<SerializedScriptValue> PlatformSupport::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const String& keyPath)511 PassRefPtr<SerializedScriptValue> PlatformSupport::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath) 511 512 { 512 513 return webKitPlatformSupport()->injectIDBKeyIntoSerializedValue(key, value, keyPath); -
trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp
r104481 r117817 67 67 } 68 68 69 WebIDBObjectStore* WebIDBDatabaseImpl::createObjectStore(const WebString& name, const Web String& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec)69 WebIDBObjectStore* WebIDBDatabaseImpl::createObjectStore(const WebString& name, const WebIDBKeyPath& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec) 70 70 { 71 71 RefPtr<IDBObjectStoreBackendInterface> objectStore = m_databaseBackend->createObjectStore(name, keyPath, autoIncrement, transaction.getIDBTransactionBackendInterface(), ec); -
trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h
r115339 r117817 54 54 virtual WebDOMStringList objectStoreNames() const; 55 55 56 // FIXME: Remove WebString keyPath overload once callers are updated. 57 // http://webkit.org/b/84207 58 virtual WebIDBObjectStore* createObjectStore(const WebString&, const WebString&, bool, const WebIDBTransaction&, WebExceptionCode&); 59 virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebIDBKeyPath& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec) { return createObjectStore(name, keyPath.string(), autoIncrement, transaction, ec); } 56 virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebIDBKeyPath&, bool autoIncrement, const WebIDBTransaction&, WebExceptionCode&); 60 57 virtual void deleteObjectStore(const WebString& name, const WebIDBTransaction&, WebExceptionCode&); 61 58 virtual void setVersion(const WebString& version, WebIDBCallbacks*, WebExceptionCode&); -
trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.cpp
r117512 r117817 59 59 } 60 60 61 // FIXME: Remove this method once callers are updated.62 // http://webkit.org/b/8420763 WebString WebIDBIndexImpl::keyPathString() const64 {65 return m_backend->keyPath();66 }67 68 61 bool WebIDBIndexImpl::unique() const 69 62 { -
trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.h
r117512 r117817 46 46 virtual WebString name() const; 47 47 virtual WebIDBKeyPath keyPath() const; 48 // FIXME: Remove this method once callers are updated.49 // http://webkit.org/b/8420750 virtual WebString keyPathString() const;51 48 virtual bool unique() const; 52 49 virtual bool multiEntry() const; -
trunk/Source/WebKit/chromium/src/WebIDBKeyPath.cpp
r115339 r117817 38 38 namespace WebKit { 39 39 40 WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>&)40 WebIDBKeyPath::~WebIDBKeyPath() 41 41 { 42 // FIXME: Array-type key paths not yet supported. http://webkit.org/b/84207 43 WEBKIT_ASSERT_NOT_REACHED(); 44 return createNull(); 42 m_private.reset(0); 45 43 } 46 44 47 45 WebIDBKeyPath WebIDBKeyPath::create(const WebString& keyPath) 48 46 { 49 if (keyPath.isNull())50 return createNull(); 47 return WebIDBKeyPath(IDBKeyPath(keyPath)); 48 } 51 49 52 WTF::Vector<WTF::String> idbElements; 53 IDBKeyPathParseError idbError; 54 IDBParseKeyPath(keyPath, idbElements, idbError); 55 return WebIDBKeyPath(idbElements, static_cast<int>(idbError)); 50 WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>& keyPath) 51 { 52 Vector<String> strings; 53 for (size_t i = 0; i < keyPath.size(); ++i) 54 strings.append(keyPath[i]); 55 return WebIDBKeyPath(IDBKeyPath(strings)); 56 56 } 57 57 58 58 WebIDBKeyPath WebIDBKeyPath::createNull() 59 59 { 60 return WebIDBKeyPath(WebString()); 61 } 62 63 WebIDBKeyPath::WebIDBKeyPath(const WebIDBKeyPath& keyPath) 64 { 65 assign(keyPath); 66 } 67 68 WebIDBKeyPath::WebIDBKeyPath(const WTF::Vector<WTF::String>& elements, int parseError) 69 : m_private(new WTF::Vector<WTF::String>(elements)) 70 , m_parseError(parseError) 71 { 60 return WebIDBKeyPath(IDBKeyPath()); 72 61 } 73 62 74 63 bool WebIDBKeyPath::isValid() const 75 64 { 76 return m_parseError == IDBKeyPathParseErrorNone; 65 ASSERT(m_private.get()); 66 return m_private->isValid(); 77 67 } 78 68 79 69 WebIDBKeyPath::Type WebIDBKeyPath::type() const 80 70 { 81 return m_private.get() ? StringType : NullType; 71 ASSERT(m_private.get()); 72 return Type(m_private->type()); 73 } 74 75 76 WebVector<WebString> WebIDBKeyPath::array() const 77 { 78 ASSERT(m_private.get()); 79 ASSERT(m_private->type() == IDBKeyPath::ArrayType); 80 return m_private->array(); 82 81 } 83 82 84 83 WebString WebIDBKeyPath::string() const 85 84 { 86 if (!m_private.get()) 87 return WebString(); 88 89 // FIXME: Store the complete string instead of rebuilding it. 90 // http://webkit.org/b/84207 91 WTF::String string(""); 92 WTF::Vector<WTF::String>& array = *m_private.get(); 93 for (size_t i = 0; i < array.size(); ++i) { 94 if (i) 95 string.append("."); 96 string.append(array[i]); 97 } 98 return WebString(string); 85 ASSERT(m_private.get()); 86 ASSERT(m_private->type() == IDBKeyPath::StringType); 87 return m_private->string(); 99 88 } 100 89 101 WebIDBKeyPath::WebIDBKeyPath(const Web String& keyPath)102 : m_p arseError(IDBKeyPathParseErrorNone)90 WebIDBKeyPath::WebIDBKeyPath(const WebIDBKeyPath& keyPath) 91 : m_private(new IDBKeyPath(keyPath)) 103 92 { 104 if (!keyPath.isNull()) { 105 m_private.reset(new WTF::Vector<WTF::String>()); 106 IDBKeyPathParseError idbParseError; 107 IDBParseKeyPath(keyPath, *m_private.get(), idbParseError); 108 m_parseError = idbParseError; 109 } 93 ASSERT(m_private.get()); 110 94 } 111 95 112 int WebIDBKeyPath::parseError() const 96 WebIDBKeyPath::WebIDBKeyPath(const WebCore::IDBKeyPath& value) 97 : m_private(new IDBKeyPath(value)) 113 98 { 114 return m_parseError;99 ASSERT(m_private.get()); 115 100 } 116 101 117 void WebIDBKeyPath::assign(const WebIDBKeyPath& keyPath)102 WebIDBKeyPath& WebIDBKeyPath::operator=(const WebCore::IDBKeyPath& value) 118 103 { 119 m_parseError = keyPath.m_parseError; 120 if (keyPath.m_private.get()) 121 m_private.reset(new WTF::Vector<WTF::String>(keyPath)); 122 else 123 m_private.reset(0); 104 ASSERT(m_private.get()); 105 m_private.reset(new IDBKeyPath(value)); 106 return *this; 124 107 } 125 108 126 void WebIDBKeyPath::reset() 127 { 128 m_private.reset(0); 129 } 130 131 WebIDBKeyPath::operator const WTF::Vector<WTF::String, 0>&() const 109 WebIDBKeyPath::operator const WebCore::IDBKeyPath&() const 132 110 { 133 111 ASSERT(m_private.get()); 134 return * m_private.get();112 return *(m_private.get()); 135 113 } 136 114 -
trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp
r117509 r117817 32 32 #include "IDBCallbacksProxy.h" 33 33 #include "IDBIndexBackendInterface.h" 34 #include "IDBKeyPath.h" 34 35 #include "IDBKeyRange.h" 35 36 #include "IDBObjectStoreBackendInterface.h" … … 59 60 60 61 WebIDBKeyPath WebIDBObjectStoreImpl::keyPath() const 61 {62 return WebIDBKeyPath(m_objectStore->keyPath());63 }64 65 // FIXME: Remove this method once callers are updated.66 // http://webkit.org/b/8420767 WebString WebIDBObjectStoreImpl::keyPathString() const68 62 { 69 63 return m_objectStore->keyPath(); … … 105 99 } 106 100 107 WebIDBIndex* WebIDBObjectStoreImpl::createIndex(const WebString& name, const Web String& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec)101 WebIDBIndex* WebIDBObjectStoreImpl::createIndex(const WebString& name, const WebIDBKeyPath& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec) 108 102 { 109 103 RefPtr<IDBIndexBackendInterface> index = m_objectStore->createIndex(name, keyPath, unique, multiEntry, transaction.getIDBTransactionBackendInterface(), ec); -
trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h
r117509 r117817 48 48 WebString name() const; 49 49 WebIDBKeyPath keyPath() const; 50 // FIXME: Remove this method once callers are updated.51 // http://webkit.org/b/8420752 WebString keyPathString() const;53 50 WebDOMStringList indexNames() const; 54 51 bool autoIncrement() const; … … 60 57 void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); 61 58 62 // FIXME: Remove WebString keyPath overload once callers are updated. 63 // http://webkit.org/b/84207 64 WebIDBIndex* createIndex(const WebString&, const WebString&, bool, bool, const WebIDBTransaction&, WebExceptionCode&); 65 WebIDBIndex* createIndex(const WebString& name, const WebIDBKeyPath& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec) { return createIndex(name, keyPath.string(), unique, multiEntry, transaction, ec); } 59 WebIDBIndex* createIndex(const WebString& name, const WebIDBKeyPath&, bool unique, bool multiEntry, const WebIDBTransaction&, WebExceptionCode&); 66 60 WebIDBIndex* index(const WebString& name, WebExceptionCode&); 67 61 void deleteIndex(const WebString& name, const WebIDBTransaction&, WebExceptionCode&); -
trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp
r110104 r117817 42 42 PassRefPtr<IDBKey> checkKeyFromValueAndKeyPathInternal(SerializedScriptValue* value, const String& keyPath) 43 43 { 44 Vector<String> idbKeyPath; 45 IDBKeyPathParseError parseError; 46 IDBParseKeyPath(keyPath, idbKeyPath, parseError); 47 EXPECT_EQ(IDBKeyPathParseErrorNone, parseError); 44 IDBKeyPath idbKeyPath(keyPath); 45 EXPECT_TRUE(idbKeyPath.isValid()); 48 46 return createIDBKeyFromSerializedValueAndKeyPath(value, idbKeyPath); 49 47 } … … 57 55 PassRefPtr<SerializedScriptValue> injectKey(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const String& keyPath) 58 56 { 59 Vector<String> idbKeyPath; 60 IDBKeyPathParseError parseError; 61 IDBParseKeyPath(keyPath, idbKeyPath, parseError); 62 EXPECT_EQ(IDBKeyPathParseErrorNone, parseError); 57 IDBKeyPath idbKeyPath(keyPath); 58 EXPECT_TRUE(idbKeyPath.isValid()); 63 59 return injectIDBKeyIntoSerializedValue(key, value, idbKeyPath); 64 60 } -
trunk/Source/WebKit/chromium/tests/IDBKeyPathTest.cpp
r95901 r117817 38 38 void checkKeyPath(const String& keyPath, const Vector<String>& expected, int parserError) 39 39 { 40 IDBKeyPath idbKeyPath(keyPath); 41 ASSERT_EQ(idbKeyPath.type(), IDBKeyPath::StringType); 42 ASSERT_EQ(idbKeyPath.isValid(), (parserError == IDBKeyPathParseErrorNone)); 43 40 44 IDBKeyPathParseError error; 41 45 Vector<String> keyPathElements; -
trunk/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp
r116333 r117817 31 31 32 32 #include "IDBKey.h" 33 #include "IDBKeyPath.h" 33 34 #include "LevelDBSlice.h" 34 35 #include <gtest/gtest.h> … … 417 418 EXPECT_EQ(v.data() + v.size(), p); 418 419 EXPECT_EQ(0, decodeIDBKey(v.data(), v.data() + v.size() - 1, decodedKey)); 420 } 421 422 TEST(IDBLevelDBCodingTest, EncodeIDBKeyPath) 423 { 424 const unsigned char kIDBKeyPathTypeCodedByte1 = 0; 425 const unsigned char kIDBKeyPathTypeCodedByte2 = 0; 426 { 427 IDBKeyPath keyPath; 428 EXPECT_EQ(keyPath.type(), IDBKeyPath::NullType); 429 Vector<char> v = encodeIDBKeyPath(keyPath); 430 EXPECT_EQ(v.size(), 3U); 431 EXPECT_EQ(v[0], kIDBKeyPathTypeCodedByte1); 432 EXPECT_EQ(v[1], kIDBKeyPathTypeCodedByte2); 433 EXPECT_EQ(v[2], IDBKeyPath::NullType); 434 } 435 436 { 437 Vector<String> testCases; 438 testCases.append(""); 439 testCases.append("foo"); 440 testCases.append("foo.bar"); 441 442 for (size_t i = 0; i < testCases.size(); ++i) { 443 IDBKeyPath keyPath = IDBKeyPath(testCases[i]); 444 Vector<char> v = encodeIDBKeyPath(keyPath); 445 EXPECT_EQ(v.size(), encodeStringWithLength(testCases[i]).size() + 3); 446 const char* p = v.data(); 447 const char* limit = v.data() + v.size(); 448 EXPECT_EQ(*p++, kIDBKeyPathTypeCodedByte1); 449 EXPECT_EQ(*p++, kIDBKeyPathTypeCodedByte2); 450 EXPECT_EQ(*p++, IDBKeyPath::StringType); 451 String string; 452 p = decodeStringWithLength(p, limit, string); 453 EXPECT_EQ(string, testCases[i]); 454 EXPECT_EQ(p, limit); 455 } 456 } 457 458 { 459 Vector<String> testCase; 460 testCase.append(""); 461 testCase.append("foo"); 462 testCase.append("foo.bar"); 463 464 IDBKeyPath keyPath(testCase); 465 EXPECT_EQ(keyPath.type(), IDBKeyPath::ArrayType); 466 Vector<char> v = encodeIDBKeyPath(keyPath); 467 const char* p = v.data(); 468 const char* limit = v.data() + v.size(); 469 EXPECT_EQ(*p++, kIDBKeyPathTypeCodedByte1); 470 EXPECT_EQ(*p++, kIDBKeyPathTypeCodedByte2); 471 EXPECT_EQ(*p++, IDBKeyPath::ArrayType); 472 int64_t count; 473 p = decodeVarInt(p, limit, count); 474 EXPECT_EQ(count, static_cast<int64_t>(testCase.size())); 475 for (size_t i = 0; i < static_cast<size_t>(count); ++i) { 476 String string; 477 p = decodeStringWithLength(p, limit, string); 478 EXPECT_EQ(string, testCase[i]); 479 } 480 EXPECT_EQ(p, limit); 481 } 482 } 483 484 TEST(IDBLevelDBCodingTest, DecodeIDBKeyPath) 485 { 486 const unsigned char kIDBKeyPathTypeCodedByte1 = 0; 487 const unsigned char kIDBKeyPathTypeCodedByte2 = 0; 488 { 489 // Legacy encoding of string key paths. 490 Vector<String> testCases; 491 testCases.append(""); 492 testCases.append("foo"); 493 testCases.append("foo.bar"); 494 495 for (size_t i = 0; i < testCases.size(); ++i) { 496 Vector<char> v = encodeString(testCases[i]); 497 IDBKeyPath keyPath = decodeIDBKeyPath(v.data(), v.data() + v.size()); 498 EXPECT_EQ(keyPath.type(), IDBKeyPath::StringType); 499 EXPECT_EQ(testCases[i], keyPath.string()); 500 } 501 } 502 { 503 Vector<char> v; 504 v.append(kIDBKeyPathTypeCodedByte1); 505 v.append(kIDBKeyPathTypeCodedByte2); 506 v.append(IDBKeyPath::NullType); 507 IDBKeyPath keyPath = decodeIDBKeyPath(v.data(), v.data() + v.size()); 508 EXPECT_EQ(keyPath.type(), IDBKeyPath::NullType); 509 EXPECT_TRUE(keyPath.isNull()); 510 } 511 { 512 Vector<String> testCases; 513 testCases.append(""); 514 testCases.append("foo"); 515 testCases.append("foo.bar"); 516 517 for (size_t i = 0; i < testCases.size(); ++i) { 518 Vector<char> v; 519 v.append(kIDBKeyPathTypeCodedByte1); 520 v.append(kIDBKeyPathTypeCodedByte2); 521 v.append(IDBKeyPath::StringType); 522 v.append(encodeStringWithLength(testCases[i])); 523 IDBKeyPath keyPath = decodeIDBKeyPath(v.data(), v.data() + v.size()); 524 EXPECT_EQ(keyPath.type(), IDBKeyPath::StringType); 525 EXPECT_EQ(testCases[i], keyPath.string()); 526 } 527 } 528 { 529 Vector<String> testCase; 530 testCase.append(""); 531 testCase.append("foo"); 532 testCase.append("foo.bar"); 533 534 Vector<char> v; 535 v.append(kIDBKeyPathTypeCodedByte1); 536 v.append(kIDBKeyPathTypeCodedByte2); 537 v.append(IDBKeyPath::ArrayType); 538 v.append(encodeVarInt(testCase.size())); 539 for (size_t i = 0; i < testCase.size(); ++i) 540 v.append(encodeStringWithLength(testCase[i])); 541 IDBKeyPath keyPath = decodeIDBKeyPath(v.data(), v.data() + v.size()); 542 EXPECT_EQ(keyPath.type(), IDBKeyPath::ArrayType); 543 EXPECT_EQ(keyPath.array().size(), testCase.size()); 544 for (size_t i = 0; i < testCase.size(); ++i) 545 EXPECT_EQ(keyPath.array()[i], testCase[i]); 546 } 419 547 } 420 548
Note: See TracChangeset
for help on using the changeset viewer.