Changeset 117978 in webkit
- Timestamp:
- May 22, 2012 8:55:15 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117977 r117978 1 2012-05-22 David Grogan <dgrogan@chromium.org> 2 3 IndexedDB: Fire error when there are problems opening a DB 4 https://bugs.webkit.org/show_bug.cgi?id=85579 5 6 We used to either fire success or get into an infinite loop. 7 8 Reviewed by Tony Chang. 9 10 New unit test in 11 Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp 12 13 * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: 14 (WebCore::IDBDatabaseBackendImpl::IDBDatabaseBackendImpl): 15 (WebCore::IDBDatabaseBackendImpl::openInternal): 16 (WebCore::IDBDatabaseBackendImpl::openConnection): 17 * Modules/indexeddb/IDBDatabaseBackendImpl.h: 18 (WebCore::IDBDatabaseBackendImpl::create): 19 (IDBDatabaseBackendImpl): 20 * Modules/indexeddb/IDBFactoryBackendImpl.cpp: 21 (WebCore::IDBFactoryBackendImpl::deleteDatabase): 22 (WebCore::IDBFactoryBackendImpl::openInternal): 23 * Modules/indexeddb/IDBFactoryBackendImpl.h: 24 (IDBFactoryBackendImpl): 25 * Modules/indexeddb/IDBLevelDBBackingStore.h: 26 (IDBLevelDBBackingStore): 27 1 28 2012-05-22 Nikolas Zimmermann <nzimmermann@rim.com> 2 29 -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
r117817 r117978 94 94 }; 95 95 96 PassRefPtr<IDBDatabaseBackendImpl> IDBDatabaseBackendImpl::create(const String& name, IDBBackingStore* database, IDBTransactionCoordinator* coordinator, IDBFactoryBackendImpl* factory, const String& uniqueIdentifier) 97 { 98 RefPtr<IDBDatabaseBackendImpl> backend = adoptRef(new IDBDatabaseBackendImpl(name, database, coordinator, factory, uniqueIdentifier)); 99 if (!backend->openInternal()) 100 return 0; 101 return backend.release(); 102 } 103 96 104 IDBDatabaseBackendImpl::IDBDatabaseBackendImpl(const String& name, IDBBackingStore* backingStore, IDBTransactionCoordinator* coordinator, IDBFactoryBackendImpl* factory, const String& uniqueIdentifier) 97 105 : m_backingStore(backingStore) … … 104 112 { 105 113 ASSERT(!m_name.isNull()); 106 openInternal(); 107 } 108 109 void IDBDatabaseBackendImpl::openInternal() 114 } 115 116 bool IDBDatabaseBackendImpl::openInternal() 110 117 { 111 118 bool success = m_backingStore->getIDBDatabaseMetaData(m_name, m_version, m_id); … … 113 120 if (success) { 114 121 loadObjectStores(); 115 return; 116 } 117 if (!m_backingStore->createIDBDatabaseMetaData(m_name, m_version, m_id)) 118 ASSERT_NOT_REACHED(); // FIXME: Need better error handling. 122 return true; 123 } 124 return m_backingStore->createIDBDatabaseMetaData(m_name, m_version, m_id); 119 125 } 120 126 … … 326 332 m_pendingOpenCalls.append(PendingOpenCall::create(callbacks)); 327 333 else { 328 if (m_id == InvalidId) 329 openInternal(); 330 callbacks->onSuccess(this); 334 if (m_id == InvalidId && !openInternal()) 335 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error.")); 336 else 337 callbacks->onSuccess(this); 331 338 } 332 339 } -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h
r117817 r117978 46 46 class IDBDatabaseBackendImpl : public IDBDatabaseBackendInterface { 47 47 public: 48 static PassRefPtr<IDBDatabaseBackendImpl> create(const String& name, IDBBackingStore* database, IDBTransactionCoordinator* coordinator, IDBFactoryBackendImpl* factory, const String& uniqueIdentifier) 49 { 50 return adoptRef(new IDBDatabaseBackendImpl(name, database, coordinator, factory, uniqueIdentifier)); 51 } 48 static PassRefPtr<IDBDatabaseBackendImpl> create(const String& name, IDBBackingStore* database, IDBTransactionCoordinator*, IDBFactoryBackendImpl*, const String& uniqueIdentifier); 52 49 virtual ~IDBDatabaseBackendImpl(); 53 50 … … 80 77 IDBDatabaseBackendImpl(const String& name, IDBBackingStore* database, IDBTransactionCoordinator*, IDBFactoryBackendImpl*, const String& uniqueIdentifier); 81 78 82 voidopenInternal();79 bool openInternal(); 83 80 void loadObjectStores(); 84 81 void processPendingCalls(); -
trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendImpl.cpp
r110539 r117978 130 130 131 131 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::create(name, backingStore.get(), m_transactionCoordinator.get(), this, uniqueIdentifier); 132 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); 133 databaseBackend->deleteDatabase(callbacks); 132 if (databaseBackend) { 133 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); 134 databaseBackend->deleteDatabase(callbacks); 135 } else 136 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error.")); 134 137 } 135 138 … … 178 181 179 182 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::create(name, backingStore.get(), m_transactionCoordinator.get(), this, uniqueIdentifier); 180 callbacks->onSuccess(RefPtr<IDBDatabaseBackendInterface>(databaseBackend.get()).release()); 181 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); 183 if (databaseBackend) { 184 callbacks->onSuccess(RefPtr<IDBDatabaseBackendInterface>(databaseBackend.get()).release()); 185 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); 186 } else 187 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error.")); 182 188 } 183 189 -
trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendImpl.h
r109493 r117978 52 52 53 53 // Notifications from weak pointers. 54 v oid removeIDBDatabaseBackend(const String& uniqueIdentifier);54 virtual void removeIDBDatabaseBackend(const String& uniqueIdentifier); 55 55 void addIDBBackingStore(const String& fileIdentifier, IDBBackingStore*); 56 v oid removeIDBBackingStore(const String& fileIdentifier);56 virtual void removeIDBBackingStore(const String& fileIdentifier); 57 57 58 58 virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir); … … 62 62 virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir); 63 63 64 protected: 65 IDBFactoryBackendImpl(); 66 virtual PassRefPtr<IDBBackingStore> openBackingStore(PassRefPtr<SecurityOrigin>, const String& dataDir); 67 64 68 private: 65 IDBFactoryBackendImpl();66 PassRefPtr<IDBBackingStore> openBackingStore(PassRefPtr<SecurityOrigin>, const String& dataDir);67 69 void openInternal(const String& name, IDBCallbacks*, PassRefPtr<SecurityOrigin>, const String& dataDir); 68 70 -
trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h
r117817 r117978 81 81 static bool backingStoreExists(SecurityOrigin*, const String& name, const String& pathBase); 82 82 83 pr ivate:83 protected: 84 84 IDBLevelDBBackingStore(const String& identifier, IDBFactoryBackendImpl*, PassOwnPtr<LevelDBDatabase>); 85 85 86 private: 86 87 String m_identifier; 87 88 RefPtr<IDBFactoryBackendImpl> m_factory; -
trunk/Source/WebKit/chromium/ChangeLog
r117970 r117978 1 2012-05-22 David Grogan <dgrogan@chromium.org> 2 3 IndexedDB: Fire error when there are problems opening a DB 4 https://bugs.webkit.org/show_bug.cgi?id=85579 5 6 Reviewed by Tony Chang. 7 8 * WebKit.gypi: 9 * tests/IDBAbortOnCorruptTest.cpp: Added. 10 (WebCore): 11 (MockIDBCallbacks): 12 (WebCore::MockIDBCallbacks::MockIDBCallbacks): 13 (WebCore::MockIDBCallbacks::~MockIDBCallbacks): 14 (WebCore::MockIDBCallbacks::onError): 15 (WebCore::MockIDBCallbacks::onSuccess): 16 (WebCore::MockIDBCallbacks::onSuccessWithContinuation): 17 (WebCore::MockIDBCallbacks::onSuccessWithPrefetch): 18 (WebCore::MockIDBCallbacks::onBlocked): 19 (FailingBackingStore): 20 (WebCore::FailingBackingStore::~FailingBackingStore): 21 (WebCore::FailingBackingStore::open): 22 (WebCore::FailingBackingStore::createIDBDatabaseMetaData): 23 (FailingIDBFactoryBackendImpl): 24 (WebCore::FailingIDBFactoryBackendImpl::~FailingIDBFactoryBackendImpl): 25 (WebCore::FailingIDBFactoryBackendImpl::create): 26 (WebCore::FailingIDBFactoryBackendImpl::removeIDBDatabaseBackend): 27 (WebCore::FailingIDBFactoryBackendImpl::openBackingStore): 28 (WebCore::TEST): 29 * tests/IDBFakeBackingStore.h: Copied from Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h. 30 (WebCore): 31 (IDBFakeBackingStore): 32 1 33 2012-05-22 Alexander Pavlov <apavlov@chromium.org> 2 34 -
trunk/Source/WebKit/chromium/WebKit.gypi
r117864 r117978 108 108 'tests/FrameTestHelpers.h', 109 109 'tests/GraphicsLayerChromiumTest.cpp', 110 'tests/IDBAbortOnCorruptTest.cpp', 110 111 'tests/IDBBindingUtilitiesTest.cpp', 112 'tests/IDBFakeBackingStore.h', 111 113 'tests/IDBKeyPathTest.cpp', 112 114 'tests/IDBLevelDBCodingTest.cpp', -
trunk/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
r117977 r117978 1 1 /* 2 * Copyright (C) 201 1Google Inc. All rights reserved.2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef IDBLevelDBBackingStore_h 27 #define IDBLevelDBBackingStore_h 28 29 #if ENABLE(INDEXED_DATABASE) 30 #if USE(LEVELDB) 26 #ifndef IDBFakeBackingStore_h 27 #define IDBFakeBackingStore_h 31 28 32 29 #include "IDBBackingStore.h" 33 #include <wtf/OwnPtr.h>34 30 35 31 namespace WebCore { 36 32 37 class LevelDBComparator; 38 class LevelDBDatabase; 39 class LevelDBTransaction; 40 class IDBFactoryBackendImpl; 33 class IDBFakeBackingStore : public IDBBackingStore { 34 public: 35 virtual void getDatabaseNames(Vector<String>& foundNames) OVERRIDE { } 36 virtual bool getIDBDatabaseMetaData(const String& name, String& foundVersion, int64_t& foundId) OVERRIDE { return false; } 37 virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t& rowId) OVERRIDE { return true; } 38 virtual bool updateIDBDatabaseMetaData(int64_t rowId, const String& version) OVERRIDE { return false; } 39 virtual bool deleteDatabase(const String& name) OVERRIDE { return false; } 41 40 42 class IDBLevelDBBackingStore : public IDBBackingStore { 43 public: 44 static PassRefPtr<IDBBackingStore> open(SecurityOrigin*, const String& pathBase, const String& fileIdentifier, IDBFactoryBackendImpl*); 45 virtual ~IDBLevelDBBackingStore(); 41 virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) OVERRIDE { } 42 virtual bool createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) OVERRIDE { return false; } 43 virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId) OVERRIDE { } 46 44 47 virtual void getDatabaseNames(Vector<String>& foundNames); 48 virtual bool getIDBDatabaseMetaData(const String& name, String& foundVersion, int64_t& foundId); 49 virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t& rowId); 50 virtual bool updateIDBDatabaseMetaData(int64_t rowId, const String& version); 51 virtual bool deleteDatabase(const String& name); 45 virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier() OVERRIDE { return PassRefPtr<ObjectStoreRecordIdentifier>(); } 52 46 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 virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId); 56 virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier(); 57 virtual String getObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&); 58 virtual bool putObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*); 59 virtual void clearObjectStore(int64_t databaseId, int64_t objectStoreId); 60 virtual void deleteObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*); 61 virtual int64_t nextAutoIncrementNumber(int64_t databaseId, int64_t objectStoreId); 62 virtual bool keyExistsInObjectStore(int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier); 47 virtual String getObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&) OVERRIDE { return String(); } 48 virtual bool putObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*) OVERRIDE { return false; } 49 virtual void clearObjectStore(int64_t databaseId, int64_t objectStoreId) OVERRIDE { } 50 virtual void deleteObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*) OVERRIDE { } 51 virtual int64_t nextAutoIncrementNumber(int64_t databaseId, int64_t objectStoreId) OVERRIDE { return 0.0; } 52 virtual bool keyExistsInObjectStore(int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier) OVERRIDE { return false; } 63 53 64 virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) ;54 virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) OVERRIDE { return false; } 65 55 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 virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId) ;69 virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) ;70 virtual bool deleteIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) ;71 virtual String getObjectViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) ;72 virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) ;73 virtual bool keyExistsInIndex(int64_t database Id, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey);56 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) OVERRIDE { } 57 virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId) OVERRIDE { return false; } 58 virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE { } 59 virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; } 60 virtual bool deleteIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; } 61 virtual String getObjectViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) OVERRIDE { return String(); } 62 virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) OVERRIDE { return PassRefPtr<IDBKey>(); } 63 virtual bool keyExistsInIndex(int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey) OVERRIDE { return false; } 74 64 75 virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) ;76 virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) ;77 virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) ;65 virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } 66 virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } 67 virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); } 78 68 79 virtual PassRefPtr<Transaction> createTransaction(); 80 81 static bool backingStoreExists(SecurityOrigin*, const String& name, const String& pathBase); 82 83 private: 84 IDBLevelDBBackingStore(const String& identifier, IDBFactoryBackendImpl*, PassOwnPtr<LevelDBDatabase>); 85 86 String m_identifier; 87 RefPtr<IDBFactoryBackendImpl> m_factory; 88 OwnPtr<LevelDBDatabase> m_db; 89 OwnPtr<LevelDBComparator> m_comparator; 90 RefPtr<LevelDBTransaction> m_currentTransaction; 91 92 class Transaction : public IDBBackingStore::Transaction { 93 public: 94 static PassRefPtr<Transaction> create(IDBLevelDBBackingStore*); 95 virtual void begin(); 96 virtual bool commit(); 97 virtual void rollback(); 98 99 private: 100 Transaction(IDBLevelDBBackingStore*); 101 IDBLevelDBBackingStore* m_backingStore; 102 }; 69 virtual PassRefPtr<Transaction> createTransaction() OVERRIDE { return PassRefPtr<Transaction>(); } 103 70 }; 104 71 105 72 } // namespace WebCore 106 73 107 108 #endif // USE(LEVELDB) 109 #endif // ENABLE(INDEXED_DATABASE) 110 111 #endif // IDBLevelDBBackingStore_h 74 #endif // IDBFakeBackingStore_h
Note: See TracChangeset
for help on using the changeset viewer.