Diff
Modified: trunk/LayoutTests/ChangeLog (87256 => 87257)
--- trunk/LayoutTests/ChangeLog 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/LayoutTests/ChangeLog 2011-05-25 03:00:58 UTC (rev 87257)
@@ -1,3 +1,16 @@
+2011-05-24 Greg Simon <[email protected]>
+
+ Reviewed by Dimitri Glazkov.
+
+ Control Indexeddb backends from LayoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=61000
+
+ LayoutTest for migration between SQLite and LevelDB
+ in IndxededDB.
+
+ * storage/indexeddb/migrate-basics-expected.txt: Added.
+ * storage/indexeddb/migrate-basics.html: Added.
+
2011-05-24 Fumitoshi Ukai <[email protected]>
Unreviewed.
Added: trunk/LayoutTests/storage/indexeddb/migrate-basics-expected.txt (0 => 87257)
--- trunk/LayoutTests/storage/indexeddb/migrate-basics-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/migrate-basics-expected.txt 2011-05-25 03:00:58 UTC (rev 87257)
@@ -0,0 +1,36 @@
+Test migration from SQLite to LevelDB.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitIndexedDB.open('MigrationDatabase')
+sqliteCreateSuccess():
+db = event.target.result
+db.setVersion('new version')
+sqliteSetVersionSuccess():
+window.db.createObjectStore('PlainOldStore', {autoIncrement: false})
+store = window.db.createObjectStore('StoreWithKeyPath', {keyPath: 'id', autoIncrement: true})
+window.db.createObjectStore('StoreWithAutoIncrement', {autoIncrement: true})
+trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
+index = store.createIndex('ExampleIndex','id', false)
+sqliteTestAddRecords1():
+store = trans.objectStore('PlainOldStore')
+store = store.add({name: 'George'},1)
+sqliteTestAddRecords2():
+store = trans.objectStore('StoreWithKeyPath')
+store.add({name: 'Thomas', id: 3})
+sqliteTestAddRecords3():
+store = trans.objectStore('StoreWithAutoIncrement')
+store.add({name: 'Lincoln', number: '7012'}, 5)
+leveldbOpenSuccess():
+db = event.target.result
+trans = db.transaction([], webkitIDBTransaction.READ_WRITE, 0)
+leveldbCheckPlainOldStore():
+store = trans.objectStore('PlainOldStore')
+FAIL store = trans.objectStore('PlainOldStore') threw exception Error: NOT_FOUND_ERR: DOM IDBDatabase Exception 3
+request = store.openCursor(keyRange)
+FAIL request = store.openCursor(keyRange) threw exception TypeError: Cannot call method 'openCursor' of undefined
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/storage/indexeddb/migrate-basics.html (0 => 87257)
--- trunk/LayoutTests/storage/indexeddb/migrate-basics.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/migrate-basics.html 2011-05-25 03:00:58 UTC (rev 87257)
@@ -0,0 +1,197 @@
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test migration from SQLite to LevelDB.");
+
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function test()
+{
+ if (window.layoutTestController)
+ layoutTestController.setOverrideIndexedDBBackingStore("sqlite");
+
+ request = evalAndLog("webkitIndexedDB.open('MigrationDatabase')");
+ request._onsuccess_ = sqliteOpenSuccess;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function sqliteOpenSuccess()
+{
+ debug("sqliteCreateSuccess():");
+ window.db = evalAndLog("db = event.target.result");
+
+ request = evalAndLog("db.setVersion('new version')");
+ request._onsuccess_ = sqliteSetVersionSuccess;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function sqliteSetVersionSuccess()
+{
+ debug("sqliteSetVersionSuccess():");
+ evalAndLog("window.db.createObjectStore('PlainOldStore', {autoIncrement: false})");
+ window.store = evalAndLog("store = window.db.createObjectStore('StoreWithKeyPath', {keyPath: 'id', autoIncrement: true})");
+ evalAndLog("window.db.createObjectStore('StoreWithAutoIncrement', {autoIncrement: true})");
+
+ window.trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)");
+ window.index = evalAndLog("index = store.createIndex('ExampleIndex','id', false)");
+
+
+ sqliteTestAddRecords1();
+}
+
+function sqliteTestAddRecords1()
+{
+ debug("sqliteTestAddRecords1():");
+ window.store = evalAndLog("store = trans.objectStore('PlainOldStore')");
+ request = evalAndLog("store = store.add({name: 'George'},1)");
+ request._onsuccess_ = sqliteTestAddRecords2;
+ request._onfailure_ = unexpectedErrorCallback;
+}
+
+function sqliteTestAddRecords2()
+{
+ debug("sqliteTestAddRecords2():");
+ window.store = evalAndLog("store = trans.objectStore('StoreWithKeyPath')");
+
+ request = evalAndLog("store.add({name: 'Thomas', id: 3})");
+ request._onsuccess_ = sqliteTestAddRecords3;
+ request._onfailure_ = unexpectedErrorCallback;
+}
+
+function sqliteTestAddRecords3()
+{
+ debug("sqliteTestAddRecords3():");
+ window.store = evalAndLog("store = trans.objectStore('StoreWithAutoIncrement')");
+ request = evalAndLog("store.add({name: 'Lincoln', number: '7012'}, 5)");
+ request._onsuccess_ = sqliteCloseDatabase;
+ request._onfailure_ = unexpectedErrorCallback;
+}
+
+
+function sqliteCloseDatabase()
+{
+ window.db.close();
+ window.db = null;
+ window.trans = null;
+ leveldbOpen();
+}
+
+function leveldbOpen()
+{
+ if (window.layoutTestController)
+ layoutTestController.setOverrideIndexedDBBackingStore("leveldb");
+
+ // This next line will trigger the migration.
+ request = webkitIndexedDB.open('MigrationDatabase');
+ request._onsuccess_ = leveldbOpenSuccess;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function leveldbOpenSuccess()
+{
+ debug("leveldbOpenSuccess():");
+ window.db = evalAndLog("db = event.target.result");
+ window.trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE, 0)");
+ leveldbCheckPlainOldStore();
+}
+
+function leveldbCheckPlainOldStore()
+{
+ debug("leveldbCheckPlainOldStore():");
+ window.store = evalAndLog("store = trans.objectStore('PlainOldStore')");
+ window.keyRange = webkitIDBKeyRange.lowerBound(0);
+ request = evalAndLog("request = store.openCursor(keyRange)");
+ if (!request) {
+ testMigrationEnd();
+ return;
+ }
+ request._onsuccess_ = leveldbCheckPlainOldStoreCursorNext;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function leveldbCheckPlainOldStoreCursorNext()
+{
+ debug("leveldbCheckPlainOldStoreCursorNext():");
+ window.cursor = event.target.result;
+ if (!window.cursor) {
+ leveldbCheckStoreWithKeyPath();
+ return;
+ }
+
+ shouldBeTrue("cursor.value.name == 'George'");
+ cursor.continue();
+}
+
+function leveldbCheckStoreWithKeyPath()
+{
+ debug("leveldbCheckStoreWithKeyPath():");
+ window.store = evalAndLog("store = trans.objectStore('StoreWithKeyPath')");
+ var keyRange = webkitIDBKeyRange.lowerBound(0);
+ request = store.openCursor(keyRange);
+ request._onsuccess_ = leveldbCheckStoreWithKeyPathCursorNext;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function leveldbCheckStoreWithKeyPathCursorNext()
+{
+ debug("leveldbCheckStoreWithKeyPathCursorNext():");
+ window.cursor = event.target.result;
+ if (!window.cursor) {
+ leveldbCheckStoreWithAutoIncrement();
+ return;
+ }
+
+ shouldBeTrue("cursor.value.name == 'Thomas'");
+ shouldBeTrue("cursor.value.id == '3'");
+ cursor.continue();
+}
+
+function leveldbCheckStoreWithAutoIncrement()
+{
+ debug("leveldbCheckStoreWithAutoIncrement():");
+ window.store = evalAndLog("store = trans.objectStore('StoreWithAutoIncrement')");
+ var keyRange = webkitIDBKeyRange.lowerBound(0);
+ request = store.openCursor(keyRange);
+ request._onsuccess_ = leveldbCheckStoreWithAutoIncrementCursorNext;
+ request._onerror_ = unexpectedErrorCallback;
+}
+function leveldbCheckStoreWithAutoIncrementCursorNext()
+{
+ debug("leveldbCheckStoreWithAutoIncrementCursorNext():");
+ window.cursor = event.target.result;
+ if (!window.cursor) {
+ testMigrationEnd();
+ return;
+ }
+
+ shouldBeTrue("cursor.value.name == 'Lincoln'");
+ shouldBeTrue("cursor.value.number == '7012'");
+ cursor.continue();
+}
+
+function testMigrationEnd()
+{
+ window.db.close();
+ window.db = null;
+ layoutTestController.clearAllDatabases();
+ layoutTestController.setOverrideIndexedDBBackingStore("default");
+ done();
+}
+
+test();
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (87256 => 87257)
--- trunk/Source/WebCore/ChangeLog 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/ChangeLog 2011-05-25 03:00:58 UTC (rev 87257)
@@ -1,3 +1,29 @@
+2011-05-24 Greg Simon <[email protected]>
+
+ Reviewed by Dimitri Glazkov.
+
+ Control Indexeddb backends from LayoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=61000
+
+ Test: storage/indexeddb/migrate-basics.html
+
+ * storage/IDBBackingStore.h:
+ * storage/IDBFactoryBackendImpl.cpp:
+ (WebCore::IDBFactoryBackendImpl::IDBFactoryBackendImpl):
+ (WebCore::IDBFactoryBackendImpl::open):
+ (WebCore::IDBFactoryBackendImpl::setEnableMigration):
+ (WebCore::IDBFactoryBackendImpl::migrate):
+ * storage/IDBFactoryBackendImpl.h:
+ * storage/IDBFactoryBackendInterface.h:
+ * storage/IDBLevelDBBackingStore.cpp:
+ (WebCore::IDBLevelDBBackingStore::backingStoreExists):
+ * storage/IDBLevelDBBackingStore.h:
+ (WebCore::IDBLevelDBBackingStore::backingStoreType):
+ * storage/IDBSQLiteBackingStore.cpp:
+ (WebCore::IDBSQLiteBackingStore::backingStoreExists):
+ * storage/IDBSQLiteBackingStore.h:
+ (WebCore::IDBSQLiteBackingStore::backingStoreType):
+
2011-05-24 Leo Yang <[email protected]>
Reviewed by Ryosuke Niwa.
Modified: trunk/Source/WebCore/storage/IDBBackingStore.h (87256 => 87257)
--- trunk/Source/WebCore/storage/IDBBackingStore.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/storage/IDBBackingStore.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -29,6 +29,8 @@
#if ENABLE(INDEXED_DATABASE)
#include "IDBCursor.h"
+#include "IDBFactoryBackendImpl.h"
+#include "IDBFactoryBackendInterface.h"
#include "SQLiteDatabase.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -37,7 +39,6 @@
namespace WebCore {
-class IDBFactoryBackendImpl;
class IDBKey;
class IDBKeyRange;
class SecurityOrigin;
@@ -106,6 +107,7 @@
virtual void rollback() = 0;
};
virtual PassRefPtr<Transaction> createTransaction() = 0;
+ virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp (87256 => 87257)
--- trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp 2011-05-25 03:00:58 UTC (rev 87257)
@@ -45,6 +45,7 @@
IDBFactoryBackendImpl::IDBFactoryBackendImpl()
: m_transactionCoordinator(IDBTransactionCoordinator::create())
+ , m_migrateEnabled(false)
{
}
@@ -76,18 +77,39 @@
String uniqueIdentifier = fileIdentifier + "@" + name;
IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentifier);
if (it != m_databaseBackendMap.end()) {
- callbacks->onSuccess(it->second);
- return;
+ // Also check that backing store types match: this is important for migration.
+ if ((backingStoreType == DefaultBackingStore) || (backingStoreType == it->second->backingStore()->backingStoreType())) {
+ callbacks->onSuccess(it->second);
+ return;
+ }
}
// FIXME: Everything from now on should be done on another thread.
RefPtr<IDBBackingStore> backingStore;
IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier);
- if (it2 != m_backingStoreMap.end())
+ if (it2 != m_backingStoreMap.end() && (backingStoreType == it2->second->backingStoreType()))
backingStore = it2->second;
else {
- if (backingStoreType == DefaultBackingStore)
+#if ENABLE(LEVELDB)
+ if (m_migrateEnabled) {
+ bool hasSQLBackend = IDBSQLiteBackingStore::backingStoreExists(securityOrigin.get(), dataDir);
+ bool hasLevelDbBackend = IDBLevelDBBackingStore::backingStoreExists(securityOrigin.get(), dataDir);
+
+ if (hasSQLBackend && hasLevelDbBackend)
+ backingStoreType = LevelDBBackingStore;
+
+ // Migration: if the database exists and is SQLite we want to migrate it to LevelDB.
+ if (hasSQLBackend && !hasLevelDbBackend) {
+ if (migrate(name, securityOrigin.get(), dataDir, maximumSize))
+ backingStoreType = LevelDBBackingStore;
+ else
+ backingStoreType = DefaultBackingStore;
+ }
+ }
+#endif
+
+ if (backingStoreType == DefaultBackingStore || backingStoreType == SQLiteBackingStore)
backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this);
#if ENABLE(LEVELDB)
else if (backingStoreType == LevelDBBackingStore)
@@ -104,6 +126,17 @@
m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get());
}
+void IDBFactoryBackendImpl::setEnableMigration(bool enabled)
+{
+ m_migrateEnabled = enabled;
+}
+
+bool IDBFactoryBackendImpl::migrate(const String& name, SecurityOrigin* securityOrigin, const String& dataDir, int64_t maximumSize)
+{
+ // FIXME: Implement migration.
+ return false;
+}
+
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h (87256 => 87257)
--- trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -56,9 +56,11 @@
void removeIDBBackingStore(const String& uniqueIdentifier);
virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType);
+ virtual void setEnableMigration(bool);
private:
IDBFactoryBackendImpl();
+ bool migrate(const String& name, SecurityOrigin*, const String& dataDir, int64_t maximumSize);
typedef HashMap<String, IDBDatabaseBackendImpl*> IDBDatabaseBackendMap;
IDBDatabaseBackendMap m_databaseBackendMap;
@@ -68,6 +70,8 @@
RefPtr<IDBTransactionCoordinator> m_transactionCoordinator;
+ bool m_migrateEnabled;
+
// Only one instance of the factory should exist at any given time.
static IDBFactoryBackendImpl* idbFactoryBackendImpl;
};
Modified: trunk/Source/WebCore/storage/IDBFactoryBackendInterface.h (87256 => 87257)
--- trunk/Source/WebCore/storage/IDBFactoryBackendInterface.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/storage/IDBFactoryBackendInterface.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -53,10 +53,12 @@
enum BackingStoreType {
DefaultBackingStore,
- LevelDBBackingStore
+ LevelDBBackingStore,
+ SQLiteBackingStore
};
virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType) = 0;
+ virtual void setEnableMigration(bool) = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp (87256 => 87257)
--- trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp 2011-05-25 03:00:58 UTC (rev 87257)
@@ -1266,6 +1266,23 @@
return adoptRef(new DummyTransaction());
}
+bool IDBLevelDBBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String& pathBaseArg)
+{
+ String pathBase = pathBaseArg;
+
+ if (pathBase.isEmpty())
+ return false;
+
+ // FIXME: We should eventually use the same LevelDB database for all origins.
+ String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb.leveldb");
+
+ // FIXME: It would be more thorough to open the database here but also more expensive.
+ if (fileExists(path+"/CURRENT"))
+ return true;
+
+ return false;
+}
+
// FIXME: deleteDatabase should be part of IDBBackingStore.
} // namespace WebCore
Modified: trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h (87256 => 87257)
--- trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -72,7 +72,10 @@
virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction);
virtual PassRefPtr<Transaction> createTransaction();
+ virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() { return IDBFactoryBackendInterface::LevelDBBackingStore; }
+ static bool backingStoreExists(SecurityOrigin*, const String& pathBase);
+
private:
IDBLevelDBBackingStore(String identifier, IDBFactoryBackendImpl*, PassOwnPtr<LevelDBDatabase>);
Modified: trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp (87256 => 87257)
--- trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp 2011-05-25 03:00:58 UTC (rev 87257)
@@ -991,6 +991,18 @@
return cursor.release();
}
+bool IDBSQLiteBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String& pathBase)
+{
+ String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb");
+
+ SQLiteDatabase db;
+ if (!db.open(path))
+ return false;
+
+ db.close();
+ return true;
+}
+
namespace {
class TransactionImpl : public IDBBackingStore::Transaction {
Modified: trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h (87256 => 87257)
--- trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -67,7 +67,10 @@
virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction);
virtual PassRefPtr<Transaction> createTransaction();
+ virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() { return IDBFactoryBackendInterface::SQLiteBackingStore; }
+ static bool backingStoreExists(SecurityOrigin*, const String& pathBase);
+
private:
IDBSQLiteBackingStore(String identifier, IDBFactoryBackendImpl*);
Modified: trunk/Source/WebKit/chromium/ChangeLog (87256 => 87257)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-05-25 03:00:58 UTC (rev 87257)
@@ -1,3 +1,24 @@
+2011-05-24 Greg Simon <[email protected]>
+
+ Reviewed by Dimitri Glazkov.
+
+ Control Indexeddb backends from LayoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=61000
+
+ * public/WebIDBFactory.h:
+ (WebKit::WebIDBFactory::setEnableMigration):
+ * src/AssertMatchingEnums.cpp:
+ * src/IDBFactoryBackendProxy.cpp:
+ (WebKit::IDBFactoryBackendProxy::setEnableMigration):
+ * src/IDBFactoryBackendProxy.h:
+ * src/WebIDBFactoryImpl.cpp:
+ (WebKit::WebIDBFactory::setOverrideBackingStoreType):
+ (WebKit::WebIDBFactory::setTemporaryDatabaseFolder):
+ (WebKit::WebIDBFactoryImpl::WebIDBFactoryImpl):
+ (WebKit::WebIDBFactoryImpl::open):
+ (WebKit::WebIDBFactoryImpl::setEnableMigration):
+ * src/WebIDBFactoryImpl.h:
+
2011-05-24 Jay Civelli <[email protected]>
Reviewed by Adam Barth.
Modified: trunk/Source/WebKit/chromium/public/WebIDBFactory.h (87256 => 87257)
--- trunk/Source/WebKit/chromium/public/WebIDBFactory.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebKit/chromium/public/WebIDBFactory.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -53,13 +53,19 @@
enum BackingStoreType {
DefaultBackingStore,
- LevelDBBackingStore
+ LevelDBBackingStore,
+ SQLiteBackingStore
};
// The WebKit implementation of open ignores the WebFrame* parameter.
virtual void open(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType) { WEBKIT_ASSERT_NOT_REACHED(); }
+ virtual void setEnableMigration(bool) { WEBKIT_ASSERT_NOT_REACHED(); }
virtual void deleteDatabase(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir) { WEBKIT_ASSERT_NOT_REACHED(); }
+
+ // Used for DumpRenderTree tests.
+ WEBKIT_API static void setOverrideBackingStoreType(BackingStoreType);
+ WEBKIT_API static void setTemporaryDatabaseFolder(const WebString& path);
};
} // namespace WebKit
Modified: trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp (87256 => 87257)
--- trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp 2011-05-25 03:00:58 UTC (rev 87257)
@@ -399,6 +399,7 @@
COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::DefaultBackingStore, IDBFactoryBackendInterface::DefaultBackingStore);
COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::LevelDBBackingStore, IDBFactoryBackendInterface::LevelDBBackingStore);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::SQLiteBackingStore, IDBFactoryBackendInterface::SQLiteBackingStore);
#if ENABLE(FILE_SYSTEM)
COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeTemporary, AsyncFileSystem::Temporary);
Modified: trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp (87256 => 87257)
--- trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp 2011-05-25 03:00:58 UTC (rev 87257)
@@ -77,6 +77,12 @@
m_webIDBFactory->open(name, new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir, maximumSize, static_cast<WebIDBFactory::BackingStoreType>(backingStoreType));
}
+void IDBFactoryBackendProxy::setEnableMigration(bool enable)
+{
+ m_webIDBFactory->setEnableMigration(enable);
+}
+
+
} // namespace WebKit
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h (87256 => 87257)
--- trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -46,6 +46,7 @@
PassRefPtr<WebCore::DOMStringList> databases(void) const;
virtual void open(const String& name, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType);
+ virtual void setEnableMigration(bool);
private:
IDBFactoryBackendProxy();
Modified: trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp (87256 => 87257)
--- trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp 2011-05-25 03:00:58 UTC (rev 87257)
@@ -44,14 +44,28 @@
namespace WebKit {
+static WebIDBFactory::BackingStoreType overriddenBackingStoreType = WebIDBFactory::DefaultBackingStore;
+static WebString tempDatabaseFolder;
+
WebIDBFactory* WebIDBFactory::create()
{
return new WebIDBFactoryImpl();
}
+void WebIDBFactory::setOverrideBackingStoreType(BackingStoreType type)
+{
+ overriddenBackingStoreType = type;
+}
+
+void WebIDBFactory::setTemporaryDatabaseFolder(const WebString& path)
+{
+ tempDatabaseFolder = path;
+}
+
WebIDBFactoryImpl::WebIDBFactoryImpl()
: m_idbFactoryBackend(IDBFactoryBackendImpl::create())
{
+ m_idbFactoryBackend->setEnableMigration(true);
}
WebIDBFactoryImpl::~WebIDBFactoryImpl()
@@ -60,9 +74,26 @@
void WebIDBFactoryImpl::open(const WebString& name, WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType backingStoreType)
{
- m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(adoptPtr(callbacks)), origin, 0, dataDir, maximumSize, static_cast<IDBFactoryBackendInterface::BackingStoreType>(backingStoreType));
+ WebString path = dataDir;
+ if (overriddenBackingStoreType != DefaultBackingStore) {
+ backingStoreType = overriddenBackingStoreType;
+
+ // The dataDir is empty for two reasons: LevelDB in icognito mode or
+ // LevelDB from DumpRenderTree. The first case is taken care of inside
+ // IDBFactoryBackendImpl.cpp by forcing SQLITE backend for incognito.
+ // For the DumpRenderTree case we need to keep track of the location
+ // so we can wipe it out when we're done with the test.
+ if (dataDir.isEmpty() && backingStoreType == LevelDBBackingStore)
+ path = tempDatabaseFolder;
+ }
+ m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(adoptPtr(callbacks)), origin, 0, path, maximumSize, static_cast<IDBFactoryBackendInterface::BackingStoreType>(backingStoreType));
}
+void WebIDBFactoryImpl::setEnableMigration(bool enable)
+{
+ m_idbFactoryBackend->setEnableMigration(enable);
+}
+
} // namespace WebKit
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.h (87256 => 87257)
--- trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -45,6 +45,7 @@
virtual ~WebIDBFactoryImpl();
virtual void open(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType);
+ virtual void setEnableMigration(bool);
private:
WTF::RefPtr<WebCore::IDBFactoryBackendInterface> m_idbFactoryBackend;
Modified: trunk/Tools/ChangeLog (87256 => 87257)
--- trunk/Tools/ChangeLog 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Tools/ChangeLog 2011-05-25 03:00:58 UTC (rev 87257)
@@ -1,3 +1,16 @@
+2011-05-24 Greg Simon <[email protected]>
+
+ Reviewed by Dimitri Glazkov.
+
+ Control Indexeddb backends from LayoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=61000
+
+ * DumpRenderTree/chromium/LayoutTestController.cpp:
+ (LayoutTestController::LayoutTestController):
+ (LayoutTestController::setOverrideIndexedDBBackingStore):
+ (LayoutTestController::clearAllDatabases):
+ * DumpRenderTree/chromium/LayoutTestController.h:
+
2011-05-24 Robert Hogan <[email protected]>
Reviewed by Ryosuke Niwa.
Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (87256 => 87257)
--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp 2011-05-25 03:00:58 UTC (rev 87257)
@@ -44,6 +44,7 @@
#include "WebElement.h"
#include "WebFrame.h"
#include "WebGeolocationClientMock.h"
+#include "WebIDBFactory.h"
#include "WebInputElement.h"
#include "WebKit.h"
#include "WebNotificationPresenter.h"
@@ -82,6 +83,7 @@
// names to their methods will be done by calling bindToJavaScript() (defined
// by CppBoundClass, the parent to LayoutTestController).
bindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
+ bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry);
bindMethod("addUserScript", &LayoutTestController::addUserScript);
bindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet);
@@ -159,7 +161,7 @@
bindMethod("setMockDeviceOrientation", &LayoutTestController::setMockDeviceOrientation);
bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError);
bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition);
- bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
+ bindMethod("setOverrideIndexedDBBackingStore", &LayoutTestController::setOverrideIndexedDBBackingStore);
bindMethod("setPageVisibility", &LayoutTestController::setPageVisibility);
bindMethod("setPluginsEnabled", &LayoutTestController::setPluginsEnabled);
bindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled);
@@ -1127,6 +1129,29 @@
result->setNull();
}
+void LayoutTestController::setOverrideIndexedDBBackingStore(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+#if ENABLE(INDEXED_DATABASE)
+ if (arguments.size() < 1 || !arguments[0].isString())
+ return;
+ string name = arguments[0].toString();
+ if (name == "sqlite")
+ WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::SQLiteBackingStore);
+ else if (name == "default")
+ WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::DefaultBackingStore);
+ else if (name == "leveldb") {
+ WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::LevelDBBackingStore);
+
+ m_tempFolder = adoptPtr(webkit_support::CreateScopedTempDirectory());
+ if (m_tempFolder) {
+ if (m_tempFolder->CreateUniqueTempDir())
+ WebIDBFactory::setTemporaryDatabaseFolder(WebString::fromUTF8(m_tempFolder->path().c_str()));
+ }
+ }
+#endif
+}
+
void LayoutTestController::callShouldCloseOnWebView(const CppArgumentList&, CppVariant* result)
{
result->set(m_shell->webView()->dispatchBeforeUnloadEvent());
@@ -1492,6 +1517,7 @@
{
result->setNull();
webkit_support::ClearAllDatabases();
+ m_tempFolder.clear();
}
void LayoutTestController::setDatabaseQuota(const CppArgumentList& arguments, CppVariant* result)
Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (87256 => 87257)
--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h 2011-05-25 02:54:29 UTC (rev 87256)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h 2011-05-25 03:00:58 UTC (rev 87257)
@@ -56,6 +56,10 @@
class WebSpeechInputListener;
}
+namespace webkit_support {
+class ScopedTempDirectory;
+}
+
class TestShell;
class LayoutTestController : public CppBoundClass {
@@ -304,6 +308,8 @@
void clearAllDatabases(const CppArgumentList&, CppVariant*);
// Sets the default quota for all origins
void setDatabaseQuota(const CppArgumentList&, CppVariant*);
+ // Overrides the backend for IndexedDB
+ void setOverrideIndexedDBBackingStore(const CppArgumentList&, CppVariant*);
// Calls setlocale(LC_ALL, ...) for a specified locale.
// Resets between tests.
@@ -587,6 +593,9 @@
CppVariant m_globalFlag;
+ // Used to create and destroy temporary folders.
+ OwnPtr<webkit_support::ScopedTempDirectory> m_tempFolder;
+
// Bound variable counting the number of top URLs visited.
CppVariant m_webHistoryItemCount;