summaryrefslogtreecommitdiffstats
path: root/WebCore/storage
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/storage')
-rw-r--r--WebCore/storage/AbstractDatabase.cpp38
-rw-r--r--WebCore/storage/AbstractDatabase.h43
-rw-r--r--WebCore/storage/Database.idl3
-rw-r--r--WebCore/storage/DatabaseCallback.h2
-rw-r--r--WebCore/storage/DatabaseCallback.idl1
-rw-r--r--WebCore/storage/DatabaseSync.cpp4
-rw-r--r--WebCore/storage/DatabaseSync.h4
-rw-r--r--WebCore/storage/DatabaseSync.idl42
-rw-r--r--WebCore/storage/IDBAny.cpp98
-rw-r--r--WebCore/storage/IDBAny.h81
-rw-r--r--WebCore/storage/IDBAny.idl37
-rw-r--r--WebCore/storage/IDBCallbacks.h64
-rw-r--r--WebCore/storage/IDBDatabaseRequest.h8
-rw-r--r--WebCore/storage/IDBErrorEvent.cpp58
-rw-r--r--WebCore/storage/IDBErrorEvent.h66
-rw-r--r--WebCore/storage/IDBErrorEvent.idl37
-rw-r--r--WebCore/storage/IDBEvent.cpp55
-rw-r--r--WebCore/storage/IDBEvent.h59
-rw-r--r--WebCore/storage/IDBEvent.idl36
-rw-r--r--WebCore/storage/IDBRequest.cpp162
-rw-r--r--WebCore/storage/IDBRequest.h113
-rw-r--r--WebCore/storage/IDBRequest.idl61
-rw-r--r--WebCore/storage/IDBSuccessEvent.cpp61
-rw-r--r--WebCore/storage/IDBSuccessEvent.h62
-rw-r--r--WebCore/storage/IDBSuccessEvent.idl36
-rw-r--r--WebCore/storage/IndexedDatabase.h4
-rw-r--r--WebCore/storage/IndexedDatabaseImpl.cpp10
-rw-r--r--WebCore/storage/IndexedDatabaseImpl.h2
-rw-r--r--WebCore/storage/IndexedDatabaseRequest.cpp10
-rw-r--r--WebCore/storage/IndexedDatabaseRequest.h8
-rw-r--r--WebCore/storage/IndexedDatabaseRequest.idl2
-rw-r--r--WebCore/storage/SQLError.idl3
-rw-r--r--WebCore/storage/SQLResultSet.idl3
-rw-r--r--WebCore/storage/SQLResultSetRowList.idl3
-rw-r--r--WebCore/storage/SQLTransaction.cpp10
-rw-r--r--WebCore/storage/SQLTransaction.idl3
-rw-r--r--WebCore/storage/SQLTransactionSync.idl38
-rw-r--r--WebCore/storage/SQLTransactionSyncCallback.h2
-rw-r--r--WebCore/storage/SQLTransactionSyncCallback.idl36
39 files changed, 1278 insertions, 87 deletions
diff --git a/WebCore/storage/AbstractDatabase.cpp b/WebCore/storage/AbstractDatabase.cpp
new file mode 100644
index 0000000..c795189
--- /dev/null
+++ b/WebCore/storage/AbstractDatabase.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AbstractDatabase.h"
+
+#if ENABLE(DATABASE)
+
+namespace WebCore {
+
+} // namespace WebCore
+
+#endif // ENABLE(DATABASE)
diff --git a/WebCore/storage/AbstractDatabase.h b/WebCore/storage/AbstractDatabase.h
new file mode 100644
index 0000000..962be61
--- /dev/null
+++ b/WebCore/storage/AbstractDatabase.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AbstractDatabase_h
+#define AbstractDatabase_h
+
+#if ENABLE(DATABASE)
+
+namespace WebCore {
+
+class AbstractDatabase {
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(DATABASE)
+
+#endif // AbstractDatabase_h
diff --git a/WebCore/storage/Database.idl b/WebCore/storage/Database.idl
index c8a537c..ab79c97 100644
--- a/WebCore/storage/Database.idl
+++ b/WebCore/storage/Database.idl
@@ -30,7 +30,8 @@ module storage {
interface [
Conditional=DATABASE,
- OmitConstructor
+ OmitConstructor,
+ NoStaticTables
] Database {
readonly attribute DOMString version;
[Custom] void changeVersion(in DOMString oldVersion, in DOMString newVersion, in SQLTransactionCallback callback, in SQLTransactionErrorCallback errorCallback, in VoidCallback successCallback);
diff --git a/WebCore/storage/DatabaseCallback.h b/WebCore/storage/DatabaseCallback.h
index f87732f..dfdc038 100644
--- a/WebCore/storage/DatabaseCallback.h
+++ b/WebCore/storage/DatabaseCallback.h
@@ -38,12 +38,14 @@
namespace WebCore {
class Database;
+class DatabaseSync;
class ScriptExecutionContext;
class DatabaseCallback : public ThreadSafeShared<DatabaseCallback> {
public:
virtual ~DatabaseCallback() { }
virtual bool handleEvent(ScriptExecutionContext*, Database*) = 0;
+ virtual bool handleEvent(ScriptExecutionContext*, DatabaseSync*) = 0;
};
}
diff --git a/WebCore/storage/DatabaseCallback.idl b/WebCore/storage/DatabaseCallback.idl
index 7d060fe..c218680 100644
--- a/WebCore/storage/DatabaseCallback.idl
+++ b/WebCore/storage/DatabaseCallback.idl
@@ -32,5 +32,6 @@ module storage {
Callback
] DatabaseCallback {
boolean handleEvent(in Database database);
+ boolean handleEvent(in DatabaseSync database);
};
}
diff --git a/WebCore/storage/DatabaseSync.cpp b/WebCore/storage/DatabaseSync.cpp
index 3c36803..fd1376a 100644
--- a/WebCore/storage/DatabaseSync.cpp
+++ b/WebCore/storage/DatabaseSync.cpp
@@ -91,12 +91,12 @@ String DatabaseSync::version() const
return String();
}
-void DatabaseSync::changeVersion(const String&, const String&, PassRefPtr<SQLTransactionSyncCallback>)
+void DatabaseSync::changeVersion(const String&, const String&, PassRefPtr<SQLTransactionSyncCallback>, ExceptionCode&)
{
ASSERT(m_scriptExecutionContext->isContextThread());
}
-void DatabaseSync::transaction(PassRefPtr<SQLTransactionSyncCallback>, bool)
+void DatabaseSync::transaction(PassRefPtr<SQLTransactionSyncCallback>, bool, ExceptionCode&)
{
ASSERT(m_scriptExecutionContext->isContextThread());
}
diff --git a/WebCore/storage/DatabaseSync.h b/WebCore/storage/DatabaseSync.h
index c398607..4b9985c 100644
--- a/WebCore/storage/DatabaseSync.h
+++ b/WebCore/storage/DatabaseSync.h
@@ -53,8 +53,8 @@ public:
static PassRefPtr<DatabaseSync> openDatabaseSync(ScriptExecutionContext*, const String& name, const String& expectedVersion,
const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback>, ExceptionCode&);
String version() const;
- void changeVersion(const String& oldVersion, const String& newVersion, PassRefPtr<SQLTransactionSyncCallback>);
- void transaction(PassRefPtr<SQLTransactionSyncCallback>, bool readOnly);
+ void changeVersion(const String& oldVersion, const String& newVersion, PassRefPtr<SQLTransactionSyncCallback>, ExceptionCode&);
+ void transaction(PassRefPtr<SQLTransactionSyncCallback>, bool readOnly, ExceptionCode&);
// Internal engine support
ScriptExecutionContext* scriptExecutionContext() const;
diff --git a/WebCore/storage/DatabaseSync.idl b/WebCore/storage/DatabaseSync.idl
new file mode 100644
index 0000000..29b87a7
--- /dev/null
+++ b/WebCore/storage/DatabaseSync.idl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module storage {
+
+ interface [
+ Conditional=DATABASE,
+ OmitConstructor,
+ NoStaticTables
+ ] DatabaseSync {
+ readonly attribute DOMString version;
+ [Custom] void changeVersion(in DOMString oldVersion, in DOMString newVersion, in SQLTransactionSyncCallback callback);
+ [Custom] void transaction(in SQLTransactionSyncCallback callback);
+ [Custom] void readTransaction(in SQLTransactionSyncCallback callback);
+ };
+
+}
diff --git a/WebCore/storage/IDBAny.cpp b/WebCore/storage/IDBAny.cpp
new file mode 100644
index 0000000..17a8007
--- /dev/null
+++ b/WebCore/storage/IDBAny.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBAny.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBDatabaseRequest.h"
+#include "IndexedDatabaseRequest.h"
+#include "SerializedScriptValue.h"
+
+namespace WebCore {
+
+PassRefPtr<IDBAny> IDBAny::create()
+{
+ return adoptRef(new IDBAny());
+}
+
+IDBAny::IDBAny()
+ : m_type(UndefinedType)
+{
+}
+
+IDBAny::~IDBAny()
+{
+}
+
+PassRefPtr<IDBDatabaseRequest> IDBAny::idbDatabaseRequest()
+{
+ ASSERT(m_type == IDBDatabaseRequestType);
+ return m_idbDatabaseRequest;
+}
+
+PassRefPtr<IndexedDatabaseRequest> IDBAny::indexedDatabaseRequest()
+{
+ ASSERT(m_type == IndexedDatabaseRequestType);
+ return m_indexedDatabaseRequest;
+}
+
+PassRefPtr<SerializedScriptValue> IDBAny::serializedScriptValue()
+{
+ ASSERT(m_type == SerializedScriptValueType);
+ return m_serializedScriptValue;
+}
+
+void IDBAny::set(PassRefPtr<IDBDatabaseRequest> value)
+{
+ m_type = IDBDatabaseRequestType;
+ m_idbDatabaseRequest = value;
+ m_indexedDatabaseRequest = 0;
+ m_serializedScriptValue = 0;
+}
+
+void IDBAny::set(PassRefPtr<IndexedDatabaseRequest> value)
+{
+ m_type = IndexedDatabaseRequestType;
+ m_idbDatabaseRequest = 0;
+ m_indexedDatabaseRequest = value;
+ m_serializedScriptValue = 0;
+}
+
+void IDBAny::set(PassRefPtr<SerializedScriptValue> value)
+{
+ m_type = SerializedScriptValueType;
+ m_idbDatabaseRequest = 0;
+ m_indexedDatabaseRequest = 0;
+ m_serializedScriptValue = value;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/storage/IDBAny.h b/WebCore/storage/IDBAny.h
new file mode 100644
index 0000000..56c57e2
--- /dev/null
+++ b/WebCore/storage/IDBAny.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBAny_h
+#define IDBAny_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class IDBDatabaseRequest;
+class IndexedDatabaseRequest;
+class SerializedScriptValue;
+
+class IDBAny : public RefCounted<IDBAny> {
+public:
+ static PassRefPtr<IDBAny> create();
+ ~IDBAny();
+
+ enum Type {
+ UndefinedType = 0,
+ IDBDatabaseRequestType,
+ IndexedDatabaseRequestType,
+ SerializedScriptValueType
+ };
+
+ Type type() const { return m_type; }
+
+ PassRefPtr<IDBDatabaseRequest> idbDatabaseRequest();
+ PassRefPtr<IndexedDatabaseRequest> indexedDatabaseRequest();
+ PassRefPtr<SerializedScriptValue> serializedScriptValue();
+
+ void set(PassRefPtr<IDBDatabaseRequest>);
+ void set(PassRefPtr<IndexedDatabaseRequest>);
+ void set(PassRefPtr<SerializedScriptValue>);
+
+private:
+ IDBAny();
+
+ Type m_type;
+
+ // Only one of the following should ever be in use at any given time.
+ RefPtr<IDBDatabaseRequest> m_idbDatabaseRequest;
+ RefPtr<IndexedDatabaseRequest> m_indexedDatabaseRequest;
+ RefPtr<SerializedScriptValue> m_serializedScriptValue;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // IDBAny_h
diff --git a/WebCore/storage/IDBAny.idl b/WebCore/storage/IDBAny.idl
new file mode 100644
index 0000000..59da1c7
--- /dev/null
+++ b/WebCore/storage/IDBAny.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module storage {
+
+ interface [
+ Conditional=INDEXED_DATABASE,
+ CustomToJS
+ ] IDBAny {
+ // This space is intentionally left blank.
+ };
+}
diff --git a/WebCore/storage/IDBCallbacks.h b/WebCore/storage/IDBCallbacks.h
index ce0d20d..74c11d8 100644
--- a/WebCore/storage/IDBCallbacks.h
+++ b/WebCore/storage/IDBCallbacks.h
@@ -29,74 +29,22 @@
#ifndef IDBCallbacks_h
#define IDBCallbacks_h
-#include "ActiveDOMObject.h"
+#include "IDBDatabase.h"
#include "IDBDatabaseError.h"
-#include "Timer.h"
-#include <wtf/PassRefPtr.h>
+#include "SerializedScriptValue.h"
#include <wtf/RefCounted.h>
#if ENABLE(INDEXED_DATABASE)
namespace WebCore {
-// All IndexedDB callbacks must implement this class. It handles the asynchronous firing of
-// the callbacks.
-template <typename ResultType>
-class IDBCallbacks : public RefCounted<IDBCallbacks<ResultType> >, public ActiveDOMObject {
+class IDBCallbacks : public RefCounted<IDBCallbacks> {
public:
- IDBCallbacks(ScriptExecutionContext* scriptExecutionContext, void* upcastPointer)
- : ActiveDOMObject(scriptExecutionContext, upcastPointer)
- , m_timer(this, &IDBCallbacks::timerFired)
- {
- }
-
virtual ~IDBCallbacks() { }
- void onSuccess(PassRefPtr<ResultType> result)
- {
- ASSERT(!m_result);
- ASSERT(!m_error);
- m_result = result;
- ASSERT(m_result);
-
- ASSERT(!m_timer.isActive());
- m_selfRef = this;
- m_timer.startOneShot(0);
- }
-
- void onError(PassRefPtr<IDBDatabaseError> error)
- {
- ASSERT(!m_result);
- ASSERT(!m_error);
- m_error = error;
- ASSERT(m_error);
-
- ASSERT(!m_timer.isActive());
- m_selfRef = this;
- m_timer.startOneShot(0);
- }
-
-protected:
- virtual void onSuccessAsync(PassRefPtr<ResultType>) = 0;
- virtual void onErrorAsync(PassRefPtr<IDBDatabaseError>) = 0;
-
- void timerFired(Timer<IDBCallbacks>*)
- {
- if (m_result) {
- onSuccessAsync(m_result);
- m_result = 0;
- } else {
- onErrorAsync(m_error);
- m_error = 0;
- }
- m_selfRef = 0; // May trigger a delete immediately.
- }
-
-private:
- Timer<IDBCallbacks> m_timer;
- RefPtr<IDBCallbacks> m_selfRef;
- RefPtr<ResultType> m_result;
- RefPtr<IDBDatabaseError> m_error;
+ virtual void onError(PassRefPtr<IDBDatabaseError>) = 0;
+ virtual void onSuccess(PassRefPtr<IDBDatabase>) = 0;
+ virtual void onSuccess(PassRefPtr<SerializedScriptValue>) = 0;
};
} // namespace WebCore
diff --git a/WebCore/storage/IDBDatabaseRequest.h b/WebCore/storage/IDBDatabaseRequest.h
index c027b6a..199eb79 100644
--- a/WebCore/storage/IDBDatabaseRequest.h
+++ b/WebCore/storage/IDBDatabaseRequest.h
@@ -33,6 +33,7 @@
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/UnusedParam.h>
#if ENABLE(INDEXED_DATABASE)
@@ -47,7 +48,12 @@ public:
~IDBDatabaseRequest();
// FIXME: Write.
- void createObjectStore(const String& name, const String& keyPath, bool autoIncrement) { }
+ void createObjectStore(const String& name, const String& keyPath, bool autoIncrement)
+ {
+ UNUSED_PARAM(name);
+ UNUSED_PARAM(keyPath);
+ UNUSED_PARAM(autoIncrement);
+ }
private:
IDBDatabaseRequest(PassRefPtr<IDBDatabase>);
diff --git a/WebCore/storage/IDBErrorEvent.cpp b/WebCore/storage/IDBErrorEvent.cpp
new file mode 100644
index 0000000..cba980d
--- /dev/null
+++ b/WebCore/storage/IDBErrorEvent.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBErrorEvent.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "EventNames.h"
+#include "IDBAny.h"
+#include "IDBDatabaseError.h"
+
+namespace WebCore {
+
+PassRefPtr<IDBErrorEvent> IDBErrorEvent::create(PassRefPtr<IDBAny> source, const IDBDatabaseError& error)
+{
+ return adoptRef(new IDBErrorEvent(source, error));
+}
+
+IDBErrorEvent::IDBErrorEvent(PassRefPtr<IDBAny> source, const IDBDatabaseError& error)
+ : IDBEvent(eventNames().errorEvent, source)
+ , m_code(error.code())
+ , m_message(error.message())
+{
+}
+
+IDBErrorEvent::~IDBErrorEvent()
+{
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/storage/IDBErrorEvent.h b/WebCore/storage/IDBErrorEvent.h
new file mode 100644
index 0000000..648da8b
--- /dev/null
+++ b/WebCore/storage/IDBErrorEvent.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBErrorEvent_h
+#define IDBErrorEvent_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBEvent.h"
+#include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class IDBAny;
+class IDBDatabaseError;
+
+class IDBErrorEvent : public IDBEvent {
+public:
+ static PassRefPtr<IDBErrorEvent> create(PassRefPtr<IDBAny> source, const IDBDatabaseError&);
+ // FIXME: Need to allow creation of these events from JS.
+ virtual ~IDBErrorEvent();
+
+ unsigned short code() const { return m_code; }
+ String message() { return m_message; }
+
+ virtual bool isIDBErrorEvent() const { return true; }
+
+private:
+ IDBErrorEvent(PassRefPtr<IDBAny> source, const IDBDatabaseError&);
+
+ unsigned short m_code;
+ String m_message;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // IDBEvent_h
diff --git a/WebCore/storage/IDBErrorEvent.idl b/WebCore/storage/IDBErrorEvent.idl
new file mode 100644
index 0000000..5c58f6f
--- /dev/null
+++ b/WebCore/storage/IDBErrorEvent.idl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module storage {
+
+ interface [
+ Conditional=INDEXED_DATABASE
+ ] IDBErrorEvent : IDBEvent {
+ readonly attribute unsigned short code;
+ readonly attribute DOMString message;
+ };
+}
diff --git a/WebCore/storage/IDBEvent.cpp b/WebCore/storage/IDBEvent.cpp
new file mode 100644
index 0000000..f9f6060
--- /dev/null
+++ b/WebCore/storage/IDBEvent.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBEvent.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBAny.h"
+
+namespace WebCore {
+
+IDBEvent::IDBEvent(const AtomicString& type, PassRefPtr<IDBAny> source)
+ : Event(type, false, false)
+ , m_source(source)
+{
+}
+
+IDBEvent::~IDBEvent()
+{
+}
+
+PassRefPtr<IDBAny> IDBEvent::source()
+{
+ return m_source;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/storage/IDBEvent.h b/WebCore/storage/IDBEvent.h
new file mode 100644
index 0000000..c44e449
--- /dev/null
+++ b/WebCore/storage/IDBEvent.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBEvent_h
+#define IDBEvent_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "Event.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class IDBAny;
+
+class IDBEvent : public Event {
+public:
+ virtual ~IDBEvent();
+
+ PassRefPtr<IDBAny> source();
+
+protected:
+ IDBEvent(const AtomicString& type, PassRefPtr<IDBAny> source);
+
+private:
+ RefPtr<IDBAny> m_source;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // IDBEvent_h
diff --git a/WebCore/storage/IDBEvent.idl b/WebCore/storage/IDBEvent.idl
new file mode 100644
index 0000000..4dd552e
--- /dev/null
+++ b/WebCore/storage/IDBEvent.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module storage {
+
+ interface [
+ Conditional=INDEXED_DATABASE
+ ] IDBEvent : Event {
+ readonly attribute IDBAny source;
+ };
+}
diff --git a/WebCore/storage/IDBRequest.cpp b/WebCore/storage/IDBRequest.cpp
new file mode 100644
index 0000000..a77377f
--- /dev/null
+++ b/WebCore/storage/IDBRequest.cpp
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBRequest.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "Event.h"
+#include "EventException.h"
+#include "EventListener.h"
+#include "EventNames.h"
+#include "IDBDatabaseRequest.h"
+#include "IDBErrorEvent.h"
+#include "IDBSuccessEvent.h"
+#include "ScriptExecutionContext.h"
+
+namespace WebCore {
+
+IDBRequest::IDBRequest(ScriptExecutionContext* context, PassRefPtr<IDBAny> source)
+ : ActiveDOMObject(context, this)
+ , m_source(source)
+ , m_result(IDBAny::create())
+ , m_timer(this, &IDBRequest::timerFired)
+ , m_stopped(false)
+ , m_aborted(false)
+ , m_readyState(INITIAL)
+{
+}
+
+IDBRequest::~IDBRequest()
+{
+ if (m_readyState != DONE)
+ abort();
+}
+
+void IDBRequest::onError(PassRefPtr<IDBDatabaseError> error)
+{
+ onEventCommon();
+ m_error = error;
+}
+
+void IDBRequest::onSuccess(PassRefPtr<IDBDatabase> idbDatabase)
+{
+ onEventCommon();
+ m_result->set(IDBDatabaseRequest::create(idbDatabase));
+}
+
+void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> serializedScriptValue)
+{
+ onEventCommon();
+ m_result->set(serializedScriptValue);
+}
+
+void IDBRequest::abort()
+{
+ m_timer.stop();
+ m_aborted = true;
+ // FIXME: This should cancel any pending work being done in the backend.
+}
+
+ScriptExecutionContext* IDBRequest::scriptExecutionContext() const
+{
+ return ActiveDOMObject::scriptExecutionContext();
+}
+
+void IDBRequest::stop()
+{
+ abort();
+ m_selfRef = 0; // Could trigger a delete.
+}
+
+void IDBRequest::suspend()
+{
+ m_timer.stop();
+ m_stopped = true;
+}
+
+void IDBRequest::resume()
+{
+ m_stopped = false;
+ // We only hold our self ref when we're waiting to dispatch an event.
+ if (m_selfRef && !m_aborted)
+ m_timer.startOneShot(0);
+}
+
+EventTargetData* IDBRequest::eventTargetData()
+{
+ return &m_eventTargetData;
+}
+
+EventTargetData* IDBRequest::ensureEventTargetData()
+{
+ return &m_eventTargetData;
+}
+
+void IDBRequest::timerFired(Timer<IDBRequest>*)
+{
+ ASSERT(m_readyState == DONE);
+ ASSERT(m_selfRef);
+ ASSERT(!m_stopped);
+ ASSERT(!m_aborted);
+
+ // We need to keep self-referencing ourself, otherwise it's possible we'll be deleted.
+ // But in some cases, suspend() could be called while we're dispatching an event, so we
+ // need to make sure that resume() doesn't re-start the timer based on m_selfRef being set.
+ RefPtr<IDBRequest> selfRef = m_selfRef.release();
+
+ if (m_error) {
+ ASSERT(m_result->type() == IDBAny::UndefinedType);
+ dispatchEvent(IDBErrorEvent::create(m_source, *m_error));
+ } else {
+ ASSERT(m_result->type() != IDBAny::UndefinedType);
+ dispatchEvent(IDBSuccessEvent::create(m_source, m_result));
+ }
+}
+
+void IDBRequest::onEventCommon()
+{
+ ASSERT(m_readyState < DONE);
+ ASSERT(m_result->type() == IDBAny::UndefinedType);
+ ASSERT(!m_error);
+ ASSERT(!m_selfRef);
+ ASSERT(!m_timer.isActive());
+
+ if (m_aborted)
+ return;
+
+ m_readyState = DONE;
+ m_selfRef = this;
+ if (!m_stopped)
+ m_timer.startOneShot(0);
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/storage/IDBRequest.h b/WebCore/storage/IDBRequest.h
new file mode 100644
index 0000000..0c37c96
--- /dev/null
+++ b/WebCore/storage/IDBRequest.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBRequest_h
+#define IDBRequest_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "ActiveDOMObject.h"
+#include "EventListener.h"
+#include "EventNames.h"
+#include "EventTarget.h"
+#include "IDBAny.h"
+#include "IDBCallbacks.h"
+#include "Timer.h"
+
+namespace WebCore {
+
+class IDBDatabaseRequest;
+
+class IDBRequest : public IDBCallbacks, public EventTarget, public ActiveDOMObject {
+public:
+ static PassRefPtr<IDBRequest> create(ScriptExecutionContext* context, PassRefPtr<IDBAny> source) { return adoptRef(new IDBRequest(context, source)); }
+ virtual ~IDBRequest();
+
+ // Defined in the IDL
+ void abort();
+ enum ReadyState {
+ INITIAL = 0,
+ LOADING = 1,
+ DONE = 2
+ };
+ unsigned short readyState() const { return m_readyState; }
+ PassRefPtr<IDBDatabaseError> error() const { return m_error; }
+ PassRefPtr<IDBAny> result() { return m_result; }
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(success);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
+
+ // IDBCallbacks
+ virtual void onError(PassRefPtr<IDBDatabaseError>);
+ virtual void onSuccess(PassRefPtr<IDBDatabase>);
+ virtual void onSuccess(PassRefPtr<SerializedScriptValue>);
+ // FIXME: Have one onSuccess function for each possible result type.
+
+ // EventTarget
+ virtual IDBRequest* toIDBRequest() { return this; }
+
+ // ActiveDOMObject
+ virtual ScriptExecutionContext* scriptExecutionContext() const;
+ virtual void stop();
+ virtual void suspend();
+ virtual void resume();
+
+ using RefCounted<IDBCallbacks>::ref;
+ using RefCounted<IDBCallbacks>::deref;
+
+private:
+ IDBRequest(ScriptExecutionContext*, PassRefPtr<IDBAny> source);
+
+ void timerFired(Timer<IDBRequest>*);
+ void onEventCommon();
+
+ // EventTarget
+ virtual void refEventTarget() { ref(); }
+ virtual void derefEventTarget() { deref(); }
+ virtual EventTargetData* eventTargetData();
+ virtual EventTargetData* ensureEventTargetData();
+
+ RefPtr<IDBAny> m_source;
+
+ RefPtr<IDBAny> m_result;
+ RefPtr<IDBDatabaseError> m_error;
+
+ // Used to fire events asynchronously.
+ Timer<IDBRequest> m_timer;
+ RefPtr<IDBRequest> m_selfRef; // This is set to us iff there's an event pending.
+
+ bool m_stopped;
+ bool m_aborted;
+ ReadyState m_readyState;
+ EventTargetData m_eventTargetData;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // IDBRequest_h
diff --git a/WebCore/storage/IDBRequest.idl b/WebCore/storage/IDBRequest.idl
new file mode 100644
index 0000000..9d7e0e4
--- /dev/null
+++ b/WebCore/storage/IDBRequest.idl
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module storage {
+
+ interface [
+ Conditional=INDEXED_DATABASE,
+ EventTarget
+ ] IDBRequest {
+ void abort();
+
+ // States
+ const unsigned short INITIAL = 0;
+ const unsigned short LOADING = 1;
+ const unsigned short DONE = 2;
+ readonly attribute unsigned short readyState;
+
+ // Possible results
+ readonly attribute IDBDatabaseError error;
+ readonly attribute IDBAny result;
+
+ // Events
+ attribute EventListener onsuccess;
+ attribute EventListener onerror;
+
+ // EventTarget interface
+ void addEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ void removeEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ boolean dispatchEvent(in Event evt)
+ raises(EventException);
+ };
+}
diff --git a/WebCore/storage/IDBSuccessEvent.cpp b/WebCore/storage/IDBSuccessEvent.cpp
new file mode 100644
index 0000000..9660eef
--- /dev/null
+++ b/WebCore/storage/IDBSuccessEvent.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBSuccessEvent.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "EventNames.h"
+#include "IDBAny.h"
+
+namespace WebCore {
+
+PassRefPtr<IDBSuccessEvent> IDBSuccessEvent::create(PassRefPtr<IDBAny> source, PassRefPtr<IDBAny> result)
+{
+ return adoptRef(new IDBSuccessEvent(source, result));
+}
+
+IDBSuccessEvent::IDBSuccessEvent(PassRefPtr<IDBAny> source, PassRefPtr<IDBAny> result)
+ : IDBEvent(eventNames().errorEvent, source)
+ , m_result(result)
+{
+}
+
+IDBSuccessEvent::~IDBSuccessEvent()
+{
+}
+
+PassRefPtr<IDBAny> IDBSuccessEvent::result()
+{
+ return m_result;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/storage/IDBSuccessEvent.h b/WebCore/storage/IDBSuccessEvent.h
new file mode 100644
index 0000000..5be660a
--- /dev/null
+++ b/WebCore/storage/IDBSuccessEvent.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBSuccessEvent_h
+#define IDBSuccessEvent_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBEvent.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class IDBAny;
+
+class IDBSuccessEvent : public IDBEvent {
+public:
+ static PassRefPtr<IDBSuccessEvent> create(PassRefPtr<IDBAny> source, PassRefPtr<IDBAny> result);
+ // FIXME: Need to allow creation of these events from JS.
+ virtual ~IDBSuccessEvent();
+
+ PassRefPtr<IDBAny> result();
+
+ virtual bool isIDBSuccessEvent() const { return true; }
+
+private:
+ IDBSuccessEvent(PassRefPtr<IDBAny> source, PassRefPtr<IDBAny> result);
+
+ RefPtr<IDBAny> m_result;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // IDBEvent_h
diff --git a/WebCore/storage/IDBSuccessEvent.idl b/WebCore/storage/IDBSuccessEvent.idl
new file mode 100644
index 0000000..b4ea7d2
--- /dev/null
+++ b/WebCore/storage/IDBSuccessEvent.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module storage {
+
+ interface [
+ Conditional=INDEXED_DATABASE
+ ] IDBSuccessEvent : IDBEvent {
+ readonly attribute IDBAny result;
+ };
+}
diff --git a/WebCore/storage/IndexedDatabase.h b/WebCore/storage/IndexedDatabase.h
index 1027fb7..1e43781 100644
--- a/WebCore/storage/IndexedDatabase.h
+++ b/WebCore/storage/IndexedDatabase.h
@@ -40,8 +40,6 @@ namespace WebCore {
class Frame;
class IDBDatabase;
-typedef IDBCallbacks<IDBDatabase> IDBDatabaseCallbacks;
-
// This class is shared by IndexedDatabaseRequest (async) and IndexedDatabaseSync (sync).
// This is implemented by IndexedDatabaseImpl and optionally others (in order to proxy
// calls across process barriers). All calls to these classes should be non-blocking and
@@ -51,7 +49,7 @@ public:
static PassRefPtr<IndexedDatabase> create();
virtual ~IndexedDatabase() { }
- virtual void open(const String& name, const String& description, bool modifyDatabase, PassRefPtr<IDBDatabaseCallbacks>, Frame*, ExceptionCode&) = 0;
+ virtual void open(const String& name, const String& description, bool modifyDatabase, PassRefPtr<IDBCallbacks>, Frame*, ExceptionCode&) = 0;
};
} // namespace WebCore
diff --git a/WebCore/storage/IndexedDatabaseImpl.cpp b/WebCore/storage/IndexedDatabaseImpl.cpp
index b82dee8..b3051c9 100644
--- a/WebCore/storage/IndexedDatabaseImpl.cpp
+++ b/WebCore/storage/IndexedDatabaseImpl.cpp
@@ -31,6 +31,7 @@
#include "IDBDatabase.h"
#include "IDBDatabaseError.h"
#include <wtf/Threading.h>
+#include <wtf/UnusedParam.h>
#if ENABLE(INDEXED_DATABASE)
@@ -49,10 +50,13 @@ IndexedDatabaseImpl::~IndexedDatabaseImpl()
{
}
-void IndexedDatabaseImpl::open(const String& name, const String& description, bool modifyDatabase, PassRefPtr<IDBDatabaseCallbacks>, Frame*, ExceptionCode&)
+void IndexedDatabaseImpl::open(const String& name, const String& description, bool modifyDatabase, PassRefPtr<IDBCallbacks> callbacks, Frame*, ExceptionCode&)
{
- // FIXME: Write.
- ASSERT_NOT_REACHED();
+ // FIXME: Write for realz.
+ UNUSED_PARAM(name);
+ UNUSED_PARAM(description);
+ UNUSED_PARAM(modifyDatabase);
+ callbacks->onError(IDBDatabaseError::create(0, "Not implemented"));
}
} // namespace WebCore
diff --git a/WebCore/storage/IndexedDatabaseImpl.h b/WebCore/storage/IndexedDatabaseImpl.h
index 5413b9b..73edf6b 100644
--- a/WebCore/storage/IndexedDatabaseImpl.h
+++ b/WebCore/storage/IndexedDatabaseImpl.h
@@ -39,7 +39,7 @@ public:
static PassRefPtr<IndexedDatabaseImpl> create();
virtual ~IndexedDatabaseImpl();
- virtual void open(const String& name, const String& description, bool modifyDatabase, PassRefPtr<IDBCallbacks<IDBDatabase> >, Frame*, ExceptionCode&);
+ virtual void open(const String& name, const String& description, bool modifyDatabase, PassRefPtr<IDBCallbacks>, Frame*, ExceptionCode&);
private:
IndexedDatabaseImpl();
diff --git a/WebCore/storage/IndexedDatabaseRequest.cpp b/WebCore/storage/IndexedDatabaseRequest.cpp
index 4430115..2210a8d 100644
--- a/WebCore/storage/IndexedDatabaseRequest.cpp
+++ b/WebCore/storage/IndexedDatabaseRequest.cpp
@@ -30,7 +30,9 @@
#include "IndexedDatabaseRequest.h"
#include "ExceptionCode.h"
+#include "Frame.h"
#include "IDBDatabase.h"
+#include "IDBRequest.h"
#include "IndexedDatabase.h"
#if ENABLE(INDEXED_DATABASE)
@@ -41,15 +43,19 @@ IndexedDatabaseRequest::IndexedDatabaseRequest(IndexedDatabase* indexedDatabase,
: m_indexedDatabase(indexedDatabase)
, m_frame(frame)
{
+ m_this = IDBAny::create();
+ m_this->set(this);
}
IndexedDatabaseRequest::~IndexedDatabaseRequest()
{
}
-void IndexedDatabaseRequest::open(const String& name, const String& description, bool modifyDatabase, PassRefPtr<IDBDatabaseCallbacks> callbacks, ExceptionCode& exception)
+PassRefPtr<IDBRequest> IndexedDatabaseRequest::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& exception)
{
- m_indexedDatabase->open(name, description, modifyDatabase, callbacks, m_frame, exception);
+ RefPtr<IDBRequest> request = IDBRequest::create(m_frame->document(), m_this);
+ m_indexedDatabase->open(name, description, modifyDatabase, request, m_frame, exception);
+ return request;
}
} // namespace WebCore
diff --git a/WebCore/storage/IndexedDatabaseRequest.h b/WebCore/storage/IndexedDatabaseRequest.h
index 83235b6..0b59790 100644
--- a/WebCore/storage/IndexedDatabaseRequest.h
+++ b/WebCore/storage/IndexedDatabaseRequest.h
@@ -39,8 +39,9 @@
namespace WebCore {
-class IndexedDatabase;
class Frame;
+class IDBAny;
+class IndexedDatabase;
class IndexedDatabaseRequest : public RefCounted<IndexedDatabaseRequest> {
public:
@@ -50,14 +51,15 @@ public:
}
~IndexedDatabaseRequest();
- void open(const String& name, const String& description, bool modifyDatabase, PassRefPtr<IDBDatabaseCallbacks>, ExceptionCode&);
+ PassRefPtr<IDBRequest> open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&);
void disconnectFrame() { m_frame = 0; }
private:
IndexedDatabaseRequest(IndexedDatabase*, Frame*);
- PassRefPtr<IndexedDatabase> m_indexedDatabase;
+ RefPtr<IndexedDatabase> m_indexedDatabase;
+ RefPtr<IDBAny> m_this;
Frame* m_frame;
};
diff --git a/WebCore/storage/IndexedDatabaseRequest.idl b/WebCore/storage/IndexedDatabaseRequest.idl
index 2c2a90e..e423eb0 100644
--- a/WebCore/storage/IndexedDatabaseRequest.idl
+++ b/WebCore/storage/IndexedDatabaseRequest.idl
@@ -30,7 +30,7 @@ module storage {
interface [
Conditional=INDEXED_DATABASE
] IndexedDatabaseRequest {
- [Custom] void open(in DOMString name, in DOMString description, in optional boolean modifyDatabase, IDBDatabaseErrorCallback onerror, IDBDatabaseRequestCallback onsuccess)
+ IDBRequest open(in DOMString name, in DOMString description, in boolean modifyDatabase)
raises(IDBDatabaseException);
};
diff --git a/WebCore/storage/SQLError.idl b/WebCore/storage/SQLError.idl
index 503fe6f..b50a8bc 100644
--- a/WebCore/storage/SQLError.idl
+++ b/WebCore/storage/SQLError.idl
@@ -30,7 +30,8 @@ module storage {
interface [
Conditional=DATABASE,
- OmitConstructor
+ OmitConstructor,
+ NoStaticTables
] SQLError {
readonly attribute unsigned long code;
readonly attribute DOMString message;
diff --git a/WebCore/storage/SQLResultSet.idl b/WebCore/storage/SQLResultSet.idl
index c98fff6..0b70e01 100644
--- a/WebCore/storage/SQLResultSet.idl
+++ b/WebCore/storage/SQLResultSet.idl
@@ -30,7 +30,8 @@ module storage {
interface [
Conditional=DATABASE,
- OmitConstructor
+ OmitConstructor,
+ NoStaticTables
] SQLResultSet {
readonly attribute SQLResultSetRowList rows;
diff --git a/WebCore/storage/SQLResultSetRowList.idl b/WebCore/storage/SQLResultSetRowList.idl
index 7ae7a9c..26239cb 100644
--- a/WebCore/storage/SQLResultSetRowList.idl
+++ b/WebCore/storage/SQLResultSetRowList.idl
@@ -30,7 +30,8 @@ module storage {
interface [
Conditional=DATABASE,
- OmitConstructor
+ OmitConstructor,
+ NoStaticTables
] SQLResultSetRowList {
readonly attribute unsigned long length;
[Custom] DOMObject item(in unsigned long index);
diff --git a/WebCore/storage/SQLTransaction.cpp b/WebCore/storage/SQLTransaction.cpp
index aebc293..7f16b63 100644
--- a/WebCore/storage/SQLTransaction.cpp
+++ b/WebCore/storage/SQLTransaction.cpp
@@ -466,12 +466,12 @@ void SQLTransaction::postflightAndCommit()
return;
}
- // The commit was successful, so vacuum the database if needed
- m_database->incrementalVacuumIfNeeded();
-
- // The commit was successful, notify the delegates if the transaction modified this database
- if (m_modifiedDatabase)
+ // The commit was successful. If the transaction modified this database,
+ // vacuum the database if needed and notify the delegates.
+ if (m_modifiedDatabase) {
+ m_database->incrementalVacuumIfNeeded();
m_database->transactionClient()->didCommitTransaction(this);
+ }
// Now release our unneeded callbacks, to break reference cycles.
m_callback = 0;
diff --git a/WebCore/storage/SQLTransaction.idl b/WebCore/storage/SQLTransaction.idl
index 7d694e8..4e353d3 100644
--- a/WebCore/storage/SQLTransaction.idl
+++ b/WebCore/storage/SQLTransaction.idl
@@ -30,7 +30,8 @@ module storage {
interface [
Conditional=DATABASE,
- OmitConstructor
+ OmitConstructor,
+ NoStaticTables
] SQLTransaction {
[Custom] void executeSql(in DOMString sqlStatement, in ObjectArray arguments, in SQLStatementCallback callback, in SQLStatementErrorCallback errorCallback);
};
diff --git a/WebCore/storage/SQLTransactionSync.idl b/WebCore/storage/SQLTransactionSync.idl
new file mode 100644
index 0000000..a4002b1
--- /dev/null
+++ b/WebCore/storage/SQLTransactionSync.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module storage {
+
+ interface [
+ Conditional=DATABASE,
+ OmitConstructor,
+ NoStaticTables
+ ] SQLTransactionSync {
+ [Custom] SQLResultSet executeSql(in DOMString sqlStatement, in ObjectArray arguments);
+ };
+}
diff --git a/WebCore/storage/SQLTransactionSyncCallback.h b/WebCore/storage/SQLTransactionSyncCallback.h
index d32bbfa..416a608 100644
--- a/WebCore/storage/SQLTransactionSyncCallback.h
+++ b/WebCore/storage/SQLTransactionSyncCallback.h
@@ -42,7 +42,7 @@ class SQLTransactionSync;
class SQLTransactionSyncCallback : public RefCounted<SQLTransactionSyncCallback> {
public:
virtual ~SQLTransactionSyncCallback() { }
- virtual void handleEvent(ScriptExecutionContext*, SQLTransactionSync*, bool& raisedException) = 0;
+ virtual bool handleEvent(ScriptExecutionContext*, SQLTransactionSync*) = 0;
};
}
diff --git a/WebCore/storage/SQLTransactionSyncCallback.idl b/WebCore/storage/SQLTransactionSyncCallback.idl
new file mode 100644
index 0000000..1bff22b
--- /dev/null
+++ b/WebCore/storage/SQLTransactionSyncCallback.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module storage {
+ interface [
+ Conditional=DATABASE,
+ Callback
+ ] SQLTransactionSyncCallback {
+ boolean handleEvent(in SQLTransactionSync transaction);
+ };
+}