Changeset 89130 in webkit
- Timestamp:
- Jun 17, 2011 2:43:59 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r89128 r89130 1 2011-06-09 Hans Wennborg <hans@chromium.org> 2 3 Reviewed by Tony Gentilcore. 4 5 IndexedDB: backingStoreMap is per backing store, not per database 6 https://bugs.webkit.org/show_bug.cgi?id=62382 7 8 IDBFactoryBackendImpl::m_backingStoreMap should contain an entry per 9 backing store, not per database. Otherwise, we might accidentally open 10 the same backing store more than once, which is dangerous. 11 12 Also tweak the code that chooses backing store type. It should be 13 simple: we default to SQLite; if LevelDB is specifically requested, we 14 use that. If LevelDB is requested and there is a SQLite database, we 15 migrate. 16 17 No new tests, just cleaning up the code. 18 19 * storage/IDBFactoryBackendImpl.cpp: 20 (WebCore::IDBFactoryBackendImpl::addIDBBackingStore): 21 (WebCore::IDBFactoryBackendImpl::removeIDBBackingStore): 22 (WebCore::IDBFactoryBackendImpl::open): 23 (WebCore::IDBFactoryBackendImpl::migrateFromSQLiteToLevelDB): 24 * storage/IDBFactoryBackendImpl.h: 25 1 26 2011-06-17 Andrey Adaikin <aandrey@google.com> 2 27 -
trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp
r88358 r89130 59 59 } 60 60 61 void IDBFactoryBackendImpl::addIDBBackingStore(const String& uniqueIdentifier, IDBBackingStore* backingStore)61 void IDBFactoryBackendImpl::addIDBBackingStore(const String& fileIdentifier, IDBBackingStore* backingStore) 62 62 { 63 ASSERT(!m_backingStoreMap.contains( uniqueIdentifier));64 m_backingStoreMap.set( uniqueIdentifier, backingStore);63 ASSERT(!m_backingStoreMap.contains(fileIdentifier)); 64 m_backingStoreMap.set(fileIdentifier, backingStore); 65 65 } 66 66 67 void IDBFactoryBackendImpl::removeIDBBackingStore(const String& uniqueIdentifier)67 void IDBFactoryBackendImpl::removeIDBBackingStore(const String& fileIdentifier) 68 68 { 69 ASSERT(m_backingStoreMap.contains( uniqueIdentifier));70 m_backingStoreMap.remove( uniqueIdentifier);69 ASSERT(m_backingStoreMap.contains(fileIdentifier)); 70 m_backingStoreMap.remove(fileIdentifier); 71 71 } 72 72 73 73 void IDBFactoryBackendImpl::open(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType backingStoreType) 74 74 { 75 String uniqueIdentifier = securityOrigin->databaseIdentifier() + "@" + name + String::format("@%d", (int)backingStoreType); 75 if (backingStoreType == DefaultBackingStore) 76 backingStoreType = SQLiteBackingStore; // FIXME: DefaultBackingStore is confusing; get rid of it. 77 78 const String fileIdentifier = securityOrigin->databaseIdentifier() + String::format("@%d", static_cast<int>(backingStoreType)); 79 const String uniqueIdentifier = fileIdentifier + "@" + name; 80 76 81 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentifier); 77 82 if (it != m_databaseBackendMap.end()) { … … 83 88 84 89 RefPtr<IDBBackingStore> backingStore; 85 IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find( uniqueIdentifier);90 IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier); 86 91 if (it2 != m_backingStoreMap.end() && (backingStoreType == it2->second->backingStoreType())) 87 92 backingStore = it2->second; 88 93 else { 94 89 95 #if ENABLE(LEVELDB) 90 // Should we migrate this backing store? 91 bool hasSQLBackingStore = IDBSQLiteBackingStore::backingStoreExists(securityOrigin.get(), dataDir); 92 bool hasLevelDBBackingStore = IDBLevelDBBackingStore::backingStoreExists(securityOrigin.get(), dataDir); 96 if (backingStoreType == LevelDBBackingStore) { 97 const bool hasSQLBackingStore = IDBSQLiteBackingStore::backingStoreExists(securityOrigin.get(), dataDir); 93 98 94 if (hasSQLBackingStore && hasLevelDBBackingStore) 95 backingStoreType = LevelDBBackingStore; 96 97 // Migration: if the database exists and is SQLite we want to migrate it to LevelDB. 98 if (hasSQLBackingStore && !hasLevelDBBackingStore) { 99 if (migrate(name, securityOrigin.get(), dataDir, maximumSize)) 100 backingStoreType = LevelDBBackingStore; 99 if (hasSQLBackingStore) { 100 bool migrationSucceeded = migrateFromSQLiteToLevelDB(name, securityOrigin.get(), dataDir, maximumSize); 101 (void)migrationSucceeded; // FIXME: When migration is actually implemented, we need error handling here. 102 } 101 103 } 102 104 #endif 103 105 104 if (backingStoreType == DefaultBackingStore || backingStoreType ==SQLiteBackingStore)105 backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, uniqueIdentifier, this);106 if (backingStoreType == SQLiteBackingStore) 107 backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this); 106 108 #if ENABLE(LEVELDB) 107 109 else if (backingStoreType == LevelDBBackingStore) 108 backingStore = IDBLevelDBBackingStore::open(securityOrigin.get(), dataDir, maximumSize, uniqueIdentifier, this);110 backingStore = IDBLevelDBBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this); 109 111 #endif 110 112 if (!backingStore) { … … 119 121 } 120 122 121 bool IDBFactoryBackendImpl::migrate (const String& name, SecurityOrigin* securityOrigin, const String& dataDir, int64_t maximumSize)123 bool IDBFactoryBackendImpl::migrateFromSQLiteToLevelDB(const String& name, SecurityOrigin* securityOrigin, const String& dataDir, int64_t maximumSize) 122 124 { 123 return false; 125 return false; // FIXME: To be implemented. 124 126 } 125 127 -
trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h
r88358 r89130 53 53 // Notifications from weak pointers. 54 54 void removeIDBDatabaseBackend(const String& uniqueIdentifier); 55 void addIDBBackingStore(const String& uniqueIdentifier, IDBBackingStore*);56 void removeIDBBackingStore(const String& uniqueIdentifier);55 void addIDBBackingStore(const String& fileIdentifier, IDBBackingStore*); 56 void removeIDBBackingStore(const String& fileIdentifier); 57 57 58 58 virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType); … … 60 60 private: 61 61 IDBFactoryBackendImpl(); 62 bool migrate (const String& name, SecurityOrigin*, const String& dataDir, int64_t maximumSize);62 bool migrateFromSQLiteToLevelDB(const String& name, SecurityOrigin*, const String& dataDir, int64_t maximumSize); 63 63 64 64 typedef HashMap<String, IDBDatabaseBackendImpl*> IDBDatabaseBackendMap;
Note: See TracChangeset
for help on using the changeset viewer.