tizen beta release
[framework/web/webkit-efl.git] / Source / WebCore / storage / IDBFactory.cpp
index d2014fe..7e3b5d5 100755 (executable)
@@ -42,6 +42,7 @@
 #include "IDBKey.h"
 #include "IDBKeyRange.h"
 #include "IDBRequest.h"
+#include "IDBVersionChangeRequest.h"
 #include "Page.h"
 #include "PageGroup.h"
 #include "SecurityOrigin.h"
@@ -49,7 +50,7 @@
 namespace WebCore {
 
 IDBFactory::IDBFactory(IDBFactoryBackendInterface* factory)
-    : m_factoryBackend(factory)
+    : m_backend(factory)
 {
     // We pass a reference to this object before it can be adopted.
     relaxAdoptionRequirement();
@@ -72,7 +73,7 @@ PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* cont
 
     RefPtr<IDBRequest> request = IDBRequest::create(document, IDBAny::create(this), 0);
     GroupSettings* groupSettings = document->page()->group().groupSettings();
-    m_factoryBackend->getDatabaseNames(request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+    m_backend->getDatabaseNames(request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
     return request;
 }
 
@@ -94,7 +95,37 @@ PassRefPtr<IDBRequest> IDBFactory::open(ScriptExecutionContext* context, const S
 
     RefPtr<IDBRequest> request = IDBRequest::create(document, IDBAny::create(this), 0);
     GroupSettings* groupSettings = document->page()->group().groupSettings();
-    m_factoryBackend->open(name, request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+#if ENABLE(TIZEN_INDEXED_DATABASE)
+    m_backend->open(document, name, request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+#else
+    m_backend->open(name, request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+#endif // TIZEN_INDEXED_DATABASE
+    return request;
+}
+
+PassRefPtr<IDBVersionChangeRequest> IDBFactory::deleteDatabase(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
+{
+    if (!context->isDocument()) {
+        // FIXME: make this work with workers.
+        return 0;
+    }
+
+    Document* document = static_cast<Document*>(context);
+    if (!document->frame() || !document->page())
+        return 0;
+
+    if (name.isNull()) {
+        ec = IDBDatabaseException::NON_TRANSIENT_ERR;
+        return 0;
+    }
+
+    RefPtr<IDBVersionChangeRequest> request = IDBVersionChangeRequest::create(document, IDBAny::createNull(), "");
+    GroupSettings* groupSettings = document->page()->group().groupSettings();
+#if ENABLE(TIZEN_INDEXED_DATABASE)
+    m_backend->deleteDatabase(document, name, request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+#else
+    m_backend->deleteDatabase(name, request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+#endif // TIZEN_INDEXED_DATABASE
     return request;
 }
 
@@ -103,7 +134,7 @@ short IDBFactory::cmp(PassRefPtr<IDBKey> first, PassRefPtr<IDBKey> second, Excep
     ASSERT(first);
     ASSERT(second);
 
-    if (first->type() == IDBKey::NullType || second->type() == IDBKey::NullType) {
+    if (first->type() == IDBKey::InvalidType || second->type() == IDBKey::InvalidType) {
         ec = IDBDatabaseException::DATA_ERR;
         return 0;
     }