Changeset 87257 in webkit
- Timestamp:
- May 24, 2011 8:00:58 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r87256 r87257 1 2011-05-24 Greg Simon <gregsimon@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Control Indexeddb backends from LayoutTestController 6 https://bugs.webkit.org/show_bug.cgi?id=61000 7 8 LayoutTest for migration between SQLite and LevelDB 9 in IndxededDB. 10 11 * storage/indexeddb/migrate-basics-expected.txt: Added. 12 * storage/indexeddb/migrate-basics.html: Added. 13 1 14 2011-05-24 Fumitoshi Ukai <ukai@chromium.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r87248 r87257 1 2011-05-24 Greg Simon <gregsimon@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Control Indexeddb backends from LayoutTestController 6 https://bugs.webkit.org/show_bug.cgi?id=61000 7 8 Test: storage/indexeddb/migrate-basics.html 9 10 * storage/IDBBackingStore.h: 11 * storage/IDBFactoryBackendImpl.cpp: 12 (WebCore::IDBFactoryBackendImpl::IDBFactoryBackendImpl): 13 (WebCore::IDBFactoryBackendImpl::open): 14 (WebCore::IDBFactoryBackendImpl::setEnableMigration): 15 (WebCore::IDBFactoryBackendImpl::migrate): 16 * storage/IDBFactoryBackendImpl.h: 17 * storage/IDBFactoryBackendInterface.h: 18 * storage/IDBLevelDBBackingStore.cpp: 19 (WebCore::IDBLevelDBBackingStore::backingStoreExists): 20 * storage/IDBLevelDBBackingStore.h: 21 (WebCore::IDBLevelDBBackingStore::backingStoreType): 22 * storage/IDBSQLiteBackingStore.cpp: 23 (WebCore::IDBSQLiteBackingStore::backingStoreExists): 24 * storage/IDBSQLiteBackingStore.h: 25 (WebCore::IDBSQLiteBackingStore::backingStoreType): 26 1 27 2011-05-24 Leo Yang <leo.yang@torchmobile.com.cn> 2 28 -
trunk/Source/WebCore/storage/IDBBackingStore.h
r86422 r87257 30 30 31 31 #include "IDBCursor.h" 32 #include "IDBFactoryBackendImpl.h" 33 #include "IDBFactoryBackendInterface.h" 32 34 #include "SQLiteDatabase.h" 33 35 #include <wtf/PassRefPtr.h> … … 38 40 namespace WebCore { 39 41 40 class IDBFactoryBackendImpl;41 42 class IDBKey; 42 43 class IDBKeyRange; … … 107 108 }; 108 109 virtual PassRefPtr<Transaction> createTransaction() = 0; 110 virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() = 0; 109 111 }; 110 112 -
trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp
r83443 r87257 46 46 IDBFactoryBackendImpl::IDBFactoryBackendImpl() 47 47 : m_transactionCoordinator(IDBTransactionCoordinator::create()) 48 , m_migrateEnabled(false) 48 49 { 49 50 } … … 77 78 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentifier); 78 79 if (it != m_databaseBackendMap.end()) { 79 callbacks->onSuccess(it->second); 80 return; 80 // Also check that backing store types match: this is important for migration. 81 if ((backingStoreType == DefaultBackingStore) || (backingStoreType == it->second->backingStore()->backingStoreType())) { 82 callbacks->onSuccess(it->second); 83 return; 84 } 81 85 } 82 86 … … 85 89 RefPtr<IDBBackingStore> backingStore; 86 90 IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier); 87 if (it2 != m_backingStoreMap.end() )91 if (it2 != m_backingStoreMap.end() && (backingStoreType == it2->second->backingStoreType())) 88 92 backingStore = it2->second; 89 93 else { 90 if (backingStoreType == DefaultBackingStore) 94 #if ENABLE(LEVELDB) 95 if (m_migrateEnabled) { 96 bool hasSQLBackend = IDBSQLiteBackingStore::backingStoreExists(securityOrigin.get(), dataDir); 97 bool hasLevelDbBackend = IDBLevelDBBackingStore::backingStoreExists(securityOrigin.get(), dataDir); 98 99 if (hasSQLBackend && hasLevelDbBackend) 100 backingStoreType = LevelDBBackingStore; 101 102 // Migration: if the database exists and is SQLite we want to migrate it to LevelDB. 103 if (hasSQLBackend && !hasLevelDbBackend) { 104 if (migrate(name, securityOrigin.get(), dataDir, maximumSize)) 105 backingStoreType = LevelDBBackingStore; 106 else 107 backingStoreType = DefaultBackingStore; 108 } 109 } 110 #endif 111 112 if (backingStoreType == DefaultBackingStore || backingStoreType == SQLiteBackingStore) 91 113 backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this); 92 114 #if ENABLE(LEVELDB) … … 105 127 } 106 128 129 void IDBFactoryBackendImpl::setEnableMigration(bool enabled) 130 { 131 m_migrateEnabled = enabled; 132 } 133 134 bool IDBFactoryBackendImpl::migrate(const String& name, SecurityOrigin* securityOrigin, const String& dataDir, int64_t maximumSize) 135 { 136 // FIXME: Implement migration. 137 return false; 138 } 139 107 140 } // namespace WebCore 108 141 -
trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h
r80635 r87257 57 57 58 58 virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType); 59 virtual void setEnableMigration(bool); 59 60 60 61 private: 61 62 IDBFactoryBackendImpl(); 63 bool migrate(const String& name, SecurityOrigin*, const String& dataDir, int64_t maximumSize); 62 64 63 65 typedef HashMap<String, IDBDatabaseBackendImpl*> IDBDatabaseBackendMap; … … 68 70 69 71 RefPtr<IDBTransactionCoordinator> m_transactionCoordinator; 72 73 bool m_migrateEnabled; 70 74 71 75 // Only one instance of the factory should exist at any given time. -
trunk/Source/WebCore/storage/IDBFactoryBackendInterface.h
r81567 r87257 54 54 enum BackingStoreType { 55 55 DefaultBackingStore, 56 LevelDBBackingStore 56 LevelDBBackingStore, 57 SQLiteBackingStore 57 58 }; 58 59 59 60 virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType) = 0; 61 virtual void setEnableMigration(bool) = 0; 60 62 }; 61 63 -
trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp
r86422 r87257 1267 1267 } 1268 1268 1269 bool IDBLevelDBBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String& pathBaseArg) 1270 { 1271 String pathBase = pathBaseArg; 1272 1273 if (pathBase.isEmpty()) 1274 return false; 1275 1276 // FIXME: We should eventually use the same LevelDB database for all origins. 1277 String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb.leveldb"); 1278 1279 // FIXME: It would be more thorough to open the database here but also more expensive. 1280 if (fileExists(path+"/CURRENT")) 1281 return true; 1282 1283 return false; 1284 } 1285 1269 1286 // FIXME: deleteDatabase should be part of IDBBackingStore. 1270 1287 -
trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h
r85122 r87257 73 73 74 74 virtual PassRefPtr<Transaction> createTransaction(); 75 virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() { return IDBFactoryBackendInterface::LevelDBBackingStore; } 76 77 static bool backingStoreExists(SecurityOrigin*, const String& pathBase); 75 78 76 79 private: -
trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp
r86422 r87257 992 992 } 993 993 994 bool IDBSQLiteBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String& pathBase) 995 { 996 String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb"); 997 998 SQLiteDatabase db; 999 if (!db.open(path)) 1000 return false; 1001 1002 db.close(); 1003 return true; 1004 } 1005 994 1006 namespace { 995 1007 -
trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h
r83443 r87257 68 68 69 69 virtual PassRefPtr<Transaction> createTransaction(); 70 virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() { return IDBFactoryBackendInterface::SQLiteBackingStore; } 71 72 static bool backingStoreExists(SecurityOrigin*, const String& pathBase); 70 73 71 74 private: -
trunk/Source/WebKit/chromium/ChangeLog
r87189 r87257 1 2011-05-24 Greg Simon <gregsimon@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Control Indexeddb backends from LayoutTestController 6 https://bugs.webkit.org/show_bug.cgi?id=61000 7 8 * public/WebIDBFactory.h: 9 (WebKit::WebIDBFactory::setEnableMigration): 10 * src/AssertMatchingEnums.cpp: 11 * src/IDBFactoryBackendProxy.cpp: 12 (WebKit::IDBFactoryBackendProxy::setEnableMigration): 13 * src/IDBFactoryBackendProxy.h: 14 * src/WebIDBFactoryImpl.cpp: 15 (WebKit::WebIDBFactory::setOverrideBackingStoreType): 16 (WebKit::WebIDBFactory::setTemporaryDatabaseFolder): 17 (WebKit::WebIDBFactoryImpl::WebIDBFactoryImpl): 18 (WebKit::WebIDBFactoryImpl::open): 19 (WebKit::WebIDBFactoryImpl::setEnableMigration): 20 * src/WebIDBFactoryImpl.h: 21 1 22 2011-05-24 Jay Civelli <jcivelli@chromium.org> 2 23 -
trunk/Source/WebKit/chromium/public/WebIDBFactory.h
r83443 r87257 54 54 enum BackingStoreType { 55 55 DefaultBackingStore, 56 LevelDBBackingStore 56 LevelDBBackingStore, 57 SQLiteBackingStore 57 58 }; 58 59 59 60 // The WebKit implementation of open ignores the WebFrame* parameter. 60 61 virtual void open(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType) { WEBKIT_ASSERT_NOT_REACHED(); } 62 virtual void setEnableMigration(bool) { WEBKIT_ASSERT_NOT_REACHED(); } 61 63 62 64 virtual void deleteDatabase(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir) { WEBKIT_ASSERT_NOT_REACHED(); } 65 66 // Used for DumpRenderTree tests. 67 WEBKIT_API static void setOverrideBackingStoreType(BackingStoreType); 68 WEBKIT_API static void setTemporaryDatabaseFolder(const WebString& path); 63 69 }; 64 70 -
trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
r86452 r87257 400 400 COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::DefaultBackingStore, IDBFactoryBackendInterface::DefaultBackingStore); 401 401 COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::LevelDBBackingStore, IDBFactoryBackendInterface::LevelDBBackingStore); 402 COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::SQLiteBackingStore, IDBFactoryBackendInterface::SQLiteBackingStore); 402 403 403 404 #if ENABLE(FILE_SYSTEM) -
trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp
r85966 r87257 78 78 } 79 79 80 void IDBFactoryBackendProxy::setEnableMigration(bool enable) 81 { 82 m_webIDBFactory->setEnableMigration(enable); 83 } 84 85 80 86 } // namespace WebKit 81 87 -
trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h
r82917 r87257 47 47 PassRefPtr<WebCore::DOMStringList> databases(void) const; 48 48 virtual void open(const String& name, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType); 49 virtual void setEnableMigration(bool); 49 50 50 51 private: -
trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp
r86067 r87257 45 45 namespace WebKit { 46 46 47 static WebIDBFactory::BackingStoreType overriddenBackingStoreType = WebIDBFactory::DefaultBackingStore; 48 static WebString tempDatabaseFolder; 49 47 50 WebIDBFactory* WebIDBFactory::create() 48 51 { … … 50 53 } 51 54 55 void WebIDBFactory::setOverrideBackingStoreType(BackingStoreType type) 56 { 57 overriddenBackingStoreType = type; 58 } 59 60 void WebIDBFactory::setTemporaryDatabaseFolder(const WebString& path) 61 { 62 tempDatabaseFolder = path; 63 } 64 52 65 WebIDBFactoryImpl::WebIDBFactoryImpl() 53 66 : m_idbFactoryBackend(IDBFactoryBackendImpl::create()) 54 67 { 68 m_idbFactoryBackend->setEnableMigration(true); 55 69 } 56 70 … … 61 75 void WebIDBFactoryImpl::open(const WebString& name, WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType backingStoreType) 62 76 { 63 m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(adoptPtr(callbacks)), origin, 0, dataDir, maximumSize, static_cast<IDBFactoryBackendInterface::BackingStoreType>(backingStoreType)); 77 WebString path = dataDir; 78 if (overriddenBackingStoreType != DefaultBackingStore) { 79 backingStoreType = overriddenBackingStoreType; 80 81 // The dataDir is empty for two reasons: LevelDB in icognito mode or 82 // LevelDB from DumpRenderTree. The first case is taken care of inside 83 // IDBFactoryBackendImpl.cpp by forcing SQLITE backend for incognito. 84 // For the DumpRenderTree case we need to keep track of the location 85 // so we can wipe it out when we're done with the test. 86 if (dataDir.isEmpty() && backingStoreType == LevelDBBackingStore) 87 path = tempDatabaseFolder; 88 } 89 m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(adoptPtr(callbacks)), origin, 0, path, maximumSize, static_cast<IDBFactoryBackendInterface::BackingStoreType>(backingStoreType)); 90 } 91 92 void WebIDBFactoryImpl::setEnableMigration(bool enable) 93 { 94 m_idbFactoryBackend->setEnableMigration(enable); 64 95 } 65 96 -
trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.h
r82917 r87257 46 46 47 47 virtual void open(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType); 48 virtual void setEnableMigration(bool); 48 49 49 50 private: -
trunk/Tools/ChangeLog
r87210 r87257 1 2011-05-24 Greg Simon <gregsimon@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Control Indexeddb backends from LayoutTestController 6 https://bugs.webkit.org/show_bug.cgi?id=61000 7 8 * DumpRenderTree/chromium/LayoutTestController.cpp: 9 (LayoutTestController::LayoutTestController): 10 (LayoutTestController::setOverrideIndexedDBBackingStore): 11 (LayoutTestController::clearAllDatabases): 12 * DumpRenderTree/chromium/LayoutTestController.h: 13 1 14 2011-05-24 Robert Hogan <robert@webkit.org> 2 15 -
trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp
r86930 r87257 45 45 #include "WebFrame.h" 46 46 #include "WebGeolocationClientMock.h" 47 #include "WebIDBFactory.h" 47 48 #include "WebInputElement.h" 48 49 #include "WebKit.h" … … 83 84 // by CppBoundClass, the parent to LayoutTestController). 84 85 bindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag); 86 bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult); 85 87 bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry); 86 88 bindMethod("addUserScript", &LayoutTestController::addUserScript); … … 160 162 bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); 161 163 bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); 162 bindMethod(" addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);164 bindMethod("setOverrideIndexedDBBackingStore", &LayoutTestController::setOverrideIndexedDBBackingStore); 163 165 bindMethod("setPageVisibility", &LayoutTestController::setPageVisibility); 164 166 bindMethod("setPluginsEnabled", &LayoutTestController::setPluginsEnabled); … … 1126 1128 // We don't use the WebKit icon database. 1127 1129 result->setNull(); 1130 } 1131 1132 void LayoutTestController::setOverrideIndexedDBBackingStore(const CppArgumentList& arguments, CppVariant* result) 1133 { 1134 result->setNull(); 1135 #if ENABLE(INDEXED_DATABASE) 1136 if (arguments.size() < 1 || !arguments[0].isString()) 1137 return; 1138 string name = arguments[0].toString(); 1139 if (name == "sqlite") 1140 WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::SQLiteBackingStore); 1141 else if (name == "default") 1142 WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::DefaultBackingStore); 1143 else if (name == "leveldb") { 1144 WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::LevelDBBackingStore); 1145 1146 m_tempFolder = adoptPtr(webkit_support::CreateScopedTempDirectory()); 1147 if (m_tempFolder) { 1148 if (m_tempFolder->CreateUniqueTempDir()) 1149 WebIDBFactory::setTemporaryDatabaseFolder(WebString::fromUTF8(m_tempFolder->path().c_str())); 1150 } 1151 } 1152 #endif 1128 1153 } 1129 1154 … … 1493 1518 result->setNull(); 1494 1519 webkit_support::ClearAllDatabases(); 1520 m_tempFolder.clear(); 1495 1521 } 1496 1522 -
trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h
r86930 r87257 57 57 } 58 58 59 namespace webkit_support { 60 class ScopedTempDirectory; 61 } 62 59 63 class TestShell; 60 64 … … 305 309 // Sets the default quota for all origins 306 310 void setDatabaseQuota(const CppArgumentList&, CppVariant*); 311 // Overrides the backend for IndexedDB 312 void setOverrideIndexedDBBackingStore(const CppArgumentList&, CppVariant*); 307 313 308 314 // Calls setlocale(LC_ALL, ...) for a specified locale. … … 588 594 CppVariant m_globalFlag; 589 595 596 // Used to create and destroy temporary folders. 597 OwnPtr<webkit_support::ScopedTempDirectory> m_tempFolder; 598 590 599 // Bound variable counting the number of top URLs visited. 591 600 CppVariant m_webHistoryItemCount;
Note: See TracChangeset
for help on using the changeset viewer.