Changeset 83443 in webkit
- Timestamp:
- Apr 11, 2011 8:56:50 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r83441 r83443 1 2011-04-05 Hans Wennborg <hans@chromium.org> 2 3 Reviewed by Steve Block. 4 5 IndexedDB: Introduce skeleton for LevelDB backend 6 https://bugs.webkit.org/show_bug.cgi?id=57827 7 8 No new tests: no new functionality (yet). 9 10 * WebCore.gyp/WebCore.gyp: 11 Add dependency on leveldb when ENABLE_LEVELDB=1 in feature_defines. 12 * WebCore.gypi: 13 Add new files. 14 * storage/IDBBackingStore.h: 15 (WebCore::IDBBackingStore::ObjectStoreRecordIdentifier::~ObjectStoreRecordIdentifier): 16 Introduce abstract type ObjectStoreRecordIdentifier. The SQLite 17 backend uses integers to refer to a specific row in a table, but 18 the LevelDB backend will use something else. 19 * storage/IDBDatabaseBackendImpl.cpp: 20 (WebCore::IDBDatabaseBackendImpl::createObjectStore): 21 (WebCore::IDBDatabaseBackendImpl::createObjectStoreInternal): 22 (WebCore::IDBDatabaseBackendImpl::deleteObjectStoreInternal): 23 (WebCore::IDBDatabaseBackendImpl::loadObjectStores): 24 Change functions to pass along the database id for operations that 25 concern object stores. We want to be able to group object stores 26 ids per database. 27 * storage/IDBFactoryBackendImpl.cpp: 28 (WebCore::IDBFactoryBackendImpl::open): 29 Decide which backend to use based on the backingStoreType 30 parameter. 31 * storage/IDBIndexBackendImpl.cpp: 32 (WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl): 33 (WebCore::IDBIndexBackendImpl::openCursorInternal): 34 (WebCore::IDBIndexBackendImpl::getInternal): 35 (WebCore::IDBIndexBackendImpl::addingKeyAllowed): 36 * storage/IDBIndexBackendImpl.h: 37 (WebCore::IDBIndexBackendImpl::create): 38 Pass database and object store id to backend functions concerning 39 indexes. 40 * storage/IDBLevelDBBackingStore.cpp: Added. 41 (WebCore::IDBLevelDBBackingStore::IDBLevelDBBackingStore): 42 (WebCore::IDBLevelDBBackingStore::~IDBLevelDBBackingStore): 43 (WebCore::IDBLevelDBBackingStore::open): 44 (WebCore::IDBLevelDBBackingStore::extractIDBDatabaseMetaData): 45 (WebCore::IDBLevelDBBackingStore::setIDBDatabaseMetaData): 46 (WebCore::IDBLevelDBBackingStore::getObjectStores): 47 (WebCore::IDBLevelDBBackingStore::createObjectStore): 48 (WebCore::IDBLevelDBBackingStore::deleteObjectStore): 49 (WebCore::IDBLevelDBBackingStore::getObjectStoreRecord): 50 (WebCore::IDBLevelDBBackingStore::putObjectStoreRecord): 51 (WebCore::IDBLevelDBBackingStore::clearObjectStore): 52 (WebCore::IDBLevelDBBackingStore::deleteObjectStoreRecord): 53 (WebCore::IDBLevelDBBackingStore::nextAutoIncrementNumber): 54 (WebCore::IDBLevelDBBackingStore::keyExistsInObjectStore): 55 (WebCore::IDBLevelDBBackingStore::forEachObjectStoreRecord): 56 (WebCore::IDBLevelDBBackingStore::getIndexes): 57 (WebCore::IDBLevelDBBackingStore::createIndex): 58 (WebCore::IDBLevelDBBackingStore::deleteIndex): 59 (WebCore::IDBLevelDBBackingStore::putIndexDataForRecord): 60 (WebCore::IDBLevelDBBackingStore::deleteIndexDataForRecord): 61 (WebCore::IDBLevelDBBackingStore::getObjectViaIndex): 62 (WebCore::IDBLevelDBBackingStore::getPrimaryKeyViaIndex): 63 (WebCore::IDBLevelDBBackingStore::keyExistsInIndex): 64 (WebCore::IDBLevelDBBackingStore::openObjectStoreCursor): 65 (WebCore::IDBLevelDBBackingStore::openIndexKeyCursor): 66 (WebCore::IDBLevelDBBackingStore::openIndexCursor): 67 (WebCore::IDBLevelDBBackingStore::createTransaction): 68 * storage/IDBLevelDBBackingStore.h: Added. 69 Add an empty implementation of the LevelDB backend. 70 * storage/IDBObjectStoreBackendImpl.cpp: 71 Keep track of database id, use the new RecordIdentifier. 72 (WebCore::IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl): 73 (WebCore::IDBObjectStoreBackendImpl::getInternal): 74 (WebCore::IDBObjectStoreBackendImpl::putInternal): 75 (WebCore::IDBObjectStoreBackendImpl::deleteInternal): 76 (WebCore::IDBObjectStoreBackendImpl::clearInternal): 77 (WebCore::populateIndex): 78 (WebCore::IDBObjectStoreBackendImpl::createIndex): 79 (WebCore::IDBObjectStoreBackendImpl::createIndexInternal): 80 (WebCore::IDBObjectStoreBackendImpl::deleteIndexInternal): 81 (WebCore::IDBObjectStoreBackendImpl::openCursorInternal): 82 (WebCore::IDBObjectStoreBackendImpl::loadIndexes): 83 (WebCore::IDBObjectStoreBackendImpl::genAutoIncrementKey): 84 * storage/IDBObjectStoreBackendImpl.h: 85 (WebCore::IDBObjectStoreBackendImpl::create): 86 (WebCore::IDBObjectStoreBackendImpl::databaseId): 87 * storage/IDBSQLiteBackingStore.cpp: 88 (WebCore::IDBSQLiteBackingStore::open): 89 (WebCore::IDBSQLiteBackingStore::createObjectStore): 90 (WebCore::IDBSQLiteBackingStore::deleteObjectStore): 91 (WebCore::IDBSQLiteBackingStore::getObjectStoreRecord): 92 (WebCore::IDBSQLiteBackingStore::putObjectStoreRecord): 93 (WebCore::IDBSQLiteBackingStore::clearObjectStore): 94 (WebCore::IDBSQLiteBackingStore::deleteObjectStoreRecord): 95 (WebCore::IDBSQLiteBackingStore::nextAutoIncrementNumber): 96 (WebCore::IDBSQLiteBackingStore::keyExistsInObjectStore): 97 (WebCore::IDBSQLiteBackingStore::forEachObjectStoreRecord): 98 (WebCore::IDBSQLiteBackingStore::getIndexes): 99 (WebCore::IDBSQLiteBackingStore::createIndex): 100 (WebCore::IDBSQLiteBackingStore::deleteIndex): 101 (WebCore::IDBSQLiteBackingStore::putIndexDataForRecord): 102 (WebCore::IDBSQLiteBackingStore::deleteIndexDataForRecord): 103 (WebCore::IDBSQLiteBackingStore::getObjectViaIndex): 104 (WebCore::IDBSQLiteBackingStore::getPrimaryKeyViaIndex): 105 (WebCore::IDBSQLiteBackingStore::keyExistsInIndex): 106 (WebCore::IDBSQLiteBackingStore::openObjectStoreCursor): 107 (WebCore::IDBSQLiteBackingStore::openIndexKeyCursor): 108 (WebCore::IDBSQLiteBackingStore::openIndexCursor): 109 * storage/IDBSQLiteBackingStore.h: 110 1 111 2011-04-11 Alexander Pavlov <apavlov@chromium.org> 2 112 -
trunk/Source/WebCore/WebCore.gyp/WebCore.gyp
r82863 r83443 1185 1185 }, 1186 1186 }], 1187 ['"ENABLE_LEVELDB=1" in feature_defines', { 1188 'dependencies': [ 1189 '<(chromium_src_dir)/third_party/leveldb/leveldb.gyp:leveldb', 1190 ], 1191 'export_dependent_settings': [ 1192 '<(chromium_src_dir)/third_party/leveldb/leveldb.gyp:leveldb', 1193 ], 1194 }], 1187 1195 ], 1188 1196 }, -
trunk/Source/WebCore/WebCore.gypi
r83344 r83443 5481 5481 'storage/IDBKeyRange.cpp', 5482 5482 'storage/IDBKeyRange.h', 5483 'storage/IDBLevelDBBackingStore.cpp', 5484 'storage/IDBLevelDBBackingStore.h', 5483 5485 'storage/IDBObjectStore.cpp', 5484 5486 'storage/IDBObjectStore.h', -
trunk/Source/WebCore/storage/IDBBackingStore.h
r80834 r83443 51 51 52 52 virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) = 0; 53 virtual bool createObjectStore(const String& name, const String& keyPath, bool autoIncrement, int64_t databaseId, int64_t& assignedObjectStoreId) = 0; 54 virtual void deleteObjectStore(int64_t objectStoreId) = 0; 55 virtual String getObjectStoreRecord(int64_t objectStoreId, const IDBKey&) = 0; 56 virtual bool putObjectStoreRecord(int64_t objectStoreId, const IDBKey&, const String& value, int64_t& rowId, bool invalidRowId) = 0; 57 virtual void clearObjectStore(int64_t objectStoreId) = 0; 58 virtual void deleteObjectStoreRecord(int64_t objectStoreId, int64_t objectStoreDataId) = 0; 59 virtual double nextAutoIncrementNumber(int64_t objectStoreId) = 0; 60 virtual bool keyExistsInObjectStore(int64_t objectStoreId, const IDBKey&, int64_t& foundObjectStoreDataId) = 0; 53 virtual bool createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) = 0; 54 virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId) = 0; 55 56 class ObjectStoreRecordIdentifier : public RefCounted<ObjectStoreRecordIdentifier> { 57 public: 58 virtual bool isValid() const = 0; 59 virtual ~ObjectStoreRecordIdentifier() {} 60 }; 61 virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier() = 0; 62 63 virtual String getObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&) = 0; 64 virtual bool putObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*) = 0; 65 virtual void clearObjectStore(int64_t databaseId, int64_t objectStoreId) = 0; 66 virtual void deleteObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*) = 0; 67 virtual double nextAutoIncrementNumber(int64_t databaseId, int64_t objectStoreId) = 0; 68 virtual bool keyExistsInObjectStore(int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier) = 0; 61 69 62 70 class ObjectStoreRecordCallback { 63 71 public: 64 virtual bool callback( int64_t objectStoreDataId, const String& value) = 0;72 virtual bool callback(const ObjectStoreRecordIdentifier*, const String& value) = 0; 65 73 virtual ~ObjectStoreRecordCallback() {}; 66 74 }; 67 virtual bool forEachObjectStoreRecord(int64_t objectStoreId, ObjectStoreRecordCallback&) = 0;75 virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) = 0; 68 76 69 virtual void getIndexes(int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags) = 0;70 virtual bool createIndex(int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, int64_t& indexId) = 0;71 virtual void deleteIndex(int64_t indexId) = 0;72 virtual bool putIndexDataForRecord(int64_t indexId, const IDBKey&, int64_t objectStoreDataId) = 0;73 virtual bool deleteIndexDataForRecord(int64_t objectStoreDataId) = 0;74 virtual String getObjectViaIndex(int64_t indexId, const IDBKey&) = 0;75 virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t indexId, const IDBKey&) = 0;76 virtual bool keyExistsInIndex(int64_t indexId, const IDBKey&) = 0;77 virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags) = 0; 78 virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, int64_t& indexId) = 0; 79 virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId) = 0; 80 virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) = 0; 81 virtual bool deleteIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) = 0; 82 virtual String getObjectViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) = 0; 83 virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) = 0; 84 virtual bool keyExistsInIndex(int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey&) = 0; 77 85 78 86 class Cursor : public RefCounted<Cursor> { … … 82 90 virtual PassRefPtr<IDBKey> primaryKey() = 0; 83 91 virtual String value() = 0; 84 virtual int64_t objectStoreDataId() = 0;92 virtual PassRefPtr<ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() = 0; 85 93 virtual int64_t indexDataId() = 0; 86 94 virtual ~Cursor() {}; 87 95 }; 88 96 89 virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) = 0;90 virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) = 0;91 virtual PassRefPtr<Cursor> openIndexCursor(int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) = 0;97 virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) = 0; 98 virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) = 0; 99 virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) = 0; 92 100 93 101 class Transaction : public RefCounted<Transaction> { -
trunk/Source/WebCore/storage/IDBDatabaseBackendImpl.cpp
r80315 r83443 1 1 /* 2 * Copyright (C) 201 0Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 98 98 } 99 99 100 PassRefPtr<IDBObjectStoreBackendInterface> 100 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec) 101 101 { 102 102 ASSERT(transactionPtr->mode() == IDBTransaction::VERSION_CHANGE); … … 107 107 } 108 108 109 RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(m_backingStore.get(), name, keyPath, autoIncrement);109 RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(m_backingStore.get(), m_id, name, keyPath, autoIncrement); 110 110 ASSERT(objectStore->name() == name); 111 111 … … 126 126 int64_t objectStoreId; 127 127 128 if (!database->m_backingStore->createObjectStore( objectStore->name(), objectStore->keyPath(), objectStore->autoIncrement(), database->id(), objectStoreId)) {128 if (!database->m_backingStore->createObjectStore(database->id(), objectStore->name(), objectStore->keyPath(), objectStore->autoIncrement(), objectStoreId)) { 129 129 transaction->abort(); 130 130 return; … … 159 159 void IDBDatabaseBackendImpl::deleteObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBTransactionBackendInterface> transaction) 160 160 { 161 database->m_backingStore->deleteObjectStore( objectStore->id());161 database->m_backingStore->deleteObjectStore(database->id(), objectStore->id()); 162 162 transaction->didCompleteTaskEvents(); 163 163 } … … 251 251 252 252 for (size_t i = 0; i < ids.size(); i++) 253 m_objectStores.set(names[i], IDBObjectStoreBackendImpl::create(m_backingStore.get(), ids[i], names[i], keyPaths[i], autoIncrementFlags[i]));253 m_objectStores.set(names[i], IDBObjectStoreBackendImpl::create(m_backingStore.get(), m_id, ids[i], names[i], keyPaths[i], autoIncrementFlags[i])); 254 254 } 255 255 -
trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp
r80834 r83443 1 1 /* 2 * Copyright (C) 201 0Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "IDBDatabaseBackendImpl.h" 34 34 #include "IDBDatabaseException.h" 35 #include "IDBLevelDBBackingStore.h" 35 36 #include "IDBSQLiteBackingStore.h" 36 37 #include "IDBTransactionCoordinator.h" … … 70 71 } 71 72 72 void IDBFactoryBackendImpl::open(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType )73 void IDBFactoryBackendImpl::open(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType backingStoreType) 73 74 { 74 75 String fileIdentifier = securityOrigin->databaseIdentifier(); … … 87 88 backingStore = it2->second; 88 89 else { 89 backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this); 90 if (backingStoreType == DefaultBackingStore) 91 backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this); 92 #if ENABLE(LEVELDB) 93 else if (backingStoreType == LevelDBBackingStore) 94 backingStore = IDBLevelDBBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this); 95 #endif 90 96 if (!backingStore) { 91 97 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error.")); -
trunk/Source/WebCore/storage/IDBIndexBackendImpl.cpp
r80220 r83443 1 1 /* 2 * Copyright (C) 201 0Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 41 41 namespace WebCore { 42 42 43 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique)43 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique) 44 44 : m_backingStore(backingStore) 45 , m_databaseId(databaseId) 46 , m_objectStoreBackend(objectStoreBackend) 45 47 , m_id(id) 46 48 , m_name(name) … … 51 53 } 52 54 53 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, const String& name, const String& storeName, const String& keyPath, bool unique)55 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& storeName, const String& keyPath, bool unique) 54 56 : m_backingStore(backingStore) 57 , m_databaseId(databaseId) 58 , m_objectStoreBackend(objectStoreBackend) 55 59 , m_id(InvalidId) 56 60 , m_name(name) … … 73 77 switch (cursorType) { 74 78 case IDBCursorBackendInterface::IndexKeyCursor: 75 backingStoreCursor = index->m_backingStore->openIndexKeyCursor(index-> id(), range.get(), direction);79 backingStoreCursor = index->m_backingStore->openIndexKeyCursor(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), range.get(), direction); 76 80 break; 77 81 case IDBCursorBackendInterface::IndexCursor: 78 backingStoreCursor = index->m_backingStore->openIndexCursor(index-> id(), range.get(), direction);82 backingStoreCursor = index->m_backingStore->openIndexCursor(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), range.get(), direction); 79 83 break; 80 84 case IDBCursorBackendInterface::ObjectStoreCursor: … … 121 125 // FIXME: Split getInternal into two functions, getting rid off |getObject|. 122 126 if (getObject) { 123 String value = index->m_backingStore->getObjectViaIndex(index-> id(), *key);127 String value = index->m_backingStore->getObjectViaIndex(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), *key); 124 128 if (value.isNull()) { 125 129 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the index.")); … … 128 132 callbacks->onSuccess(SerializedScriptValue::createFromWire(value)); 129 133 } else { 130 RefPtr<IDBKey> keyResult = index->m_backingStore->getPrimaryKeyViaIndex(index-> id(), *key);134 RefPtr<IDBKey> keyResult = index->m_backingStore->getPrimaryKeyViaIndex(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), *key); 131 135 if (!keyResult) { 132 136 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the index.")); … … 160 164 return true; 161 165 162 return !m_backingStore->keyExistsInIndex(m_ id, *key);166 return !m_backingStore->keyExistsInIndex(m_databaseId, m_objectStoreBackend->id(), m_id, *key); 163 167 } 164 168 -
trunk/Source/WebCore/storage/IDBIndexBackendImpl.h
r80315 r83443 1 1 /* 2 * Copyright (C) 201 0Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 41 41 class IDBIndexBackendImpl : public IDBIndexBackendInterface { 42 42 public: 43 static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique)43 static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique) 44 44 { 45 return adoptRef(new IDBIndexBackendImpl(backingStore, id, name, storeName, keyPath, unique));45 return adoptRef(new IDBIndexBackendImpl(backingStore, databaseId, objectStoreBackend, id, name, storeName, keyPath, unique)); 46 46 } 47 static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, const String& name, const String& storeName, const String& keyPath, bool unique)47 static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& storeName, const String& keyPath, bool unique) 48 48 { 49 return adoptRef(new IDBIndexBackendImpl(backingStore, name, storeName, keyPath, unique));49 return adoptRef(new IDBIndexBackendImpl(backingStore, databaseId, objectStoreBackend, name, storeName, keyPath, unique)); 50 50 } 51 51 virtual ~IDBIndexBackendImpl(); … … 73 73 74 74 private: 75 IDBIndexBackendImpl(IDBBackingStore*, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique);76 IDBIndexBackendImpl(IDBBackingStore*, const String& name, const String& storeName, const String& keyPath, bool unique);75 IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, const IDBObjectStoreBackendImpl*, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique); 76 IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, const IDBObjectStoreBackendImpl*, const String& name, const String& storeName, const String& keyPath, bool unique); 77 77 78 78 static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKeyRange>, unsigned short direction, IDBCursorBackendInterface::CursorType, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>); … … 83 83 RefPtr<IDBBackingStore> m_backingStore; 84 84 85 int64_t m_databaseId; 86 const IDBObjectStoreBackendImpl* m_objectStoreBackend; 85 87 int64_t m_id; 86 88 String m_name; -
trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
r80220 r83443 1 1 /* 2 * Copyright (C) 201 0Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 51 51 } 52 52 53 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t id, const String& name, const String& keyPath, bool autoIncrement)53 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement) 54 54 : m_backingStore(backingStore) 55 , m_databaseId(databaseId) 55 56 , m_id(id) 56 57 , m_name(name) … … 62 63 } 63 64 64 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, const String& name, const String& keyPath, bool autoIncrement)65 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement) 65 66 : m_backingStore(backingStore) 67 , m_databaseId(databaseId) 66 68 , m_id(InvalidId) 67 69 , m_name(name) … … 91 93 void IDBObjectStoreBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks) 92 94 { 93 String wireData = objectStore->m_backingStore->getObjectStoreRecord(objectStore-> id(), *key);95 String wireData = objectStore->m_backingStore->getObjectStoreRecord(objectStore->m_databaseId, objectStore->id(), *key); 94 96 if (wireData.isNull()) { 95 97 callbacks->onSuccess(SerializedScriptValue::undefinedValue()); … … 228 230 } 229 231 230 int64_t dataRowId = InvalidId;231 bool isExistingValue = objectStore->m_backingStore->keyExistsInObjectStore(objectStore-> id(), *key, dataRowId);232 RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier = objectStore->m_backingStore->createInvalidRecordIdentifier(); 233 bool isExistingValue = objectStore->m_backingStore->keyExistsInObjectStore(objectStore->m_databaseId, objectStore->id(), *key, recordIdentifier.get()); 232 234 233 235 if (putMode == AddOnly && isExistingValue) { … … 238 240 // Before this point, don't do any mutation. After this point, rollback the transaction in case of error. 239 241 240 if (!objectStore->m_backingStore->putObjectStoreRecord(objectStore->id(), *key, value->toWireString(), dataRowId, dataRowId == InvalidId)) { 241 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 242 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.")); 243 transaction->abort(); 244 return; 245 } 246 247 if (!objectStore->m_backingStore->deleteIndexDataForRecord(dataRowId)) { 242 if (!objectStore->m_backingStore->putObjectStoreRecord(objectStore->m_databaseId, objectStore->id(), *key, value->toWireString(), recordIdentifier.get())) { 248 243 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 249 244 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.")); … … 256 251 if (!it->second->hasValidId()) 257 252 continue; // The index object has been created, but does not exist in the database yet. 258 if (!objectStore->m_backingStore->putIndexDataForRecord(it->second->id(), *indexKeys[i], dataRowId)) { 253 254 if (!objectStore->m_backingStore->deleteIndexDataForRecord(objectStore->m_databaseId, objectStore->id(), it->second->id(), recordIdentifier.get())) { 259 255 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 260 256 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.")); … … 262 258 return; 263 259 } 260 261 if (!objectStore->m_backingStore->putIndexDataForRecord(objectStore->m_databaseId, objectStore->id(), it->second->id(), *indexKeys[i], recordIdentifier.get())) { 262 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 263 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.")); 264 transaction->abort(); 265 return; 266 } 264 267 } 265 268 … … 284 287 void IDBObjectStoreBackendImpl::deleteInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks) 285 288 { 286 int64_t id;287 if (!objectStore->m_backingStore->keyExistsInObjectStore(objectStore-> id(), *key, id)) {289 RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier = objectStore->m_backingStore->createInvalidRecordIdentifier(); 290 if (!objectStore->m_backingStore->keyExistsInObjectStore(objectStore->m_databaseId, objectStore->id(), *key, recordIdentifier.get())) { 288 291 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the object store.")); 289 292 return; 290 293 } 291 294 292 objectStore->m_backingStore->deleteObjectStoreRecord(objectStore->id(), id); 295 for (IndexMap::iterator it = objectStore->m_indexes.begin(); it != objectStore->m_indexes.end(); ++it) { 296 if (!it->second->hasValidId()) 297 continue; // The index object has been created, but does not exist in the database yet. 298 299 if (!objectStore->m_backingStore->deleteIndexDataForRecord(objectStore->m_databaseId, objectStore->id(), it->second->id(), recordIdentifier.get())) 300 ASSERT_NOT_REACHED(); 301 } 302 303 objectStore->m_backingStore->deleteObjectStoreRecord(objectStore->m_databaseId, objectStore->id(), recordIdentifier.get()); 293 304 callbacks->onSuccess(SerializedScriptValue::nullValue()); 294 305 } … … 310 321 void IDBObjectStoreBackendImpl::clearInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBCallbacks> callbacks) 311 322 { 312 objectStore->m_backingStore->clearObjectStore(objectStore-> id());323 objectStore->m_backingStore->clearObjectStore(objectStore->m_databaseId, objectStore->id()); 313 324 callbacks->onSuccess(SerializedScriptValue::undefinedValue()); 314 325 } … … 317 328 class PopulateIndexCallback : public IDBBackingStore::ObjectStoreRecordCallback { 318 329 public: 319 PopulateIndexCallback(IDBBackingStore& backingStore, const String& indexKeyPath, int64_t indexId)330 PopulateIndexCallback(IDBBackingStore& backingStore, const String& indexKeyPath, int64_t databaseId, int64_t objectStoreId, int64_t indexId) 320 331 : m_backingStore(backingStore) 321 332 , m_indexKeyPath(indexKeyPath) 333 , m_databaseId(databaseId) 334 , m_objectStoreId(objectStoreId) 322 335 , m_indexId(indexId) 323 336 { 324 337 } 325 338 326 virtual bool callback( int64_t objectStoreDataId, const String& value)339 virtual bool callback(const IDBBackingStore::ObjectStoreRecordIdentifier* recordIdentifier, const String& value) 327 340 { 328 341 RefPtr<SerializedScriptValue> objectValue = SerializedScriptValue::createFromWire(value); 329 342 RefPtr<IDBKey> indexKey = fetchKeyFromKeyPath(objectValue.get(), m_indexKeyPath); 330 343 331 if (!m_backingStore.putIndexDataForRecord(m_ indexId, *indexKey, objectStoreDataId))344 if (!m_backingStore.putIndexDataForRecord(m_databaseId, m_objectStoreId, m_indexId, *indexKey, recordIdentifier)) 332 345 return false; 333 346 … … 338 351 IDBBackingStore& m_backingStore; 339 352 const String& m_indexKeyPath; 353 int64_t m_databaseId; 354 int64_t m_objectStoreId; 340 355 int64_t m_indexId; 341 356 }; 342 357 } 343 358 344 static bool populateIndex(IDBBackingStore& backingStore, int64_t objectStoreId, int64_t indexId, const String& indexKeyPath)345 { 346 PopulateIndexCallback callback(backingStore, indexKeyPath, indexId);347 if (!backingStore.forEachObjectStoreRecord( objectStoreId, callback))359 static bool populateIndex(IDBBackingStore& backingStore, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& indexKeyPath) 360 { 361 PopulateIndexCallback callback(backingStore, indexKeyPath, databaseId, objectStoreId, indexId); 362 if (!backingStore.forEachObjectStoreRecord(databaseId, objectStoreId, callback)) 348 363 return false; 349 364 return true; … … 361 376 } 362 377 363 RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(m_backingStore.get(), name, m_name, keyPath, unique);378 RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(m_backingStore.get(), m_databaseId, this, name, m_name, keyPath, unique); 364 379 ASSERT(index->name() == name); 365 380 … … 379 394 { 380 395 int64_t id; 381 if (!objectStore->m_backingStore->createIndex(objectStore->m_ id, index->name(), index->keyPath(), index->unique(), id)) {396 if (!objectStore->m_backingStore->createIndex(objectStore->m_databaseId, objectStore->id(), index->name(), index->keyPath(), index->unique(), id)) { 382 397 transaction->abort(); 383 398 return; … … 386 401 index->setId(id); 387 402 388 if (!populateIndex(*objectStore->m_backingStore, objectStore->m_ id, id, index->keyPath())) {403 if (!populateIndex(*objectStore->m_backingStore, objectStore->m_databaseId, objectStore->m_id, id, index->keyPath())) { 389 404 transaction->abort(); 390 405 return; … … 429 444 void IDBObjectStoreBackendImpl::deleteIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index, PassRefPtr<IDBTransactionBackendInterface> transaction) 430 445 { 431 objectStore->m_backingStore->deleteIndex( index->id());446 objectStore->m_backingStore->deleteIndex(objectStore->m_databaseId, objectStore->id(), index->id()); 432 447 transaction->didCompleteTaskEvents(); 433 448 } … … 447 462 IDBCursor::Direction direction = static_cast<IDBCursor::Direction>(tmpDirection); 448 463 449 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->m_backingStore->openObjectStoreCursor(objectStore-> id(), range.get(), direction);464 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->m_backingStore->openObjectStoreCursor(objectStore->m_databaseId, objectStore->id(), range.get(), direction); 450 465 if (!backingStoreCursor) { 451 466 callbacks->onSuccess(SerializedScriptValue::nullValue()); … … 463 478 Vector<String> keyPaths; 464 479 Vector<bool> uniqueFlags; 465 m_backingStore->getIndexes(m_ id, ids, names, keyPaths, uniqueFlags);480 m_backingStore->getIndexes(m_databaseId, m_id, ids, names, keyPaths, uniqueFlags); 466 481 467 482 ASSERT(names.size() == ids.size()); … … 470 485 471 486 for (size_t i = 0; i < ids.size(); i++) 472 m_indexes.set(names[i], IDBIndexBackendImpl::create(m_backingStore.get(), ids[i], names[i], m_name, keyPaths[i], uniqueFlags[i]));487 m_indexes.set(names[i], IDBIndexBackendImpl::create(m_backingStore.get(), m_databaseId, this, ids[i], names[i], m_name, keyPaths[i], uniqueFlags[i])); 473 488 } 474 489 … … 491 506 return IDBKey::createNumber(m_autoIncrementNumber++); 492 507 493 m_autoIncrementNumber = static_cast<int>(m_backingStore->nextAutoIncrementNumber( id()));508 m_autoIncrementNumber = static_cast<int>(m_backingStore->nextAutoIncrementNumber(m_databaseId, id())); 494 509 return IDBKey::createNumber(m_autoIncrementNumber++); 495 510 } -
trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.h
r80315 r83443 1 1 /* 2 * Copyright (C) 201 0Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 43 43 class IDBObjectStoreBackendImpl : public IDBObjectStoreBackendInterface { 44 44 public: 45 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t id, const String& name, const String& keyPath, bool autoIncrement)45 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement) 46 46 { 47 return adoptRef(new IDBObjectStoreBackendImpl(backingStore, id, name, keyPath, autoIncrement));47 return adoptRef(new IDBObjectStoreBackendImpl(backingStore, databaseId, id, name, keyPath, autoIncrement)); 48 48 } 49 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, const String& name, const String& keyPath, bool autoIncrement)49 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement) 50 50 { 51 return adoptRef(new IDBObjectStoreBackendImpl(backingStore, name, keyPath, autoIncrement));51 return adoptRef(new IDBObjectStoreBackendImpl(backingStore, databaseId, name, keyPath, autoIncrement)); 52 52 } 53 53 virtual ~IDBObjectStoreBackendImpl(); … … 60 60 } 61 61 void setId(int64_t id) { m_id = id; } 62 int64_t databaseId() const { return m_databaseId; } 62 63 63 64 virtual String name() const { return m_name; } … … 78 79 79 80 private: 80 IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t id, const String& name, const String& keyPath, bool autoIncrement);81 IDBObjectStoreBackendImpl(IDBBackingStore*, const String& name, const String& keyPath, bool autoIncrement);81 IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement); 82 IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement); 82 83 83 84 void loadIndexes(); … … 100 101 RefPtr<IDBBackingStore> m_backingStore; 101 102 103 int64_t m_databaseId; 102 104 int64_t m_id; 103 105 String m_name; -
trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp
r80834 r83443 174 174 if (!makeAllDirectories(pathBase)) { 175 175 // FIXME: Is there any other thing we could possibly do to recover at this point? If so, do it rather than just erroring out. 176 LOG_ERROR("Unable d to create LocalStoragedatabase path %s", pathBase.utf8().data());176 LOG_ERROR("Unable to create Indexed DB database path %s", pathBase.utf8().data()); 177 177 return 0; 178 178 } … … 264 264 } 265 265 266 bool IDBSQLiteBackingStore::createObjectStore( const String& name, const String& keyPath, bool autoIncrement, int64_t databaseId, int64_t& assignedObjectStoreId)266 bool IDBSQLiteBackingStore::createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) 267 267 { 268 268 SQLiteStatement query(m_db, "INSERT INTO ObjectStores (name, keyPath, doAutoIncrement, databaseId) VALUES (?, ?, ?, ?)"); … … 292 292 } 293 293 294 void IDBSQLiteBackingStore::deleteObjectStore(int64_t objectStoreId)294 void IDBSQLiteBackingStore::deleteObjectStore(int64_t, int64_t objectStoreId) 295 295 { 296 296 doDelete(m_db, "DELETE FROM ObjectStores WHERE id = ?", objectStoreId); … … 298 298 doDelete(m_db, "DELETE FROM IndexData WHERE indexId IN (SELECT id FROM Indexes WHERE objectStoreId = ?)", objectStoreId); 299 299 doDelete(m_db, "DELETE FROM Indexes WHERE objectStoreId = ?", objectStoreId); 300 } 301 302 namespace { 303 class SQLiteRecordIdentifier : public IDBBackingStore::ObjectStoreRecordIdentifier { 304 public: 305 static PassRefPtr<SQLiteRecordIdentifier> create() { return adoptRef(new SQLiteRecordIdentifier()); } 306 static PassRefPtr<SQLiteRecordIdentifier> create(int64_t id) { return adoptRef(new SQLiteRecordIdentifier(id)); } 307 virtual bool isValid() const { return m_id != -1; } 308 int64_t id() const { return m_id; } 309 void setId(int64_t id) { m_id = id; } 310 private: 311 SQLiteRecordIdentifier() : m_id(-1) { } 312 SQLiteRecordIdentifier(int64_t id) : m_id(id) { } 313 int64_t m_id; 314 }; 315 } 316 317 PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> IDBSQLiteBackingStore::createInvalidRecordIdentifier() 318 { 319 return SQLiteRecordIdentifier::create(); 300 320 } 301 321 … … 374 394 } 375 395 376 String IDBSQLiteBackingStore::getObjectStoreRecord(int64_t objectStoreId, const IDBKey& key)396 String IDBSQLiteBackingStore::getObjectStoreRecord(int64_t, int64_t objectStoreId, const IDBKey& key) 377 397 { 378 398 SQLiteStatement query(m_db, "SELECT keyString, keyDate, keyNumber, value FROM ObjectStoreData WHERE objectStoreId = ? AND " + whereSyntaxForKey(key)); … … 423 443 } 424 444 425 bool IDBSQLiteBackingStore::putObjectStoreRecord(int64_t objectStoreId, const IDBKey& key, const String& value, int64_t& rowId, bool invalidRowId) 426 { 427 String sql = !invalidRowId ? "UPDATE ObjectStoreData SET keyString = ?, keyDate = ?, keyNumber = ?, value = ? WHERE id = ?" 428 : "INSERT INTO ObjectStoreData (keyString, keyDate, keyNumber, value, objectStoreId) VALUES (?, ?, ?, ?, ?)"; 445 bool IDBSQLiteBackingStore::putObjectStoreRecord(int64_t, int64_t objectStoreId, const IDBKey& key, const String& value, ObjectStoreRecordIdentifier* recordIdentifier) 446 { 447 SQLiteRecordIdentifier* sqliteRecordIdentifier = static_cast<SQLiteRecordIdentifier*>(recordIdentifier); 448 449 String sql = sqliteRecordIdentifier->isValid() ? "UPDATE ObjectStoreData SET keyString = ?, keyDate = ?, keyNumber = ?, value = ? WHERE id = ?" 450 : "INSERT INTO ObjectStoreData (keyString, keyDate, keyNumber, value, objectStoreId) VALUES (?, ?, ?, ?, ?)"; 429 451 SQLiteStatement query(m_db, sql); 430 452 if (query.prepare() != SQLResultOk) … … 433 455 bindKeyToQueryWithNulls(query, 1, key); 434 456 query.bindBlob(4, value); 435 if ( !invalidRowId)436 query.bindInt64(5, rowId);457 if (sqliteRecordIdentifier->isValid()) 458 query.bindInt64(5, sqliteRecordIdentifier->id()); 437 459 else 438 460 query.bindInt64(5, objectStoreId); … … 441 463 return false; 442 464 443 if ( invalidRowId)444 rowId = m_db.lastInsertRowID();465 if (!sqliteRecordIdentifier->isValid()) 466 sqliteRecordIdentifier->setId(m_db.lastInsertRowID()); 445 467 446 468 return true; 447 469 } 448 470 449 void IDBSQLiteBackingStore::clearObjectStore(int64_t objectStoreId)471 void IDBSQLiteBackingStore::clearObjectStore(int64_t, int64_t objectStoreId) 450 472 { 451 473 doDelete(m_db, "DELETE FROM IndexData WHERE objectStoreDataId IN (SELECT id FROM ObjectStoreData WHERE objectStoreId = ?)", objectStoreId); … … 453 475 } 454 476 455 void IDBSQLiteBackingStore::deleteObjectStoreRecord(int64_t, int64_t objectStoreDataId) 456 { 477 void IDBSQLiteBackingStore::deleteObjectStoreRecord(int64_t, int64_t objectStoreId, const ObjectStoreRecordIdentifier* recordIdentifier) 478 { 479 const SQLiteRecordIdentifier* sqliteRecordIdentifier = static_cast<const SQLiteRecordIdentifier*>(recordIdentifier); 480 ASSERT(sqliteRecordIdentifier->isValid()); 481 457 482 SQLiteStatement osQuery(m_db, "DELETE FROM ObjectStoreData WHERE id = ?"); 458 483 bool ok = osQuery.prepare() == SQLResultOk; 459 484 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling? 460 485 461 osQuery.bindInt64(1, objectStoreDataId);486 osQuery.bindInt64(1, sqliteRecordIdentifier->id()); 462 487 463 488 ok = osQuery.step() == SQLResultDone; 464 489 ASSERT_UNUSED(ok, ok); 465 466 SQLiteStatement indexQuery(m_db, "DELETE FROM IndexData WHERE objectStoreDataId = ?"); 467 ok = indexQuery.prepare() == SQLResultOk; 468 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling? 469 470 indexQuery.bindInt64(1, objectStoreDataId); 471 472 ok = indexQuery.step() == SQLResultDone; 473 ASSERT_UNUSED(ok, ok); 474 } 475 476 double IDBSQLiteBackingStore::nextAutoIncrementNumber(int64_t objectStoreId) 490 } 491 492 double IDBSQLiteBackingStore::nextAutoIncrementNumber(int64_t, int64_t objectStoreId) 477 493 { 478 494 SQLiteStatement query(m_db, "SELECT max(keyNumber) + 1 FROM ObjectStoreData WHERE objectStoreId = ? AND keyString IS NULL AND keyDate IS NULL"); … … 488 504 } 489 505 490 bool IDBSQLiteBackingStore::keyExistsInObjectStore(int64_t objectStoreId, const IDBKey& key, int64_t& foundObjectStoreDataId) 491 { 506 bool IDBSQLiteBackingStore::keyExistsInObjectStore(int64_t, int64_t objectStoreId, const IDBKey& key, ObjectStoreRecordIdentifier* foundRecordIdentifier) 507 { 508 SQLiteRecordIdentifier* sqliteRecordIdentifier = static_cast<SQLiteRecordIdentifier*>(foundRecordIdentifier); 509 492 510 String sql = String("SELECT id FROM ObjectStoreData WHERE objectStoreId = ? AND ") + whereSyntaxForKey(key); 493 511 SQLiteStatement query(m_db, sql); … … 501 519 return false; 502 520 503 foundObjectStoreDataId = query.getColumnInt64(0);521 sqliteRecordIdentifier->setId(query.getColumnInt64(0)); 504 522 return true; 505 523 } 506 524 507 bool IDBSQLiteBackingStore::forEachObjectStoreRecord(int64_t objectStoreId, ObjectStoreRecordCallback& callback)525 bool IDBSQLiteBackingStore::forEachObjectStoreRecord(int64_t, int64_t objectStoreId, ObjectStoreRecordCallback& callback) 508 526 { 509 527 SQLiteStatement query(m_db, "SELECT id, value FROM ObjectStoreData WHERE objectStoreId = ?"); … … 516 534 int64_t objectStoreDataId = query.getColumnInt64(0); 517 535 String value = query.getColumnBlobAsString(1); 518 if (!callback.callback(objectStoreDataId, value)) 536 RefPtr<SQLiteRecordIdentifier> recordIdentifier = SQLiteRecordIdentifier::create(objectStoreDataId); 537 if (!callback.callback(recordIdentifier.get(), value)) 519 538 return false; 520 539 } … … 523 542 } 524 543 525 void IDBSQLiteBackingStore::getIndexes(int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags)544 void IDBSQLiteBackingStore::getIndexes(int64_t, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags) 526 545 { 527 546 SQLiteStatement query(m_db, "SELECT id, name, keyPath, isUnique FROM Indexes WHERE objectStoreId = ?"); … … 544 563 } 545 564 546 bool IDBSQLiteBackingStore::createIndex(int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, int64_t& indexId)565 bool IDBSQLiteBackingStore::createIndex(int64_t, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, int64_t& indexId) 547 566 { 548 567 SQLiteStatement query(m_db, "INSERT INTO Indexes (objectStoreId, name, keyPath, isUnique) VALUES (?, ?, ?, ?)"); … … 562 581 } 563 582 564 void IDBSQLiteBackingStore::deleteIndex(int64_t indexId)583 void IDBSQLiteBackingStore::deleteIndex(int64_t, int64_t, int64_t indexId) 565 584 { 566 585 doDelete(m_db, "DELETE FROM Indexes WHERE id = ?", indexId); … … 568 587 } 569 588 570 bool IDBSQLiteBackingStore::putIndexDataForRecord(int64_t indexId, const IDBKey& key, int64_t objectStoreDataId) 571 { 589 bool IDBSQLiteBackingStore::putIndexDataForRecord(int64_t, int64_t, int64_t indexId, const IDBKey& key, const ObjectStoreRecordIdentifier* recordIdentifier) 590 { 591 const SQLiteRecordIdentifier* sqliteRecordIdentifier = static_cast<const SQLiteRecordIdentifier*>(recordIdentifier); 592 572 593 SQLiteStatement query(m_db, "INSERT INTO IndexData (keyString, keyDate, keyNumber, indexId, objectStoreDataId) VALUES (?, ?, ?, ?, ?)"); 573 594 if (query.prepare() != SQLResultOk) … … 576 597 bindKeyToQueryWithNulls(query, 1, key); 577 598 query.bindInt64(4, indexId); 578 query.bindInt64(5, objectStoreDataId);599 query.bindInt64(5, sqliteRecordIdentifier->id()); 579 600 580 601 return query.step() == SQLResultDone; 581 602 } 582 603 583 bool IDBSQLiteBackingStore::deleteIndexDataForRecord(int64_t objectStoreDataId) 584 { 585 SQLiteStatement query(m_db, "DELETE FROM IndexData WHERE objectStoreDataId = ?"); 604 bool IDBSQLiteBackingStore::deleteIndexDataForRecord(int64_t, int64_t, int64_t indexId, const ObjectStoreRecordIdentifier* recordIdentifier) 605 { 606 const SQLiteRecordIdentifier* sqliteRecordIdentifier = static_cast<const SQLiteRecordIdentifier*>(recordIdentifier); 607 608 SQLiteStatement query(m_db, "DELETE FROM IndexData WHERE objectStoreDataId = ? AND indexId = ?"); 586 609 if (query.prepare() != SQLResultOk) 587 610 return false; 588 611 589 query.bindInt64(1, objectStoreDataId); 612 query.bindInt64(1, sqliteRecordIdentifier->id()); 613 query.bindInt64(2, indexId); 590 614 return query.step() == SQLResultDone; 591 615 } 592 616 593 String IDBSQLiteBackingStore::getObjectViaIndex(int64_t indexId, const IDBKey& key)617 String IDBSQLiteBackingStore::getObjectViaIndex(int64_t, int64_t, int64_t indexId, const IDBKey& key) 594 618 { 595 619 String sql = String("SELECT ") … … 630 654 } 631 655 632 PassRefPtr<IDBKey> IDBSQLiteBackingStore::getPrimaryKeyViaIndex(int64_t indexId, const IDBKey& key)656 PassRefPtr<IDBKey> IDBSQLiteBackingStore::getPrimaryKeyViaIndex(int64_t, int64_t, int64_t indexId, const IDBKey& key) 633 657 { 634 658 String sql = String("SELECT ") … … 652 676 } 653 677 654 bool IDBSQLiteBackingStore::keyExistsInIndex(int64_t indexId, const IDBKey& key)678 bool IDBSQLiteBackingStore::keyExistsInIndex(int64_t, int64_t, int64_t indexId, const IDBKey& key) 655 679 { 656 680 String sql = String("SELECT id FROM IndexData WHERE indexId = ? AND ") + whereSyntaxForKey(key); … … 683 707 virtual PassRefPtr<IDBKey> primaryKey() { return m_currentKey; } 684 708 virtual String value() = 0; 685 virtual int64_t objectStoreDataId() = 0;709 virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() = 0; 686 710 virtual int64_t indexDataId() = 0; 687 711 … … 742 766 // CursorImplCommon. 743 767 virtual String value() { return m_currentValue; } 744 virtual int64_t objectStoreDataId() { return m_currentId; }768 virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() { return SQLiteRecordIdentifier::create(m_currentId); } 745 769 virtual int64_t indexDataId() { ASSERT_NOT_REACHED(); return 0; } 746 770 virtual void loadCurrentRow(); … … 780 804 virtual PassRefPtr<IDBKey> primaryKey() { return m_currentPrimaryKey; } 781 805 virtual String value() { ASSERT_NOT_REACHED(); return String(); } 782 virtual int64_t objectStoreDataId() { ASSERT_NOT_REACHED(); return 0; }806 virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() { ASSERT_NOT_REACHED(); return 0; } 783 807 virtual int64_t indexDataId() { return m_currentId; } 784 808 virtual void loadCurrentRow(); … … 818 842 virtual PassRefPtr<IDBKey> primaryKey() { return m_currentPrimaryKey; } 819 843 virtual String value() { return m_currentValue; } 820 virtual int64_t objectStoreDataId() { ASSERT_NOT_REACHED(); return 0; }844 virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() { ASSERT_NOT_REACHED(); return 0; } 821 845 virtual int64_t indexDataId() { return m_currentId; } 822 846 virtual void loadCurrentRow(); … … 850 874 } // namespace 851 875 852 PassRefPtr<IDBBackingStore::Cursor> IDBSQLiteBackingStore::openObjectStoreCursor(int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction)876 PassRefPtr<IDBBackingStore::Cursor> IDBSQLiteBackingStore::openObjectStoreCursor(int64_t, int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction) 853 877 { 854 878 bool lowerBound = range && range->lower(); … … 887 911 } 888 912 889 PassRefPtr<IDBBackingStore::Cursor> IDBSQLiteBackingStore::openIndexKeyCursor(int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction)913 PassRefPtr<IDBBackingStore::Cursor> IDBSQLiteBackingStore::openIndexKeyCursor(int64_t, int64_t, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction) 890 914 { 891 915 String sql = String("SELECT IndexData.id, IndexData.keyString, IndexData.keyDate, IndexData.keyNumber, ") … … 927 951 } 928 952 929 PassRefPtr<IDBBackingStore::Cursor> IDBSQLiteBackingStore::openIndexCursor(int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction)953 PassRefPtr<IDBBackingStore::Cursor> IDBSQLiteBackingStore::openIndexCursor(int64_t, int64_t, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction) 930 954 { 931 955 String sql = String("SELECT IndexData.id, IndexData.keyString, IndexData.keyDate, IndexData.keyNumber, ") -
trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h
r80834 r83443 42 42 43 43 virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags); 44 virtual bool createObjectStore(const String& name, const String& keyPath, bool autoIncrement, int64_t databaseId, int64_t& assignedObjectStoreId); 45 virtual void deleteObjectStore(int64_t objectStoreId); 46 virtual String getObjectStoreRecord(int64_t objectStoreId, const IDBKey&); 47 virtual bool putObjectStoreRecord(int64_t objectStoreId, const IDBKey&, const String& value, int64_t& rowId, bool invalidRowId); 48 virtual void clearObjectStore(int64_t objectStoreId); 49 virtual void deleteObjectStoreRecord(int64_t objectStoreId, int64_t objectStoreDataId); 50 virtual double nextAutoIncrementNumber(int64_t objectStoreId); 51 virtual bool keyExistsInObjectStore(int64_t objectStoreId, const IDBKey&, int64_t& foundObjectStoreDataId); 44 virtual bool createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId); 45 virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId); 46 virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier(); 47 virtual String getObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&); 48 virtual bool putObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*); 49 virtual void clearObjectStore(int64_t databaseId, int64_t objectStoreId); 50 virtual void deleteObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*); 51 virtual double nextAutoIncrementNumber(int64_t databaseId, int64_t objectStoreId); 52 virtual bool keyExistsInObjectStore(int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier); 52 53 53 virtual bool forEachObjectStoreRecord(int64_t objectStoreId, ObjectStoreRecordCallback&);54 virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&); 54 55 55 virtual void getIndexes(int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags);56 virtual bool createIndex(int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, int64_t& indexId);57 virtual void deleteIndex(int64_t indexId);58 virtual bool putIndexDataForRecord(int64_t indexId, const IDBKey&, int64_t objectStoreDataId);59 virtual bool deleteIndexDataForRecord(int64_t objectStoreDataId);60 virtual String getObjectViaIndex(int64_t indexId, const IDBKey&);61 virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t indexId, const IDBKey&);62 virtual bool keyExistsInIndex(int64_t indexId, const IDBKey&);56 virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags); 57 virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, int64_t& indexId); 58 virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId); 59 virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*); 60 virtual bool deleteIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*); 61 virtual String getObjectViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&); 62 virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&); 63 virtual bool keyExistsInIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&); 63 64 64 virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction);65 virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t indexId, const IDBKeyRange*, IDBCursor::Direction);66 virtual PassRefPtr<Cursor> openIndexCursor(int64_t indexId, const IDBKeyRange*, IDBCursor::Direction);65 virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction); 66 virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction); 67 virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction); 67 68 68 69 virtual PassRefPtr<Transaction> createTransaction(); -
trunk/Source/WebKit/chromium/ChangeLog
r83420 r83443 1 2011-04-05 Hans Wennborg <hans@chromium.org> 2 3 Reviewed by Steve Block. 4 5 IndexedDB: Introduce skeleton for LevelDB backend 6 https://bugs.webkit.org/show_bug.cgi?id=57827 7 8 * features.gypi: 9 Add ENABLE_LEVELDB=0. 10 * public/WebIDBFactory.h: 11 (WebKit::WebIDBFactory::open): 12 Remove pre-roll open() function. 13 1 14 2011-04-10 Kent Tamura <tkent@chromium.org> 2 15 -
trunk/Source/WebKit/chromium/features.gypi
r83342 r83443 66 66 'ENABLE_JAVASCRIPT_DEBUGGER=1', 67 67 'ENABLE_JSC_MULTIPLE_THREADS=0', 68 'ENABLE_LEVELDB=0', 68 69 'ENABLE_LINK_PREFETCH=1', 69 70 'ENABLE_MATHML=0', -
trunk/Source/WebKit/chromium/public/WebIDBFactory.h
r80635 r83443 1 1 /* 2 * Copyright (C) 201 0Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 58 58 59 59 // The WebKit implementation of open ignores the WebFrame* parameter. 60 // FIXME: Assert not reached when Chromium side is updated. 61 virtual void open(const WebString& name, WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame* frame, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType) { open(name, callbacks, origin, frame, dataDir, maximumSize); } 62 63 // FIXME: Remove this when Chromium side is updated. 64 virtual void open(const WebString& name, WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame* frame, const WebString& dataDir, unsigned long long maximumSize) { open(name, callbacks, origin, frame, dataDir, maximumSize, DefaultBackingStore); } 60 virtual void open(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType) { WEBKIT_ASSERT_NOT_REACHED(); } 65 61 66 62 virtual void deleteDatabase(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir) { WEBKIT_ASSERT_NOT_REACHED(); }
Note: See TracChangeset
for help on using the changeset viewer.