summaryrefslogtreecommitdiffstats
path: root/WebCore/storage/IDBFactoryBackendImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/storage/IDBFactoryBackendImpl.cpp')
-rw-r--r--WebCore/storage/IDBFactoryBackendImpl.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/WebCore/storage/IDBFactoryBackendImpl.cpp b/WebCore/storage/IDBFactoryBackendImpl.cpp
index 50cf778..d819c92 100644
--- a/WebCore/storage/IDBFactoryBackendImpl.cpp
+++ b/WebCore/storage/IDBFactoryBackendImpl.cpp
@@ -52,19 +52,21 @@ IDBFactoryBackendImpl::~IDBFactoryBackendImpl()
{
}
-static PassOwnPtr<SQLiteDatabase> openSQLiteDatabase(SecurityOrigin* securityOrigin, String name)
+static PassOwnPtr<SQLiteDatabase> openSQLiteDatabase(SecurityOrigin* securityOrigin, String name, const String& pathBase)
{
- String pathBase = "/tmp/temporary-indexed-db-files"; // FIXME: Write a PageGroupSettings class and have this value come from that.
- if (!makeAllDirectories(pathBase)) {
- // FIXME: Is there any other thing we could possibly do to recover at this point? If so, do it rather than just erroring out.
- LOG_ERROR("Unabled to create LocalStorage database path %s", pathBase.utf8().data());
- return 0;
+ String path = ":memory:";
+ if (!pathBase.isEmpty()) {
+ if (!makeAllDirectories(pathBase)) {
+ // FIXME: Is there any other thing we could possibly do to recover at this point? If so, do it rather than just erroring out.
+ LOG_ERROR("Unabled to create LocalStorage database path %s", pathBase.utf8().data());
+ return 0;
+ }
+
+ String databaseIdentifier = securityOrigin->databaseIdentifier();
+ String santizedName = encodeForFileName(name);
+ path = pathByAppendingComponent(pathBase, databaseIdentifier + "_" + santizedName + ".indexeddb");
}
- String databaseIdentifier = securityOrigin->databaseIdentifier();
- String santizedName = encodeForFileName(name);
- String path = pathByAppendingComponent(pathBase, databaseIdentifier + "_" + santizedName + ".indexeddb");
-
OwnPtr<SQLiteDatabase> sqliteDatabase = adoptPtr(new SQLiteDatabase());
if (!sqliteDatabase->open(path)) {
// FIXME: Is there any other thing we could possibly do to recover at this point? If so, do it rather than just erroring out.
@@ -98,13 +100,13 @@ static bool createTables(SQLiteDatabase* sqliteDatabase)
"CREATE UNIQUE INDEX IF NOT EXISTS ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)",
"DROP TABLE IF EXISTS IndexData",
- "CREATE TABLE IF NOT EXISTS IndexData (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexs(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, objectStoreDataId INTEGER NOT NULL UNIQUE REFERENCES ObjectStoreData(id))",
+ "CREATE TABLE IF NOT EXISTS IndexData (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexes(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, objectStoreDataId INTEGER NOT NULL UNIQUE REFERENCES ObjectStoreData(id))",
"DROP INDEX IF EXISTS IndexData_composit",
- "CREATE UNIQUE INDEX IF NOT EXISTS IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
+ "CREATE INDEX IF NOT EXISTS IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
"DROP INDEX IF EXISTS IndexData_objectStoreDataId",
- "CREATE UNIQUE INDEX IF NOT EXISTS IndexData_objectStoreDataId ON IndexData(objectStoreDataId)",
+ "CREATE INDEX IF NOT EXISTS IndexData_objectStoreDataId ON IndexData(objectStoreDataId)",
"DROP INDEX IF EXISTS IndexData_indexId",
- "CREATE UNIQUE INDEX IF NOT EXISTS IndexData_indexId ON IndexData(indexId)"
+ "CREATE INDEX IF NOT EXISTS IndexData_indexId ON IndexData(indexId)"
};
for (size_t i = 0; i < arraysize(commands); ++i) {
@@ -117,7 +119,7 @@ static bool createTables(SQLiteDatabase* sqliteDatabase)
return true;
}
-void IDBFactoryBackendImpl::open(const String& name, const String& description, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*)
+void IDBFactoryBackendImpl::open(const String& name, const String& description, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDir)
{
IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(name);
if (it != m_databaseBackendMap.end()) {
@@ -129,7 +131,7 @@ void IDBFactoryBackendImpl::open(const String& name, const String& description,
// FIXME: Everything from now on should be done on another thread.
- OwnPtr<SQLiteDatabase> sqliteDatabase = openSQLiteDatabase(securityOrigin.get(), name);
+ OwnPtr<SQLiteDatabase> sqliteDatabase = openSQLiteDatabase(securityOrigin.get(), name, dataDir);
if (!sqliteDatabase || !createTables(sqliteDatabase.get())) {
callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
return;