Changeset 113473 in webkit
- Timestamp:
- Apr 6, 2012 12:06:47 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r113472 r113473 1 2012-04-06 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: ObjectStore/Index shouldn't hold reference to backing store 4 https://bugs.webkit.org/show_bug.cgi?id=83074 5 6 We should be able to collect and close the leveldb backing store as soon as the database 7 connection is closed, but the IDBObjectStoreBackendImpl and IDBIndexBackendImpl were 8 holding RefPtrs, and those objects are kept alive by script references. 9 10 Replaced RefPtrs to the IDBBackingStore with pointers to the IDBDatabase. On the back end, 11 IDBDatabaseBackendImpl maintains a RefPtr to the IDBObjectStoreBackendImpl object, so 12 a raw pointer back is safe. On the front end, the IDBObjectStore maintains a RefPtr to 13 the IDBDatabase so script can navigate upwards. Ditto on both ends for the ObjectStore/Index 14 relationship. The frontend objects maintain RefPtrs to the backend objects, so the backend 15 objects and their owners are maintained as long as there's a script reference. 16 17 Also made IDBDatabaseBackendImpl handle a null IDBFactoryBackendImpl pointer, for testing. 18 19 Reviewed by Tony Chang. 20 21 Tests: webkit_unit_tests --gtest_filter="IDBDatabaseBackendTest.*" 22 23 * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: 24 (WebCore::IDBDatabaseBackendImpl::~IDBDatabaseBackendImpl): 25 (WebCore::IDBDatabaseBackendImpl::createObjectStore): 26 (WebCore::IDBDatabaseBackendImpl::loadObjectStores): 27 * Modules/indexeddb/IDBIndexBackendImpl.cpp: 28 (WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl): 29 (WebCore::IDBIndexBackendImpl::openCursorInternal): 30 (WebCore::IDBIndexBackendImpl::countInternal): 31 (WebCore::IDBIndexBackendImpl::getInternal): 32 (WebCore::IDBIndexBackendImpl::addingKeyAllowed): 33 * Modules/indexeddb/IDBIndexBackendImpl.h: 34 (WebCore::IDBIndexBackendImpl::create): 35 (IDBIndexBackendImpl): 36 (WebCore::IDBIndexBackendImpl::backingStore): 37 (WebCore::IDBIndexBackendImpl::databaseId): 38 * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp: 39 (WebCore::IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl): 40 (WebCore::IDBObjectStoreBackendImpl::getInternal): 41 (WebCore::IDBObjectStoreBackendImpl::putInternal): 42 (WebCore::IDBObjectStoreBackendImpl::deleteInternal): 43 (WebCore::IDBObjectStoreBackendImpl::clearInternal): 44 (WebCore): 45 (WebCore::IDBObjectStoreBackendImpl::createIndex): 46 (WebCore::IDBObjectStoreBackendImpl::createIndexInternal): 47 (WebCore::IDBObjectStoreBackendImpl::deleteIndexInternal): 48 (WebCore::IDBObjectStoreBackendImpl::openCursorInternal): 49 (WebCore::IDBObjectStoreBackendImpl::countInternal): 50 (WebCore::IDBObjectStoreBackendImpl::loadIndexes): 51 (WebCore::IDBObjectStoreBackendImpl::genAutoIncrementKey): 52 * Modules/indexeddb/IDBObjectStoreBackendImpl.h: 53 (WebCore::IDBObjectStoreBackendImpl::create): 54 (IDBObjectStoreBackendImpl): 55 (WebCore::IDBObjectStoreBackendImpl::backingStore): 56 (WebCore::IDBObjectStoreBackendImpl::databaseId): 57 1 58 2012-04-06 Jon Lee <jonlee@apple.com> 2 59 -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
r109493 r113473 121 121 IDBDatabaseBackendImpl::~IDBDatabaseBackendImpl() 122 122 { 123 m_factory->removeIDBDatabaseBackend(m_identifier); 123 // This check should only be false in tests. 124 if (m_factory) 125 m_factory->removeIDBDatabaseBackend(m_identifier); 124 126 } 125 127 … … 147 149 } 148 150 149 RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create( m_backingStore.get(), m_id, name, keyPath, autoIncrement);151 RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(this, name, keyPath, autoIncrement); 150 152 ASSERT(objectStore->name() == name); 151 153 … … 386 388 387 389 for (size_t i = 0; i < ids.size(); i++) 388 m_objectStores.set(names[i], IDBObjectStoreBackendImpl::create( m_backingStore.get(), m_id, ids[i], names[i], keyPaths[i], autoIncrementFlags[i]));390 m_objectStores.set(names[i], IDBObjectStoreBackendImpl::create(this, ids[i], names[i], keyPaths[i], autoIncrementFlags[i])); 389 391 } 390 392 -
trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp
r110539 r113473 42 42 namespace WebCore { 43 43 44 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry) 45 : m_backingStore(backingStore) 46 , m_databaseId(databaseId) 44 IDBIndexBackendImpl::IDBIndexBackendImpl(const IDBDatabaseBackendImpl* database, const IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry) 45 : m_database(database) 47 46 , m_objectStoreBackend(objectStoreBackend) 48 47 , m_id(id) … … 55 54 } 56 55 57 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry) 58 : m_backingStore(backingStore) 59 , m_databaseId(databaseId) 56 IDBIndexBackendImpl::IDBIndexBackendImpl(const IDBDatabaseBackendImpl* database, const IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry) 57 : m_database(database) 60 58 , m_objectStoreBackend(objectStoreBackend) 61 59 , m_id(InvalidId) … … 81 79 switch (cursorType) { 82 80 case IDBCursorBackendInterface::IndexKeyCursor: 83 backingStoreCursor = index-> m_backingStore->openIndexKeyCursor(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), range.get(), direction);81 backingStoreCursor = index->backingStore()->openIndexKeyCursor(index->databaseId(), index->m_objectStoreBackend->id(), index->id(), range.get(), direction); 84 82 break; 85 83 case IDBCursorBackendInterface::IndexCursor: 86 backingStoreCursor = index-> m_backingStore->openIndexCursor(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), range.get(), direction);84 backingStoreCursor = index->backingStore()->openIndexCursor(index->databaseId(), index->m_objectStoreBackend->id(), index->id(), range.get(), direction); 87 85 break; 88 86 case IDBCursorBackendInterface::ObjectStoreCursor: … … 132 130 uint32_t count = 0; 133 131 134 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = index-> m_backingStore->openIndexKeyCursor(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), range.get(), IDBCursor::NEXT);132 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = index->backingStore()->openIndexKeyCursor(index->databaseId(), index->m_objectStoreBackend->id(), index->id(), range.get(), IDBCursor::NEXT); 135 133 if (!backingStoreCursor) { 136 134 callbacks->onSuccess(SerializedScriptValue::numberValue(count)); … … 157 155 // FIXME: Split getInternal into two functions, getting rid off |getObject|. 158 156 if (getObject) { 159 String value = index-> m_backingStore->getObjectViaIndex(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), *key);157 String value = index->backingStore()->getObjectViaIndex(index->databaseId(), index->m_objectStoreBackend->id(), index->id(), *key); 160 158 if (value.isNull()) { 161 159 callbacks->onSuccess(SerializedScriptValue::undefinedValue()); … … 164 162 callbacks->onSuccess(SerializedScriptValue::createFromWire(value)); 165 163 } else { 166 RefPtr<IDBKey> keyResult = index-> m_backingStore->getPrimaryKeyViaIndex(index->m_databaseId, index->m_objectStoreBackend->id(), index->id(), *key);164 RefPtr<IDBKey> keyResult = index->backingStore()->getPrimaryKeyViaIndex(index->databaseId(), index->m_objectStoreBackend->id(), index->id(), *key); 167 165 if (!keyResult) { 168 166 callbacks->onSuccess(static_cast<IDBKey*>(0)); … … 199 197 200 198 RefPtr<IDBKey> foundPrimaryKey; 201 bool found = m_backingStore->keyExistsInIndex(m_databaseId, m_objectStoreBackend->id(), m_id, *indexKey, foundPrimaryKey);199 bool found = backingStore()->keyExistsInIndex(databaseId(), m_objectStoreBackend->id(), m_id, *indexKey, foundPrimaryKey); 202 200 if (!found) 203 201 return true; -
trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h
r109493 r113473 30 30 31 31 #include "IDBCursorBackendInterface.h" 32 #include "IDBDatabaseBackendImpl.h" 32 33 #include "IDBIndexBackendInterface.h" 33 34 … … 41 42 class IDBIndexBackendImpl : public IDBIndexBackendInterface { 42 43 public: 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, bool multiEntry)44 static PassRefPtr<IDBIndexBackendImpl> create(const IDBDatabaseBackendImpl* database, const IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry) 44 45 { 45 return adoptRef(new IDBIndexBackendImpl( backingStore, databaseId, objectStoreBackend, id, name, storeName, keyPath, unique, multiEntry));46 return adoptRef(new IDBIndexBackendImpl(database, objectStoreBackend, id, name, storeName, keyPath, unique, multiEntry)); 46 47 } 47 static PassRefPtr<IDBIndexBackendImpl> create( IDBBackingStore* backingStore, int64_t databaseId, const IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry)48 static PassRefPtr<IDBIndexBackendImpl> create(const IDBDatabaseBackendImpl* database, const IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry) 48 49 { 49 return adoptRef(new IDBIndexBackendImpl( backingStore, databaseId, objectStoreBackend, name, storeName, keyPath, unique, multiEntry));50 return adoptRef(new IDBIndexBackendImpl(database, objectStoreBackend, name, storeName, keyPath, unique, multiEntry)); 50 51 } 51 52 virtual ~IDBIndexBackendImpl(); … … 75 76 76 77 private: 77 IDBIndexBackendImpl( IDBBackingStore*, int64_t databaseId, const IDBObjectStoreBackendImpl*, int64_t id, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry);78 IDBIndexBackendImpl( IDBBackingStore*, int64_t databaseId, const IDBObjectStoreBackendImpl*, const String& name, const String& storeName, const String& keyPath, bool unique, bool multiEntry);78 IDBIndexBackendImpl(const IDBDatabaseBackendImpl*, const IDBObjectStoreBackendImpl*, int64_t, const String&, const String&, const String&, bool, bool); 79 IDBIndexBackendImpl(const IDBDatabaseBackendImpl*, const IDBObjectStoreBackendImpl*, const String&, const String&, const String&, bool, bool); 79 80 80 81 static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKeyRange>, unsigned short direction, IDBCursorBackendInterface::CursorType, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>); … … 84 85 static const int64_t InvalidId = 0; 85 86 86 RefPtr<IDBBackingStore> m_backingStore; 87 PassRefPtr<IDBBackingStore> backingStore() const { return m_database->backingStore(); } 88 int64_t databaseId() const { return m_database->id(); } 87 89 88 int64_t m_databaseId; 90 const IDBDatabaseBackendImpl* m_database; 91 89 92 const IDBObjectStoreBackendImpl* m_objectStoreBackend; 90 93 int64_t m_id; -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp
r110539 r113473 52 52 } 53 53 54 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement) 55 : m_backingStore(backingStore) 56 , m_databaseId(databaseId) 54 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(const IDBDatabaseBackendImpl* database, int64_t id, const String& name, const String& keyPath, bool autoIncrement) 55 : m_database(database) 57 56 , m_id(id) 58 57 , m_name(name) … … 64 63 } 65 64 66 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement) 67 : m_backingStore(backingStore) 68 , m_databaseId(databaseId) 65 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(const IDBDatabaseBackendImpl* database, const String& name, const String& keyPath, bool autoIncrement) 66 : m_database(database) 69 67 , m_id(InvalidId) 70 68 , m_name(name) … … 97 95 { 98 96 IDB_TRACE("IDBObjectStoreBackendImpl::getInternal"); 99 String wireData = objectStore-> m_backingStore->getObjectStoreRecord(objectStore->m_databaseId, objectStore->id(), *key);97 String wireData = objectStore->backingStore()->getObjectStoreRecord(objectStore->databaseId(), objectStore->id(), *key); 100 98 if (wireData.isNull()) { 101 99 callbacks->onSuccess(SerializedScriptValue::undefinedValue()); … … 246 244 ASSERT(key && key->valid()); 247 245 248 RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier = objectStore-> m_backingStore->createInvalidRecordIdentifier();249 if (putMode == AddOnly && objectStore-> m_backingStore->keyExistsInObjectStore(objectStore->m_databaseId, objectStore->id(), *key, recordIdentifier.get())) {246 RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier = objectStore->backingStore()->createInvalidRecordIdentifier(); 247 if (putMode == AddOnly && objectStore->backingStore()->keyExistsInObjectStore(objectStore->databaseId(), objectStore->id(), *key, recordIdentifier.get())) { 250 248 objectStore->resetAutoIncrementKeyCache(); 251 249 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "Key already exists in the object store.")); … … 285 283 // Before this point, don't do any mutation. After this point, rollback the transaction in case of error. 286 284 287 if (!objectStore-> m_backingStore->putObjectStoreRecord(objectStore->m_databaseId, objectStore->id(), *key, value->toWireString(), recordIdentifier.get())) {285 if (!objectStore->backingStore()->putObjectStoreRecord(objectStore->databaseId(), objectStore->id(), *key, value->toWireString(), recordIdentifier.get())) { 288 286 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 289 287 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.")); … … 298 296 continue; // The index object has been created, but does not exist in the database yet. 299 297 300 if (!objectStore-> m_backingStore->deleteIndexDataForRecord(objectStore->m_databaseId, objectStore->id(), index->id(), recordIdentifier.get())) {298 if (!objectStore->backingStore()->deleteIndexDataForRecord(objectStore->databaseId(), objectStore->id(), index->id(), recordIdentifier.get())) { 301 299 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 302 300 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.")); … … 310 308 311 309 if (!index->multiEntry() || indexKey->type() != IDBKey::ArrayType) { 312 if (!objectStore-> m_backingStore->putIndexDataForRecord(objectStore->m_databaseId, objectStore->id(), index->id(), *indexKey, recordIdentifier.get())) {310 if (!objectStore->backingStore()->putIndexDataForRecord(objectStore->databaseId(), objectStore->id(), index->id(), *indexKey, recordIdentifier.get())) { 313 311 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 314 312 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.")); … … 320 318 ASSERT(indexKey->type() == IDBKey::ArrayType); 321 319 for (size_t j = 0; j < indexKey->array().size(); ++j) { 322 if (!objectStore-> m_backingStore->putIndexDataForRecord(objectStore->m_databaseId, objectStore->id(), index->id(), *indexKey->array()[j], recordIdentifier.get())) {320 if (!objectStore->backingStore()->putIndexDataForRecord(objectStore->databaseId(), objectStore->id(), index->id(), *indexKey->array()[j], recordIdentifier.get())) { 323 321 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 324 322 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.")); … … 370 368 RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier; 371 369 372 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore-> m_backingStore->openObjectStoreCursor(objectStore->m_databaseId, objectStore->id(), keyRange.get(), IDBCursor::NEXT);370 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->backingStore()->openObjectStoreCursor(objectStore->databaseId(), objectStore->id(), keyRange.get(), IDBCursor::NEXT); 373 371 if (backingStoreCursor) { 374 372 … … 380 378 continue; // The index object has been created, but does not exist in the database yet. 381 379 382 bool success = objectStore-> m_backingStore->deleteIndexDataForRecord(objectStore->m_databaseId, objectStore->id(), it->second->id(), recordIdentifier.get());380 bool success = objectStore->backingStore()->deleteIndexDataForRecord(objectStore->databaseId(), objectStore->id(), it->second->id(), recordIdentifier.get()); 383 381 ASSERT_UNUSED(success, success); 384 382 } 385 383 386 objectStore-> m_backingStore->deleteObjectStoreRecord(objectStore->m_databaseId, objectStore->id(), recordIdentifier.get());384 objectStore->backingStore()->deleteObjectStoreRecord(objectStore->databaseId(), objectStore->id(), recordIdentifier.get()); 387 385 388 386 } while (backingStoreCursor->continueFunction(0)); … … 411 409 void IDBObjectStoreBackendImpl::clearInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBCallbacks> callbacks) 412 410 { 413 objectStore-> m_backingStore->clearObjectStore(objectStore->m_databaseId, objectStore->id());411 objectStore->backingStore()->clearObjectStore(objectStore->databaseId(), objectStore->id()); 414 412 callbacks->onSuccess(SerializedScriptValue::undefinedValue()); 415 413 } … … 483 481 } 484 482 485 RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(m_ backingStore.get(), m_databaseId, this, name, m_name, keyPath, unique, multiEntry);483 RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(m_database, this, name, m_name, keyPath, unique, multiEntry); 486 484 ASSERT(index->name() == name); 487 485 … … 504 502 { 505 503 int64_t id; 506 if (!objectStore-> m_backingStore->createIndex(objectStore->m_databaseId, objectStore->id(), index->name(), index->keyPath(), index->unique(), index->multiEntry(), id)) {504 if (!objectStore->backingStore()->createIndex(objectStore->databaseId(), objectStore->id(), index->name(), index->keyPath(), index->unique(), index->multiEntry(), id)) { 507 505 transaction->abort(); 508 506 return; … … 511 509 index->setId(id); 512 510 513 if (!populateIndex(*objectStore-> m_backingStore, objectStore->m_databaseId, objectStore->m_id, index)) {511 if (!populateIndex(*objectStore->backingStore(), objectStore->databaseId(), objectStore->m_id, index)) { 514 512 transaction->abort(); 515 513 return; … … 557 555 void IDBObjectStoreBackendImpl::deleteIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index, PassRefPtr<IDBTransactionBackendInterface> transaction) 558 556 { 559 objectStore-> m_backingStore->deleteIndex(objectStore->m_databaseId, objectStore->id(), index->id());557 objectStore->backingStore()->deleteIndex(objectStore->databaseId(), objectStore->id(), index->id()); 560 558 transaction->didCompleteTaskEvents(); 561 559 } … … 580 578 IDBCursor::Direction direction = static_cast<IDBCursor::Direction>(tmpDirection); 581 579 582 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore-> m_backingStore->openObjectStoreCursor(objectStore->m_databaseId, objectStore->id(), range.get(), direction);580 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->backingStore()->openObjectStoreCursor(objectStore->databaseId(), objectStore->id(), range.get(), direction); 583 581 if (!backingStoreCursor) { 584 582 callbacks->onSuccess(SerializedScriptValue::nullValue()); … … 601 599 IDB_TRACE("IDBObjectStoreBackendImpl::countInternal"); 602 600 uint32_t count = 0; 603 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore-> m_backingStore->openObjectStoreCursor(objectStore->m_databaseId, objectStore->id(), range.get(), IDBCursor::NEXT);601 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->backingStore()->openObjectStoreCursor(objectStore->databaseId(), objectStore->id(), range.get(), IDBCursor::NEXT); 604 602 if (!backingStoreCursor) { 605 603 callbacks->onSuccess(SerializedScriptValue::numberValue(count)); … … 622 620 Vector<bool> uniqueFlags; 623 621 Vector<bool> multiEntryFlags; 624 m_backingStore->getIndexes(m_databaseId, m_id, ids, names, keyPaths, uniqueFlags, multiEntryFlags);622 backingStore()->getIndexes(databaseId(), m_id, ids, names, keyPaths, uniqueFlags, multiEntryFlags); 625 623 626 624 ASSERT(names.size() == ids.size()); … … 630 628 631 629 for (size_t i = 0; i < ids.size(); i++) 632 m_indexes.set(names[i], IDBIndexBackendImpl::create(m_ backingStore.get(), m_databaseId, this, ids[i], names[i], m_name, keyPaths[i], uniqueFlags[i], multiEntryFlags[i]));630 m_indexes.set(names[i], IDBIndexBackendImpl::create(m_database, this, ids[i], names[i], m_name, keyPaths[i], uniqueFlags[i], multiEntryFlags[i])); 633 631 } 634 632 … … 651 649 return IDBKey::createNumber(m_autoIncrementNumber++); 652 650 653 m_autoIncrementNumber = static_cast<int>( m_backingStore->nextAutoIncrementNumber(m_databaseId, id()));651 m_autoIncrementNumber = static_cast<int>(backingStore()->nextAutoIncrementNumber(databaseId(), id())); 654 652 return IDBKey::createNumber(m_autoIncrementNumber++); 655 653 } -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h
r109493 r113473 27 27 #define IDBObjectStoreBackendImpl_h 28 28 29 #include "IDBDatabaseBackendImpl.h" 29 30 #include "IDBObjectStoreBackendInterface.h" 30 31 #include <wtf/HashMap.h> … … 35 36 namespace WebCore { 36 37 37 class IDBBackingStore;38 38 class IDBDatabaseBackendImpl; 39 39 class IDBIndexBackendImpl; … … 43 43 class IDBObjectStoreBackendImpl : public IDBObjectStoreBackendInterface { 44 44 public: 45 static PassRefPtr<IDBObjectStoreBackendImpl> create( IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement)45 static PassRefPtr<IDBObjectStoreBackendImpl> create(const IDBDatabaseBackendImpl* database, int64_t id, const String& name, const String& keyPath, bool autoIncrement) 46 46 { 47 return adoptRef(new IDBObjectStoreBackendImpl( backingStore, databaseId, id, name, keyPath, autoIncrement));47 return adoptRef(new IDBObjectStoreBackendImpl(database, id, name, keyPath, autoIncrement)); 48 48 } 49 static PassRefPtr<IDBObjectStoreBackendImpl> create( IDBBackingStore* backingStore, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement)49 static PassRefPtr<IDBObjectStoreBackendImpl> create(const IDBDatabaseBackendImpl* database, const String& name, const String& keyPath, bool autoIncrement) 50 50 { 51 return adoptRef(new IDBObjectStoreBackendImpl( backingStore, databaseId, name, keyPath, autoIncrement));51 return adoptRef(new IDBObjectStoreBackendImpl(database, 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; }63 62 64 63 virtual String name() const { return m_name; } … … 83 82 84 83 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);84 IDBObjectStoreBackendImpl(const IDBDatabaseBackendImpl*, int64_t, const String&, const String&, bool); 85 IDBObjectStoreBackendImpl(const IDBDatabaseBackendImpl*, const String&, const String&, bool); 87 86 88 87 void loadIndexes(); … … 104 103 static void revertAutoIncrementKeyCache(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>); 105 104 106 RefPtr<IDBBackingStore> m_backingStore; 105 PassRefPtr<IDBBackingStore> backingStore() const { return m_database->backingStore(); } 106 int64_t databaseId() const { return m_database->id(); } 107 107 108 int64_t m_databaseId;108 const IDBDatabaseBackendImpl* m_database; 109 109 int64_t m_id; 110 110 String m_name; -
trunk/Source/WebKit/chromium/ChangeLog
r113416 r113473 1 2012-04-06 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: ObjectStore/Index shouldn't hold reference to backing store 4 https://bugs.webkit.org/show_bug.cgi?id=83074 5 6 Reviewed by Tony Chang. 7 8 * WebKit.gypi: 9 * tests/IDBDatabaseBackendTest.cpp: Added. 10 (WebCore): 11 (MockIDBBackingStore): 12 (WebCore::TEST): 13 1 14 2012-04-06 Kent Tamura <tkent@chromium.org> 2 15 -
trunk/Source/WebKit/chromium/WebKit.gypi
r112550 r113473 103 103 'tests/FrameTestHelpers.h', 104 104 'tests/IDBBindingUtilitiesTest.cpp', 105 'tests/IDBDatabaseBackendTest.cpp', 105 106 'tests/IDBKeyPathTest.cpp', 106 107 'tests/IDBLevelDBCodingTest.cpp',
Note: See TracChangeset
for help on using the changeset viewer.