IndexedDB IDL Refactoring.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2013 23:45:27 +0000 (23:45 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2013 23:45:27 +0000 (23:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121996

Reviewed by Alexey Proskuryakov.

This includes:
1 - Leveraging EventTarget.idl inheritance
2 - Removing comments
3 - Reordering to match the spec's IDLs
4 - Removing nonstandard, WebKit-specific methods
5 - Updating interfaces to match the spec (versions are only uint64_t's now...)
6 - Updating implementation code as needed (versions are only uint64_t's now...)

IDL changes:
* Modules/indexeddb/IDBCursor.idl:
* Modules/indexeddb/IDBDatabase.idl:
* Modules/indexeddb/IDBFactory.idl:
* Modules/indexeddb/IDBIndex.idl:
* Modules/indexeddb/IDBKeyRange.idl:
* Modules/indexeddb/IDBObjectStore.idl:
* Modules/indexeddb/IDBRequest.idl:
* Modules/indexeddb/IDBTransaction.idl:
* Modules/indexeddb/IDBVersionChangeEvent.idl:

* Modules/indexeddb/IndexedDB.h: Add new enum to represent version nullness.

Adapt to new IDLs, and also refactor representation of initial, null versioning:
* Modules/indexeddb/IDBCallbacks.h:
(WebCore::IDBCallbacks::onBlocked):
(WebCore::IDBCallbacks::onUpgradeNeeded):

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::version):
(WebCore::IDBDatabase::onVersionChange):
* Modules/indexeddb/IDBDatabase.h:

* Modules/indexeddb/IDBDatabaseCallbacks.h:
* Modules/indexeddb/IDBDatabaseCallbacksImpl.cpp:
(WebCore::IDBDatabaseCallbacksImpl::onVersionChange):
* Modules/indexeddb/IDBDatabaseCallbacksImpl.h:

* Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::open):
(WebCore::IDBFactory::openInternal):
(WebCore::IDBFactory::deleteDatabase):
* Modules/indexeddb/IDBFactory.h:

* Modules/indexeddb/IDBMetadata.h:
(WebCore::IDBDatabaseMetadata::IDBDatabaseMetadata):

* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::create):
(WebCore::IDBOpenDBRequest::IDBOpenDBRequest):
(WebCore::IDBOpenDBRequest::onBlocked):
(WebCore::IDBOpenDBRequest::onUpgradeNeeded):
* Modules/indexeddb/IDBOpenDBRequest.h:

* Modules/indexeddb/IDBRequest.cpp:
* Modules/indexeddb/IDBRequest.h:

* Modules/indexeddb/IDBTransaction.cpp:
* Modules/indexeddb/IDBTransaction.h:

* Modules/indexeddb/IDBVersionChangeEvent.cpp:
(WebCore::IDBVersionChangeEvent::IDBVersionChangeEvent):
* Modules/indexeddb/IDBVersionChangeEvent.h:
(WebCore::IDBVersionChangeEvent::create):
(WebCore::IDBVersionChangeEvent::oldVersion):
(WebCore::IDBVersionChangeEvent::newVersion):

Keep leveldb building with minimal adaptations to the new IDLs,
but note that the LevelDB implementation is now incompatible with the spec:
* Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
(WebCore::IDBBackingStore::getIDBDatabaseMetaData):
(WebCore::objectStoreCursorOptions):
(WebCore::indexCursorOptions):

* Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp:
(WebCore::IDBDatabaseBackendLevelDB::IDBDatabaseBackendLevelDB):
(WebCore::IDBDatabaseBackendLevelDB::openInternal):
(WebCore::IDBDatabaseBackendLevelDB::VersionChangeOperation::perform):
(WebCore::IDBDatabaseBackendLevelDB::processPendingCalls):
(WebCore::IDBDatabaseBackendLevelDB::openConnection):
(WebCore::IDBDatabaseBackendLevelDB::runIntVersionChangeTransaction):
(WebCore::IDBDatabaseBackendLevelDB::deleteDatabase):
(WebCore::IDBDatabaseBackendLevelDB::deleteDatabaseFinal):
(WebCore::IDBDatabaseBackendLevelDB::VersionChangeAbortOperation::perform):

* Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp:
(WebCore::IDBLevelDBCoding::compareEncodedIDBKeys):

* inspector/InspectorIndexedDBAgent.cpp: Update for metadata change.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156590 268f45cc-cd09-0410-ab3c-d52691b4dbfc

32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBCallbacks.h
Source/WebCore/Modules/indexeddb/IDBCursor.idl
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.h
Source/WebCore/Modules/indexeddb/IDBDatabase.idl
Source/WebCore/Modules/indexeddb/IDBDatabaseCallbacks.h
Source/WebCore/Modules/indexeddb/IDBDatabaseCallbacksImpl.cpp
Source/WebCore/Modules/indexeddb/IDBDatabaseCallbacksImpl.h
Source/WebCore/Modules/indexeddb/IDBFactory.cpp
Source/WebCore/Modules/indexeddb/IDBFactory.h
Source/WebCore/Modules/indexeddb/IDBFactory.idl
Source/WebCore/Modules/indexeddb/IDBIndex.idl
Source/WebCore/Modules/indexeddb/IDBKeyRange.idl
Source/WebCore/Modules/indexeddb/IDBMetadata.h
Source/WebCore/Modules/indexeddb/IDBObjectStore.idl
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.h
Source/WebCore/Modules/indexeddb/IDBRequest.idl
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/indexeddb/IDBTransaction.idl
Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.cpp
Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.h
Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.idl
Source/WebCore/Modules/indexeddb/IndexedDB.h
Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp
Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp
Source/WebCore/Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp

index 85ae1bb5b8020cef00ffd16b33a1230ece2eaa36..e6430d4f9cfbd12318aed6884b09fa7376293f3d 100644 (file)
@@ -1,3 +1,98 @@
+2013-09-27  Brady Eidson  <beidson@apple.com>
+
+        IndexedDB IDL Refactoring.
+        https://bugs.webkit.org/show_bug.cgi?id=121996
+
+        Reviewed by Alexey Proskuryakov.
+
+        This includes:
+        1 - Leveraging EventTarget.idl inheritance
+        2 - Removing comments
+        3 - Reordering to match the spec's IDLs
+        4 - Removing nonstandard, WebKit-specific methods
+        5 - Updating interfaces to match the spec (versions are only uint64_t's now...)
+        6 - Updating implementation code as needed (versions are only uint64_t's now...)
+
+        IDL changes:
+        * Modules/indexeddb/IDBCursor.idl:
+        * Modules/indexeddb/IDBDatabase.idl:
+        * Modules/indexeddb/IDBFactory.idl:
+        * Modules/indexeddb/IDBIndex.idl:
+        * Modules/indexeddb/IDBKeyRange.idl:
+        * Modules/indexeddb/IDBObjectStore.idl:
+        * Modules/indexeddb/IDBRequest.idl:
+        * Modules/indexeddb/IDBTransaction.idl:
+        * Modules/indexeddb/IDBVersionChangeEvent.idl:
+
+        * Modules/indexeddb/IndexedDB.h: Add new enum to represent version nullness.
+
+        Adapt to new IDLs, and also refactor representation of initial, null versioning:
+        * Modules/indexeddb/IDBCallbacks.h:
+        (WebCore::IDBCallbacks::onBlocked):
+        (WebCore::IDBCallbacks::onUpgradeNeeded):
+
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::version):
+        (WebCore::IDBDatabase::onVersionChange):
+        * Modules/indexeddb/IDBDatabase.h:
+
+        * Modules/indexeddb/IDBDatabaseCallbacks.h:
+        * Modules/indexeddb/IDBDatabaseCallbacksImpl.cpp:
+        (WebCore::IDBDatabaseCallbacksImpl::onVersionChange):
+        * Modules/indexeddb/IDBDatabaseCallbacksImpl.h:
+
+        * Modules/indexeddb/IDBFactory.cpp:
+        (WebCore::IDBFactory::open):
+        (WebCore::IDBFactory::openInternal):
+        (WebCore::IDBFactory::deleteDatabase):
+        * Modules/indexeddb/IDBFactory.h:
+
+        * Modules/indexeddb/IDBMetadata.h:
+        (WebCore::IDBDatabaseMetadata::IDBDatabaseMetadata):
+
+        * Modules/indexeddb/IDBOpenDBRequest.cpp:
+        (WebCore::IDBOpenDBRequest::create):
+        (WebCore::IDBOpenDBRequest::IDBOpenDBRequest):
+        (WebCore::IDBOpenDBRequest::onBlocked):
+        (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
+        * Modules/indexeddb/IDBOpenDBRequest.h:
+
+        * Modules/indexeddb/IDBRequest.cpp:
+        * Modules/indexeddb/IDBRequest.h:
+
+        * Modules/indexeddb/IDBTransaction.cpp:
+        * Modules/indexeddb/IDBTransaction.h:
+
+        * Modules/indexeddb/IDBVersionChangeEvent.cpp:
+        (WebCore::IDBVersionChangeEvent::IDBVersionChangeEvent):
+        * Modules/indexeddb/IDBVersionChangeEvent.h:
+        (WebCore::IDBVersionChangeEvent::create):
+        (WebCore::IDBVersionChangeEvent::oldVersion):
+        (WebCore::IDBVersionChangeEvent::newVersion):
+
+        Keep leveldb building with minimal adaptations to the new IDLs,
+        but note that the LevelDB implementation is now incompatible with the spec:
+        * Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
+        (WebCore::IDBBackingStore::getIDBDatabaseMetaData):
+        (WebCore::objectStoreCursorOptions):
+        (WebCore::indexCursorOptions):
+
+        * Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp:
+        (WebCore::IDBDatabaseBackendLevelDB::IDBDatabaseBackendLevelDB):
+        (WebCore::IDBDatabaseBackendLevelDB::openInternal):
+        (WebCore::IDBDatabaseBackendLevelDB::VersionChangeOperation::perform):
+        (WebCore::IDBDatabaseBackendLevelDB::processPendingCalls):
+        (WebCore::IDBDatabaseBackendLevelDB::openConnection):
+        (WebCore::IDBDatabaseBackendLevelDB::runIntVersionChangeTransaction):
+        (WebCore::IDBDatabaseBackendLevelDB::deleteDatabase):
+        (WebCore::IDBDatabaseBackendLevelDB::deleteDatabaseFinal):
+        (WebCore::IDBDatabaseBackendLevelDB::VersionChangeAbortOperation::perform):
+
+        * Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp:
+        (WebCore::IDBLevelDBCoding::compareEncodedIDBKeys):
+
+        * inspector/InspectorIndexedDBAgent.cpp: Update for metadata change.
+
 2013-09-27  Enrica Casucci  <enrica@apple.com>
 
         Upstream changes to Pasteboard implementation for iOS.
index da7de07066274791293377514576a447aa001028..9daa3f1c2fe682bce8f9284e32defdd41c38890e 100644 (file)
@@ -68,9 +68,9 @@ public:
     // From IDBCursor.advance()/continue()
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >& keys, const Vector<RefPtr<IDBKey> >& primaryKeys, const Vector<RefPtr<SharedBuffer> >& values) = 0;
     // From IDBFactory.open()/deleteDatabase()
-    virtual void onBlocked(int64_t /* existingVersion */) { ASSERT_NOT_REACHED(); }
+    virtual void onBlocked(uint64_t /* existingVersion */) { ASSERT_NOT_REACHED(); }
     // From IDBFactory.open()
-    virtual void onUpgradeNeeded(int64_t /* oldVersion */, PassRefPtr<IDBDatabaseBackendInterface>, const IDBDatabaseMetadata&) { ASSERT_NOT_REACHED(); }
+    virtual void onUpgradeNeeded(uint64_t /* oldVersion */, PassRefPtr<IDBDatabaseBackendInterface>, const IDBDatabaseMetadata&) { ASSERT_NOT_REACHED(); }
     virtual void onSuccess(PassRefPtr<IDBDatabaseBackendInterface>, const IDBDatabaseMetadata&) { ASSERT_NOT_REACHED(); }
 };
 
index 955407a0b4b0d18274bfc7268a4faf55725bf388..5043ec2e91731900f5d8c35b4e1cb9356faa0cc8 100644 (file)
     Conditional=INDEXED_DATABASE,
     JSNoStaticTables
 ] interface IDBCursor {
-
+    readonly attribute IDBAny source;
     readonly attribute DOMString direction;
     readonly attribute any key;
     readonly attribute any primaryKey;
-    readonly attribute IDBAny source;
 
     [CallWith=ScriptState, RaisesException] IDBRequest update(any value);
     [RaisesException] void advance([EnforceRange] unsigned long count);
index 8c4e5491497ecd1eb11bbd0ece5ee428bfe92b1e..87ca101cffbd28eda1f6429ca3d17b9dcbd90038 100644 (file)
@@ -131,12 +131,9 @@ PassRefPtr<DOMStringList> IDBDatabase::objectStoreNames() const
     return objectStoreNames.release();
 }
 
-PassRefPtr<IDBAny> IDBDatabase::version() const
+uint64_t IDBDatabase::version() const
 {
-    int64_t intVersion = m_metadata.intVersion;
-    if (intVersion == IDBDatabaseMetadata::NoIntVersion)
-        return IDBAny::createString(m_metadata.version);
-    return IDBAny::create(intVersion);
+    return m_metadata.version;
 }
 
 PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, const Dictionary& options, ExceptionCode& ec)
@@ -303,7 +300,7 @@ void IDBDatabase::closeConnection()
     }
 }
 
-void IDBDatabase::onVersionChange(int64_t oldVersion, int64_t newVersion)
+void IDBDatabase::onVersionChange(uint64_t oldVersion, uint64_t newVersion, IndexedDB::VersionNullness newVersionNullness)
 {
     IDB_TRACE("IDBDatabase::onVersionChange");
     if (m_contextStopped || !scriptExecutionContext())
@@ -312,8 +309,7 @@ void IDBDatabase::onVersionChange(int64_t oldVersion, int64_t newVersion)
     if (m_closePending)
         return;
 
-    RefPtr<IDBAny> newVersionAny = newVersion == IDBDatabaseMetadata::NoIntVersion ? IDBAny::createNull() : IDBAny::create(newVersion);
-    enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), newVersionAny.release(), eventNames().versionchangeEvent));
+    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, newVersion, newVersionNullness));
 }
 
 void IDBDatabase::enqueueEvent(PassRefPtr<Event> event)
index 2a46e46b4cc5dbf5859c27ee46923a41a206af34..9025311afe325cb2b3a78d938d2b5ed0547bb729 100644 (file)
@@ -60,7 +60,7 @@ public:
 
     // Implement the IDL
     const String name() const { return m_metadata.name; }
-    PassRefPtr<IDBAny> version() const;
+    uint64_t version() const;
     PassRefPtr<DOMStringList> objectStoreNames() const;
 
     PassRefPtr<IDBObjectStore> createObjectStore(const String& name, const Dictionary&, ExceptionCode&);
@@ -76,7 +76,7 @@ public:
     DEFINE_ATTRIBUTE_EVENT_LISTENER(versionchange);
 
     // IDBDatabaseCallbacks
-    virtual void onVersionChange(int64_t oldVersion, int64_t newVersion);
+    virtual void onVersionChange(uint64_t oldVersion, uint64_t newVersion, IndexedDB::VersionNullness newVersionNullness);
     virtual void onAbort(int64_t, PassRefPtr<IDBDatabaseError>);
     virtual void onComplete(int64_t);
 
index 2c5cc86b2ee0eff1a06618b85c3ed8d039a9364f..d6038f29e33caec2ad3db43559c40201c7a6da04 100644 (file)
     ActiveDOMObject,
     EventTarget,
     JSNoStaticTables
-] interface IDBDatabase {
+] interface IDBDatabase : EventTarget {
     readonly attribute DOMString name;
-    readonly attribute IDBAny version;
+    readonly attribute unsigned long long version;
     readonly attribute DOMStringList objectStoreNames;
 
-    attribute EventListener onabort;
-    attribute EventListener onerror;
-    attribute EventListener onversionchange;
-
     [Custom, RaisesException] IDBObjectStore createObjectStore(DOMString name, optional Dictionary options);
     [RaisesException] void deleteObjectStore(DOMString name);
-    [CallWith=ScriptExecutionContext, RaisesException] IDBTransaction transaction(DOMStringList storeNames, [Default=NullString] optional DOMString mode);
-    [CallWith=ScriptExecutionContext, RaisesException] IDBTransaction transaction(sequence<DOMString> storeNames, [Default=NullString] optional DOMString mode);
     [CallWith=ScriptExecutionContext, RaisesException] IDBTransaction transaction(DOMString storeName, [Default=NullString] optional DOMString mode);
-
+    [CallWith=ScriptExecutionContext, RaisesException] IDBTransaction transaction(sequence<DOMString> storeNames, [Default=NullString] optional DOMString mode);
     void close();
 
-    // EventTarget interface
-    void addEventListener(DOMString type,
-                          EventListener listener,
-                          optional boolean useCapture);
-    void removeEventListener(DOMString type,
-                             EventListener listener,
-                             optional boolean useCapture);
-    [RaisesException] boolean dispatchEvent(Event evt);
+    attribute EventListener onabort;
+    attribute EventListener onerror;
+    attribute EventListener onversionchange;
+
 };
 
index fc242e058fd48e6aea8e5564da21e1a6b92a6993..7770abf6bfbd15d26cd4a3b9418855ec2fc8eed2 100644 (file)
 #if ENABLE(INDEXED_DATABASE)
 
 #include "IDBDatabaseError.h"
+#include "IndexedDB.h"
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
+class IDBDatabase;
+
 class IDBDatabaseCallbacks : public RefCounted<IDBDatabaseCallbacks> {
 public:
     virtual ~IDBDatabaseCallbacks() { }
 
     virtual void onForcedClose() = 0;
-    virtual void onVersionChange(int64_t oldVersion, int64_t newVersion) = 0;
+    virtual void onVersionChange(uint64_t oldVersion, uint64_t newVersion, IndexedDB::VersionNullness newVersionNullness) = 0;
 
     virtual void onAbort(int64_t transactionId, PassRefPtr<IDBDatabaseError>) = 0;
     virtual void onComplete(int64_t transactionId) = 0;
+
+    virtual void connect(IDBDatabase*) = 0;
 };
 
 } // namespace WebCore
index 42af7a275015662b7e8cdaf0eddab3724de67cd2..587c4a756301a3c4a8656e35f0268bb7de4559c2 100644 (file)
@@ -52,10 +52,10 @@ void IDBDatabaseCallbacksImpl::onForcedClose()
         m_database->forceClose();
 }
 
-void IDBDatabaseCallbacksImpl::onVersionChange(int64_t oldVersion, int64_t newVersion)
+void IDBDatabaseCallbacksImpl::onVersionChange(uint64_t oldVersion, uint64_t newVersion, IndexedDB::VersionNullness newVersionNullness)
 {
     if (m_database)
-        m_database->onVersionChange(oldVersion, newVersion);
+        m_database->onVersionChange(oldVersion, newVersion, newVersionNullness);
 }
 
 void IDBDatabaseCallbacksImpl::connect(IDBDatabase* database)
index 5a78b373581f6b038caf039ae07ab7f933bf1ad0..4fd7559f50182581c77591c043dff1f46b7639ce 100644 (file)
@@ -36,19 +36,19 @@ namespace WebCore {
 
 class IDBDatabase;
 
-class IDBDatabaseCallbacksImpl : public IDBDatabaseCallbacks {
+class IDBDatabaseCallbacksImpl FINAL : public IDBDatabaseCallbacks {
 public:
     static PassRefPtr<IDBDatabaseCallbacksImpl> create();
-    virtual ~IDBDatabaseCallbacksImpl();
+    virtual ~IDBDatabaseCallbacksImpl() OVERRIDE;
 
     // IDBDatabaseCallbacks
-    virtual void onForcedClose();
-    virtual void onVersionChange(int64_t oldVersion, int64_t newVersion);
+    virtual void onForcedClose() OVERRIDE;
+    virtual void onVersionChange(uint64_t oldVersion, uint64_t newVersion, IndexedDB::VersionNullness newVersionNullness) OVERRIDE;
 
-    virtual void onAbort(int64_t transactionId, PassRefPtr<IDBDatabaseError>);
-    virtual void onComplete(int64_t transactionId);
+    virtual void onAbort(int64_t transactionId, PassRefPtr<IDBDatabaseError>) OVERRIDE;
+    virtual void onComplete(int64_t transactionId) OVERRIDE;
 
-    void connect(IDBDatabase*);
+    virtual void connect(IDBDatabase*) OVERRIDE;
 
 private:
     IDBDatabaseCallbacksImpl();
index ea82007e04a3a7a60c8698211efa8c985e070ebc..c4fb0de730a1bd246e05c22e4d564fa98f3099c9 100644 (file)
@@ -113,6 +113,12 @@ PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* cont
     return request;
 }
 
+PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
+{
+    IDB_TRACE("IDBFactory::open");
+    return openInternal(context, name, 0, IndexedDB::NullVersion, ec);
+}
+
 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, unsigned long long version, ExceptionCode& ec)
 {
     IDB_TRACE("IDBFactory::open");
@@ -120,13 +126,13 @@ PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
         ec = TypeError;
         return 0;
     }
-    return openInternal(context, name, version, ec);
+    return openInternal(context, name, version, IndexedDB::NonNullVersion, ec);
 }
 
-PassRefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* context, const String& name, int64_t version, ExceptionCode& ec)
+PassRefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* context, const String& name, uint64_t version, IndexedDB::VersionNullness versionNullness, ExceptionCode& ec)
 {
     HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBOpenCall, IDBMethodsMax);
-    ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion);
+    ASSERT(version >= 1 || versionNullness == IndexedDB::NullVersion);
     if (name.isNull()) {
         ec = TypeError;
         return 0;
@@ -138,19 +144,13 @@ PassRefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* co
         return 0;
     }
 
-    RefPtr<IDBDatabaseCallbacksImpl> databaseCallbacks = IDBDatabaseCallbacksImpl::create();
+    RefPtr<IDBDatabaseCallbacks> databaseCallbacks = IDBDatabaseCallbacksImpl::create();
     int64_t transactionId = IDBDatabase::nextTransactionId();
-    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databaseCallbacks, transactionId, version);
+    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databaseCallbacks, transactionId, version, versionNullness);
     m_backend->open(name, version, transactionId, request, databaseCallbacks, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
     return request;
 }
 
-PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
-{
-    IDB_TRACE("IDBFactory::open");
-    return openInternal(context, name, IDBDatabaseMetadata::NoIntVersion, ec);
-}
-
 PassRefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
 {
     IDB_TRACE("IDBFactory::deleteDatabase");
@@ -166,7 +166,7 @@ PassRefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext*
         return 0;
     }
 
-    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, IDBDatabaseMetadata::DefaultIntVersion);
+    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, 0, IndexedDB::NullVersion);
     m_backend->deleteDatabase(name, request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
     return request;
 }
index 41e238507b0de09fc0360d2a4d1c971110bbbc57..9065d89d483bf1fa1d0612ff13d42a9ba608a14c 100644 (file)
@@ -68,7 +68,7 @@ public:
 private:
     IDBFactory(IDBFactoryBackendInterface*);
 
-    PassRefPtr<IDBOpenDBRequest> openInternal(ScriptExecutionContext*, const String& name, int64_t version, ExceptionCode&);
+    PassRefPtr<IDBOpenDBRequest> openInternal(ScriptExecutionContext*, const String& name, uint64_t version, IndexedDB::VersionNullness, ExceptionCode&);
 
     RefPtr<IDBFactoryBackendInterface> m_backend;
 };
index 90168a5873ac470e1a855eeb6b4b4a9697342461..896d638a301c8b0748d0d9d089bce3a02514c1f2 100644 (file)
     JSNoStaticTables,
     ImplementationLacksVTable
 ] interface IDBFactory {
-    [CallWith=ScriptExecutionContext, ImplementedAs=getDatabaseNames, RaisesException] IDBRequest webkitGetDatabaseNames();
-
     [CallWith=ScriptExecutionContext, RaisesException] IDBOpenDBRequest open(DOMString name, [EnforceRange] optional unsigned long long version);
     [CallWith=ScriptExecutionContext, RaisesException] IDBOpenDBRequest deleteDatabase(DOMString name);
-
     [CallWith=ScriptExecutionContext, RaisesException] short cmp(any first, any second);
 };
 
index cdacfe6952bc85364af926b892eebe120006e816..ba0b0ac1964c2920f0bc55766cc6425fcb7e2d28 100644 (file)
@@ -31,8 +31,8 @@
     readonly attribute DOMString name;
     readonly attribute IDBObjectStore objectStore;
     [ImplementedAs=keyPathAny] readonly attribute IDBAny keyPath;
-    readonly attribute boolean unique;
     readonly attribute boolean multiEntry;
+    readonly attribute boolean unique;
 
     [CallWith=ScriptExecutionContext, RaisesException] IDBRequest openCursor(optional IDBKeyRange? range, optional DOMString direction);
     [CallWith=ScriptExecutionContext, RaisesException] IDBRequest openCursor(any key, optional DOMString direction);
index c60d740426a749cbc5d6eb42635fc81b455f5deb..0fec31a6ad49f198d59d4c53af215db1dd427025 100644 (file)
@@ -34,8 +34,8 @@
     readonly attribute boolean upperOpen;
 
     [CallWith=ScriptExecutionContext, RaisesException] static IDBKeyRange only(any value);
-    [CallWith=ScriptExecutionContext, RaisesException] static IDBKeyRange lowerBound(any bound, optional boolean open);
-    [CallWith=ScriptExecutionContext, RaisesException] static IDBKeyRange upperBound(any bound, optional boolean open);
+    [CallWith=ScriptExecutionContext, RaisesException] static IDBKeyRange lowerBound(any lower, optional boolean open);
+    [CallWith=ScriptExecutionContext, RaisesException] static IDBKeyRange upperBound(any upper, optional boolean open);
     [CallWith=ScriptExecutionContext, RaisesException] static IDBKeyRange bound(any lower, any upper, optional boolean lowerOpen, optional boolean upperOpen);
 };
 
index c3b33346301cc71e6e0b0b5ecac0a8c65150484e..16e8762b37d37b351383af4efc61d54c57854d80 100644 (file)
@@ -30,6 +30,7 @@
 #define IDBMetadata_h
 
 #include "IDBKeyPath.h"
+#include <stdint.h>
 #include <wtf/HashMap.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
@@ -79,31 +80,45 @@ struct IDBObjectStoreMetadata {
 };
 
 struct IDBDatabaseMetadata {
-    // FIXME: These can probably be collapsed into 0.
+
+#if USE(LEVELDB)
+    // FIXME: These are only here to support the LevelDB backend which incorrectly handles versioning.
+    // Once LevelDB supports a single, uint64_t version and throws out the old string version, these
+    // should be gotten rid of.
+    // Also, "NoIntVersion" used to be a magic number of -1, which doesn't work with the new unsigned type.
+    // Changing the value to INT64_MAX here seems like a reasonable temporary fix as the current LevelDB
+    // already cannot represent valid version numbers between INT64_MAX and UINT64_MAX.
+
+#ifndef INT64_MAX
+#define INT64_MAX 9223372036854775807LL
+#endif
+
     enum {
-        NoIntVersion = -1,
+        NoIntVersion = INT64_MAX,
         DefaultIntVersion = 0
     };
+#endif // USE(LEVELDB)
 
     typedef HashMap<int64_t, IDBObjectStoreMetadata> ObjectStoreMap;
 
     IDBDatabaseMetadata()
-        : intVersion(NoIntVersion)
+        : id(0)
+        , version(0)
+        , maxObjectStoreId(0)
     {
     }
-    IDBDatabaseMetadata(const String& name, int64_t id, const String& version, int64_t intVersion, int64_t maxObjectStoreId)
+
+    IDBDatabaseMetadata(const String& name, int64_t id, uint64_t version, int64_t maxObjectStoreId)
         : name(name)
         , id(id)
         , version(version)
-        , intVersion(intVersion)
         , maxObjectStoreId(maxObjectStoreId)
     {
     }
 
     String name;
     int64_t id;
-    String version;
-    int64_t intVersion;
+    uint64_t version;
     int64_t maxObjectStoreId;
 
     ObjectStoreMap objectStores;
index c72a91b0a85535113c7de2963a4a5fec98c89acb..463b9fbec68efd0c97e940bdc701bdcfb52334a9 100644 (file)
     [CallWith=ScriptState, RaisesException] IDBRequest add(any value, optional any key);
     [CallWith=ScriptExecutionContext, ImplementedAs=deleteFunction, RaisesException] IDBRequest delete(IDBKeyRange? keyRange);
     [CallWith=ScriptExecutionContext, ImplementedAs=deleteFunction, RaisesException] IDBRequest delete(any key);
-    [CallWith=ScriptExecutionContext, RaisesException] IDBRequest clear();
     [CallWith=ScriptExecutionContext, RaisesException] IDBRequest get(IDBKeyRange? key);
     [CallWith=ScriptExecutionContext, RaisesException] IDBRequest get(any key);
+    [CallWith=ScriptExecutionContext, RaisesException] IDBRequest clear();
     [CallWith=ScriptExecutionContext, RaisesException] IDBRequest openCursor(optional IDBKeyRange? range, optional DOMString direction);
     [CallWith=ScriptExecutionContext, RaisesException] IDBRequest openCursor(any key, optional DOMString direction);
-
     [CallWith=ScriptExecutionContext, Custom, RaisesException] IDBIndex createIndex(DOMString name, sequence<DOMString> keyPath, optional Dictionary options);
     [CallWith=ScriptExecutionContext, Custom, RaisesException] IDBIndex createIndex(DOMString name, DOMString keyPath, optional Dictionary options);
     [RaisesException] IDBIndex index(DOMString name);
index 56e0f164664fbfb2cc7432f8c849965e241e301f..9e2f027acdde6206d4ad15adb57a6810b2707383 100644 (file)
 
 namespace WebCore {
 
-PassRefPtr<IDBOpenDBRequest> IDBOpenDBRequest::create(ScriptExecutionContext* context, PassRefPtr<IDBDatabaseCallbacksImpl> callbacks, int64_t transactionId, int64_t version)
+PassRefPtr<IDBOpenDBRequest> IDBOpenDBRequest::create(ScriptExecutionContext* context, PassRefPtr<IDBDatabaseCallbacks> callbacks, int64_t transactionId, uint64_t version, IndexedDB::VersionNullness versionNullness)
 {
-    RefPtr<IDBOpenDBRequest> request(adoptRef(new IDBOpenDBRequest(context, callbacks, transactionId, version)));
+    RefPtr<IDBOpenDBRequest> request(adoptRef(new IDBOpenDBRequest(context, callbacks, transactionId, version, versionNullness)));
     request->suspendIfNeeded();
     return request.release();
 }
 
-IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext* context, PassRefPtr<IDBDatabaseCallbacksImpl> callbacks, int64_t transactionId, int64_t version)
+IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext* context, PassRefPtr<IDBDatabaseCallbacks> callbacks, int64_t transactionId, uint64_t version, IndexedDB::VersionNullness versionNullness)
     : IDBRequest(context, IDBAny::createNull(), IDBDatabaseBackendInterface::NormalTask, 0)
     , m_databaseCallbacks(callbacks)
     , m_transactionId(transactionId)
     , m_version(version)
+    , m_versionNullness(versionNullness)
 {
     ASSERT(!m_result);
 }
@@ -62,16 +63,16 @@ EventTargetInterface IDBOpenDBRequest::eventTargetInterface() const
     return IDBOpenDBRequestEventTargetInterfaceType;
 }
 
-void IDBOpenDBRequest::onBlocked(int64_t oldVersion)
+void IDBOpenDBRequest::onBlocked(uint64_t oldVersion)
 {
     IDB_TRACE("IDBOpenDBRequest::onBlocked()");
     if (!shouldEnqueueEvent())
         return;
-    RefPtr<IDBAny> newVersionAny = (m_version == IDBDatabaseMetadata::DefaultIntVersion) ? IDBAny::createNull() : IDBAny::create(m_version);
-    enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), newVersionAny.release(), eventNames().blockedEvent));
+    
+    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, m_version, m_versionNullness, eventNames().blockedEvent));
 }
 
-void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassRefPtr<IDBDatabaseBackendInterface> prpDatabaseBackend, const IDBDatabaseMetadata& metadata)
+void IDBOpenDBRequest::onUpgradeNeeded(uint64_t oldVersion, PassRefPtr<IDBDatabaseBackendInterface> prpDatabaseBackend, const IDBDatabaseMetadata& metadata)
 {
     IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()");
     if (m_contextStopped || !scriptExecutionContext()) {
@@ -92,19 +93,15 @@ void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassRefPtr<IDBDatabas
     m_databaseCallbacks->connect(idbDatabase.get());
     m_databaseCallbacks = 0;
 
-    if (oldVersion == IDBDatabaseMetadata::NoIntVersion) {
-        // This database hasn't had an integer version before.
-        oldVersion = IDBDatabaseMetadata::DefaultIntVersion;
-    }
     IDBDatabaseMetadata oldMetadata(metadata);
-    oldMetadata.intVersion = oldVersion;
+    oldMetadata.version = oldVersion;
 
     m_transaction = IDBTransaction::create(scriptExecutionContext(), m_transactionId, idbDatabase.get(), this, oldMetadata);
     m_result = IDBAny::create(idbDatabase.release());
 
-    if (m_version == IDBDatabaseMetadata::NoIntVersion)
+    if (m_versionNullness == IndexedDB::NullVersion)
         m_version = 1;
-    enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), IDBAny::create(m_version), eventNames().upgradeneededEvent));
+    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, m_version, m_versionNullness, eventNames().upgradeneededEvent));
 }
 
 void IDBOpenDBRequest::onSuccess(PassRefPtr<IDBDatabaseBackendInterface> prpBackend, const IDBDatabaseMetadata& metadata)
index 2fced98d833c3d38f6faca83c91dd33d1eaa5d75..960459da9724d834487396eafcbd37e92045a51b 100644 (file)
 #if ENABLE(INDEXED_DATABASE)
 
 #include "IDBRequest.h"
+#include "IndexedDB.h"
 
 namespace WebCore {
 
-class IDBDatabaseCallbacksImpl;
+class IDBDatabaseCallbacks;
 
 class IDBOpenDBRequest : public IDBRequest {
 public:
-    static PassRefPtr<IDBOpenDBRequest> create(ScriptExecutionContext*, PassRefPtr<IDBDatabaseCallbacksImpl>, int64_t transactionId, int64_t version);
+    static PassRefPtr<IDBOpenDBRequest> create(ScriptExecutionContext*, PassRefPtr<IDBDatabaseCallbacks>, int64_t transactionId, uint64_t version, IndexedDB::VersionNullness);
     virtual ~IDBOpenDBRequest();
 
     using IDBRequest::onSuccess;
 
-    virtual void onBlocked(int64_t existingVersion) OVERRIDE;
-    virtual void onUpgradeNeeded(int64_t oldVersion, PassRefPtr<IDBDatabaseBackendInterface>, const IDBDatabaseMetadata&) OVERRIDE;
+    virtual void onBlocked(uint64_t existingVersion) OVERRIDE;
+    virtual void onUpgradeNeeded(uint64_t oldVersion, PassRefPtr<IDBDatabaseBackendInterface>, const IDBDatabaseMetadata&) OVERRIDE;
     virtual void onSuccess(PassRefPtr<IDBDatabaseBackendInterface>, const IDBDatabaseMetadata&) OVERRIDE;
 
     // EventTarget
@@ -56,11 +57,12 @@ protected:
     virtual bool shouldEnqueueEvent() const OVERRIDE;
 
 private:
-    IDBOpenDBRequest(ScriptExecutionContext*, PassRefPtr<IDBDatabaseCallbacksImpl>, int64_t transactionId, int64_t version);
+    IDBOpenDBRequest(ScriptExecutionContext*, PassRefPtr<IDBDatabaseCallbacks>, int64_t transactionId, uint64_t version, IndexedDB::VersionNullness);
 
-    RefPtr<IDBDatabaseCallbacksImpl> m_databaseCallbacks;
+    RefPtr<IDBDatabaseCallbacks> m_databaseCallbacks;
     const int64_t m_transactionId;
-    int64_t m_version;
+    uint64_t m_version;
+    IndexedDB::VersionNullness m_versionNullness;
 };
 
 } // namespace WebCore
index 47f55ffdcc26eb46720c775ea7fb4dcdfa80b555..1d9fe61a94d777ba19b8a4888bd3a0a422ab8398 100644 (file)
@@ -120,15 +120,6 @@ unsigned short IDBRequest::errorCode(ExceptionCode& ec) const
     return m_errorCode;
 }
 
-String IDBRequest::webkitErrorMessage(ExceptionCode& ec) const
-{
-    if (m_readyState != DONE) {
-        ec = IDBDatabaseException::InvalidStateError;
-        return String();
-    }
-    return m_errorMessage;
-}
-
 PassRefPtr<IDBAny> IDBRequest::source() const
 {
     return m_source;
index e5cccb4d5102b8c22979bf749a45d10b8769e0a5..25f283515f7e26e867fbe86b32ef7159aaac794e 100644 (file)
@@ -59,7 +59,6 @@ public:
     PassRefPtr<IDBAny> result(ExceptionCode&) const;
     unsigned short errorCode(ExceptionCode&) const;
     PassRefPtr<DOMError> error(ExceptionCode&) const;
-    String webkitErrorMessage(ExceptionCode&) const;
     PassRefPtr<IDBAny> source() const;
     PassRefPtr<IDBTransaction> transaction() const;
     void preventPropagation() { m_preventPropagation = true; }
index 006fc14690545ad8d7e378870bfb51d981776af5..1575b660aeccf8cd030c0147c9899a4fb34db688 100644 (file)
     ActiveDOMObject,
     EventTarget,
     JSNoStaticTables
-] interface IDBRequest {
+] interface IDBRequest : EventTarget {
     [GetterRaisesException] readonly attribute IDBAny result;
     [GetterRaisesException] readonly attribute DOMError error;
-    [TreatReturnedNullStringAs=Undefined, GetterRaisesException] readonly attribute DOMString webkitErrorMessage;
-
     readonly attribute IDBAny source;
     readonly attribute IDBTransaction transaction;
-
-    // States
     readonly attribute DOMString readyState;
 
-    // Events
     attribute EventListener onsuccess;
     attribute EventListener onerror;
-
-    // EventTarget interface
-    void addEventListener(DOMString type,
-                          EventListener listener,
-                          optional boolean useCapture);
-    void removeEventListener(DOMString type,
-                             EventListener listener,
-                             optional boolean useCapture);
-    [RaisesException] boolean dispatchEvent(Event evt);
 };
index 00bda4c10e29b72e6ad6c8fb39333cc002e2b344..2dfb8cc0dc245ec5d2add471668db0c3ce15a15d 100644 (file)
@@ -138,11 +138,6 @@ void IDBTransaction::setError(PassRefPtr<DOMError> error, const String& errorMes
     }
 }
 
-String IDBTransaction::webkitErrorMessage() const
-{
-    return m_errorMessage;
-}
-
 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, ExceptionCode& ec)
 {
     if (m_state == Finished) {
index 89701548acb9d75defd0f01a6fd23594b9f85d85..d1859da32c0702b26dc1387f16da2de88e3fd60d 100644 (file)
@@ -97,7 +97,6 @@ public:
     void objectStoreDeleted(const String&);
     void setActive(bool);
     void setError(PassRefPtr<DOMError>, const String& errorMessage);
-    String webkitErrorMessage() const;
 
     DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(complete);
index 647efe1c0a37c92290e2f86db28032f1a82247b9..8eac9aac1537ad118b6cbac30e94171a5b4cf396 100644 (file)
     ActiveDOMObject,
     EventTarget,
     JSNoStaticTables
-] interface IDBTransaction {
-
-    // Properties
+] interface IDBTransaction : EventTarget {
     readonly attribute DOMString mode;
     readonly attribute IDBDatabase db;
     readonly attribute DOMError error;
-    [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString webkitErrorMessage;
 
-    // Methods
     [RaisesException] IDBObjectStore objectStore (DOMString name);
     [RaisesException] void abort ();
 
-    // Events
     attribute EventListener onabort;
     attribute EventListener oncomplete;
     attribute EventListener onerror;
-    // EventTarget interface
-    void addEventListener(DOMString type,
-                          EventListener listener,
-                          optional boolean useCapture);
-    void removeEventListener(DOMString type,
-                             EventListener listener,
-                             optional boolean useCapture);
-    [RaisesException] boolean dispatchEvent(Event evt);
 };
index 0c861afde8b42dbf12891f1c3191c28ba55f88ec..94f3c01aa4c947ad4ac69abc069e149e11ab1628 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "EventNames.h"
-#include "IDBAny.h"
-
 namespace WebCore {
 
-PassRefPtr<IDBVersionChangeEvent> IDBVersionChangeEvent::create(PassRefPtr<IDBAny> oldVersion, PassRefPtr<IDBAny> newVersion, const AtomicString& eventType)
-{
-    return adoptRef(new IDBVersionChangeEvent(oldVersion, newVersion, eventType));
-}
-
-IDBVersionChangeEvent::IDBVersionChangeEvent(PassRefPtr<IDBAny> oldVersion, PassRefPtr<IDBAny> newVersion, const AtomicString& eventType)
+IDBVersionChangeEvent::IDBVersionChangeEvent(unsigned long long oldVersion, unsigned long long newVersion, IndexedDB::VersionNullness newVersionNullness, const AtomicString& eventType)
     : Event(eventType, false /*canBubble*/, false /*cancelable*/)
     , m_oldVersion(oldVersion)
     , m_newVersion(newVersion)
+    , m_newVersionNullness(newVersionNullness)
 {
 }
 
index d084eb27106dfecb831623cc559721d1c5eb7172..9480ccf668d2bd0e730ba4028b9a7a0e963e7e9c 100644 (file)
@@ -29,7 +29,7 @@
 #if ENABLE(INDEXED_DATABASE)
 
 #include "Event.h"
-#include "IDBAny.h"
+#include "IndexedDB.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/text/WTFString.h>
@@ -38,19 +38,24 @@ namespace WebCore {
 
 class IDBVersionChangeEvent : public Event {
 public:
-    static PassRefPtr<IDBVersionChangeEvent> create(PassRefPtr<IDBAny> oldVersion = IDBAny::createNull(), PassRefPtr<IDBAny> newVersion = IDBAny::createNull(), const AtomicString& eventType = AtomicString());
+    static PassRefPtr<IDBVersionChangeEvent> create(unsigned long long oldVersion = 0, unsigned long long newVersion = 0, IndexedDB::VersionNullness newVersionNullness = IndexedDB::NullVersion, const AtomicString& eventType = AtomicString())
+    {
+        return adoptRef(new IDBVersionChangeEvent(oldVersion, newVersion, newVersionNullness, eventType));
+    }
+
     virtual ~IDBVersionChangeEvent();
 
-    virtual PassRefPtr<IDBAny> oldVersion() { return m_oldVersion; }
-    virtual PassRefPtr<IDBAny> newVersion() { return m_newVersion; }
+    virtual unsigned long long oldVersion() { return m_oldVersion; }
+    virtual unsigned long long newVersion(bool& isNull) { isNull = (m_newVersionNullness == IndexedDB::NullVersion); return m_newVersion; }
 
     virtual EventInterface eventInterface() const;
 
 private:
-    IDBVersionChangeEvent(PassRefPtr<IDBAny> oldVersion, PassRefPtr<IDBAny> newVersion, const AtomicString& eventType);
+    IDBVersionChangeEvent(unsigned long long oldVersion, unsigned long long newVersion, IndexedDB::VersionNullness newVersionNullness, const AtomicString& eventType);
 
-    RefPtr<IDBAny> m_oldVersion;
-    RefPtr<IDBAny> m_newVersion;
+    unsigned long long m_oldVersion;
+    unsigned long long m_newVersion;
+    IndexedDB::VersionNullness m_newVersionNullness;
 };
 
 } // namespace WebCore
index e92192831f49cd947501bf1ae815f2af85f21905..8d11c8aae12d422325bfde7b055803f5fa4091a3 100644 (file)
@@ -27,6 +27,6 @@
     Conditional=INDEXED_DATABASE,
     JSNoStaticTables
 ] interface IDBVersionChangeEvent : Event {
-    readonly attribute IDBAny oldVersion;
-    readonly attribute IDBAny newVersion;
+    readonly attribute unsigned long long oldVersion;
+    readonly attribute unsigned long long? newVersion;
 };
index 2e84fc721a5c323642a683b11492d03844b4fec8..cb7e8fcc8862f409f4d79dbbd3dcccbc531a6c4e 100644 (file)
@@ -50,6 +50,11 @@ enum CursorType {
     CursorKeyOnly
 };
 
+enum VersionNullness {
+    NullVersion,
+    NonNullVersion
+};
+
 } // namespace IndexedDB
 
 } // namespace WebCore
index 52505495bb03c046831ae403a1a48b4882bf4718..e5f4c9a79e4b5ddc98cbabca06e556eebea0d1f4 100644 (file)
@@ -510,7 +510,9 @@ bool IDBBackingStore::getIDBDatabaseMetaData(const String& name, IDBDatabaseMeta
     if (!found)
         return true;
 
-    ok = getString(m_db.get(), DatabaseMetaDataKey::encode(metadata->id, DatabaseMetaDataKey::UserVersion), metadata->version, found);
+    // FIXME: The string version is no longer supported, so the levelDB ports should consider refactoring off of it.
+    String stringVersion;
+    ok = getString(m_db.get(), DatabaseMetaDataKey::encode(metadata->id, DatabaseMetaDataKey::UserVersion), stringVersion, found);
     if (!ok) {
         INTERNAL_READ_ERROR(GetIDBDatabaseMetaData);
         return false;
@@ -520,7 +522,8 @@ bool IDBBackingStore::getIDBDatabaseMetaData(const String& name, IDBDatabaseMeta
         return false;
     }
 
-    ok = getVarInt(m_db.get(), DatabaseMetaDataKey::encode(metadata->id, DatabaseMetaDataKey::UserIntVersion), metadata->intVersion, found);
+    int64_t version;
+    ok = getVarInt(m_db.get(), DatabaseMetaDataKey::encode(metadata->id, DatabaseMetaDataKey::UserIntVersion), version, found);
     if (!ok) {
         INTERNAL_READ_ERROR(GetIDBDatabaseMetaData);
         return false;
@@ -530,8 +533,11 @@ bool IDBBackingStore::getIDBDatabaseMetaData(const String& name, IDBDatabaseMeta
         return false;
     }
 
-    if (metadata->intVersion == IDBDatabaseMetadata::DefaultIntVersion)
-        metadata->intVersion = IDBDatabaseMetadata::NoIntVersion;
+    // FIXME: The versioning semantics have changed since this original code was written, and what was once a negative number
+    // stored in the database is no longer a valid version.
+    if (version < 0)
+        version = 0;
+    metadata->version = version;
 
     ok = getMaxObjectStoreId(m_db.get(), metadata->id, metadata->maxObjectStoreId);
     if (!ok) {
@@ -569,6 +575,7 @@ WARN_UNUSED_RETURN static bool getNewDatabaseId(LevelDBDatabase* db, int64_t& ne
     return true;
 }
 
+// FIXME: The version semantics have changed. String versions no longer exist, and the integer version is now a uint64_t
 bool IDBBackingStore::createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId)
 {
     bool ok = getNewDatabaseId(m_db.get(), rowId);
@@ -1804,7 +1811,7 @@ bool IndexCursorImpl::loadCurrentRow()
     return true;
 }
 
-bool objectStoreCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IndexedDB::CursorDirection direction, IDBBackingStore::Cursor::CursorOptions& cursorOptions)
+static bool objectStoreCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IndexedDB::CursorDirection direction, IDBBackingStore::Cursor::CursorOptions& cursorOptions)
 {
     cursorOptions.databaseId = databaseId;
     cursorOptions.objectStoreId = objectStoreId;
@@ -1854,7 +1861,7 @@ bool objectStoreCursorOptions(LevelDBTransaction* transaction, int64_t databaseI
     return true;
 }
 
-bool indexCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IndexedDB::CursorDirection direction, IDBBackingStore::Cursor::CursorOptions& cursorOptions)
+static bool indexCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IndexedDB::CursorDirection direction, IDBBackingStore::Cursor::CursorOptions& cursorOptions)
 {
     ASSERT(transaction);
     if (!KeyPrefix::validIds(databaseId, objectStoreId, indexId))
index 9d99dad0c42b3f88b9a923cd1f90d04faa21dd08..11994701f0a79f7d98c1909efe2cb5bd37ea8f49 100644 (file)
@@ -473,13 +473,9 @@ PassRefPtr<IDBDatabaseBackendLevelDB> IDBDatabaseBackendLevelDB::create(const St
     return backend.release();
 }
 
-namespace {
-const char* NoStringVersion = "";
-}
-
 IDBDatabaseBackendLevelDB::IDBDatabaseBackendLevelDB(const String& name, IDBBackingStore* backingStore, IDBFactoryBackendLevelDB* factory, const String& uniqueIdentifier)
     : m_backingStore(backingStore)
-    , m_metadata(name, InvalidId, NoStringVersion, IDBDatabaseMetadata::NoIntVersion, InvalidId)
+    , m_metadata(name, InvalidId, 0, InvalidId)
     , m_identifier(uniqueIdentifier)
     , m_factory(factory)
     , m_transactionCoordinator(IDBTransactionCoordinatorLevelDB::create())
@@ -538,7 +534,7 @@ bool IDBDatabaseBackendLevelDB::openInternal()
     if (success)
         return m_backingStore->getObjectStores(m_metadata.id, &m_metadata.objectStores);
 
-    return m_backingStore->createIDBDatabaseMetaData(m_metadata.name, m_metadata.version, m_metadata.intVersion, m_metadata.id);
+    return m_backingStore->createIDBDatabaseMetaData(m_metadata.name, String::number(m_metadata.version), m_metadata.version, m_metadata.id);
 }
 
 IDBDatabaseBackendLevelDB::~IDBDatabaseBackendLevelDB()
@@ -1072,10 +1068,12 @@ void IDBDatabaseBackendLevelDB::VersionChangeOperation::perform(IDBTransactionBa
 {
     IDB_TRACE("VersionChangeOperation");
     int64_t databaseId = m_database->id();
-    int64_t oldVersion = m_database->m_metadata.intVersion;
-    ASSERT(m_version > oldVersion);
-    m_database->m_metadata.intVersion = m_version;
-    if (!m_database->m_backingStore->updateIDBDatabaseIntVersion(transaction->backingStoreTransaction(), databaseId, m_database->m_metadata.intVersion)) {
+    uint64_t oldVersion = m_database->m_metadata.version;
+
+    // FIXME: Database versions are now of type uint64_t, but this code expected int64_t.
+    ASSERT(m_version > (int64_t)oldVersion);
+    m_database->m_metadata.version = m_version;
+    if (!m_database->m_backingStore->updateIDBDatabaseIntVersion(transaction->backingStoreTransaction(), databaseId, m_database->m_metadata.version)) {
         RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Error writing data to stable storage when updating version.");
         m_callbacks->onError(error);
         transaction->abort(error);
@@ -1138,7 +1136,8 @@ size_t IDBDatabaseBackendLevelDB::connectionCount()
 void IDBDatabaseBackendLevelDB::processPendingCalls()
 {
     if (m_pendingSecondHalfOpen) {
-        ASSERT(m_pendingSecondHalfOpen->version() == m_metadata.intVersion);
+        // FIXME: Database versions are now of type uint64_t, but this code expected int64_t.
+        ASSERT(m_pendingSecondHalfOpen->version() == (int64_t)m_metadata.version);
         ASSERT(m_metadata.id != InvalidId);
         m_pendingSecondHalfOpen->callbacks()->onSuccess(this, this->metadata());
         m_pendingSecondHalfOpen.release();
@@ -1194,7 +1193,7 @@ void IDBDatabaseBackendLevelDB::openConnection(PassRefPtr<IDBCallbacks> prpCallb
     if (m_metadata.id == InvalidId) {
         // The database was deleted then immediately re-opened; openInternal() recreates it in the backing store.
         if (openInternal())
-            ASSERT(m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion);
+            ASSERT(m_metadata.version == IDBDatabaseMetadata::NoIntVersion);
         else {
             String message;
             RefPtr<IDBDatabaseError> error;
@@ -1208,7 +1207,7 @@ void IDBDatabaseBackendLevelDB::openConnection(PassRefPtr<IDBCallbacks> prpCallb
     }
 
     // We infer that the database didn't exist from its lack of either type of version.
-    bool isNewDatabase = m_metadata.version == NoStringVersion && m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion;
+    bool isNewDatabase = m_metadata.version == IDBDatabaseMetadata::NoIntVersion;
 
     if (version == IDBDatabaseMetadata::DefaultIntVersion) {
         // FIXME: this comments was related to Chromium code. It may be incorrect
@@ -1229,15 +1228,20 @@ void IDBDatabaseBackendLevelDB::openConnection(PassRefPtr<IDBCallbacks> prpCallb
         version = 1;
     }
 
-    if (version > m_metadata.intVersion) {
+    // FIXME: Database versions are now of type uint64_t, but this code expected int64_t.
+    if (version > (int64_t)m_metadata.version) {
         runIntVersionChangeTransaction(callbacks, databaseCallbacks, transactionId, version);
         return;
     }
-    if (version < m_metadata.intVersion) {
-        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::VersionError, String::format("The requested version (%lld) is less than the existing version (%lld).", static_cast<long long>(version), static_cast<long long>(m_metadata.intVersion))));
+
+    // FIXME: Database versions are now of type uint64_t, but this code expected int64_t.
+    if (version < (int64_t)m_metadata.version) {
+        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::VersionError, String::format("The requested version (%lld) is less than the existing version (%lld).", static_cast<long long>(version), static_cast<long long>(m_metadata.version))));
         return;
     }
-    ASSERT(version == m_metadata.intVersion);
+
+    // FIXME: Database versions are now of type uint64_t, but this code expected int64_t.
+    ASSERT(version == (int64_t)m_metadata.version);
     m_databaseCallbacksSet.add(databaseCallbacks);
     callbacks->onSuccess(this, this->metadata());
 }
@@ -1250,7 +1254,7 @@ void IDBDatabaseBackendLevelDB::runIntVersionChangeTransaction(PassRefPtr<IDBCal
     for (DatabaseCallbacksSet::const_iterator it = m_databaseCallbacksSet.begin(); it != m_databaseCallbacksSet.end(); ++it) {
         // Front end ensures the event is not fired at connections that have closePending set.
         if (*it != databaseCallbacks)
-            (*it)->onVersionChange(m_metadata.intVersion, requestedVersion);
+            (*it)->onVersionChange(m_metadata.version, requestedVersion, IndexedDB::NullVersion);
     }
     // The spec dictates we wait until all the version change events are
     // delivered and then check m_databaseCallbacks.empty() before proceeding
@@ -1260,7 +1264,7 @@ void IDBDatabaseBackendLevelDB::runIntVersionChangeTransaction(PassRefPtr<IDBCal
     // tells us that all the blocked events have been delivered. See
     // https://bugs.webkit.org/show_bug.cgi?id=71130
     if (connectionCount())
-        callbacks->onBlocked(m_metadata.intVersion);
+        callbacks->onBlocked(m_metadata.version);
     // FIXME: Add test for m_runningVersionChangeTransaction.
     if (m_runningVersionChangeTransaction || connectionCount()) {
         m_pendingOpenCalls.append(PendingOpenCall::create(callbacks, databaseCallbacks, transactionId, requestedVersion));
@@ -1271,7 +1275,7 @@ void IDBDatabaseBackendLevelDB::runIntVersionChangeTransaction(PassRefPtr<IDBCal
     createTransaction(transactionId, databaseCallbacks, objectStoreIds, IndexedDB::TransactionVersionChange);
     RefPtr<IDBTransactionBackendLevelDB> transaction = m_transactions.get(transactionId);
 
-    transaction->scheduleTask(VersionChangeOperation::create(this, transactionId, requestedVersion, callbacks, databaseCallbacks), VersionChangeAbortOperation::create(this, m_metadata.version, m_metadata.intVersion));
+    transaction->scheduleTask(VersionChangeOperation::create(this, transactionId, requestedVersion, callbacks, databaseCallbacks), VersionChangeAbortOperation::create(this, String::number(m_metadata.version), m_metadata.version));
 
     ASSERT(!m_pendingSecondHalfOpen);
     m_databaseCallbacksSet.add(databaseCallbacks);
@@ -1283,12 +1287,12 @@ void IDBDatabaseBackendLevelDB::deleteDatabase(PassRefPtr<IDBCallbacks> prpCallb
     if (isDeleteDatabaseBlocked()) {
         for (DatabaseCallbacksSet::const_iterator it = m_databaseCallbacksSet.begin(); it != m_databaseCallbacksSet.end(); ++it) {
             // Front end ensures the event is not fired at connections that have closePending set.
-            (*it)->onVersionChange(m_metadata.intVersion, IDBDatabaseMetadata::NoIntVersion);
+            (*it)->onVersionChange(m_metadata.version, 0, IndexedDB::NullVersion);
         }
         // FIXME: Only fire onBlocked if there are open connections after the
         // VersionChangeEvents are received, not just set up to fire.
         // https://bugs.webkit.org/show_bug.cgi?id=71130
-        callbacks->onBlocked(m_metadata.intVersion);
+        callbacks->onBlocked(m_metadata.version);
         m_pendingDeleteCalls.append(PendingDeleteCall::create(callbacks.release()));
         return;
     }
@@ -1308,9 +1312,8 @@ void IDBDatabaseBackendLevelDB::deleteDatabaseFinal(PassRefPtr<IDBCallbacks> cal
         callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error deleting database."));
         return;
     }
-    m_metadata.version = NoStringVersion;
     m_metadata.id = InvalidId;
-    m_metadata.intVersion = IDBDatabaseMetadata::NoIntVersion;
+    m_metadata.version = IDBDatabaseMetadata::NoIntVersion;
     m_metadata.objectStores.clear();
     callbacks->onSuccess();
 }
@@ -1375,8 +1378,7 @@ void IDBDatabaseBackendLevelDB::VersionChangeAbortOperation::perform(IDBTransact
 {
     IDB_TRACE("VersionChangeAbortOperation");
     ASSERT_UNUSED(transaction, !transaction);
-    m_database->m_metadata.version = m_previousVersion;
-    m_database->m_metadata.intVersion = m_previousIntVersion;
+    m_database->m_metadata.version = m_previousIntVersion;
 }
 
 } // namespace WebCore
index 04e4259d1c5aedea75870ec6e1ff58f53f9921d6..008cb076b57ff2e3d9ff8722b1ffd5c89f768282 100644 (file)
@@ -580,7 +580,7 @@ static IDBKey::Type keyTypeByteToKeyType(unsigned char type)
     return IDBKey::InvalidType;
 }
 
-int compareEncodedIDBKeys(const char*& ptrA, const char* limitA, const char*& ptrB, const char* limitB, bool& ok)
+static int compareEncodedIDBKeys(const char*& ptrA, const char* limitA, const char*& ptrB, const char* limitB, bool& ok)
 {
     ok = true;
     ASSERT(&ptrA != &ptrB);
index c840b7d2fb55d7ba8b224b79f54e1c305d7a5f80..3748fd006ccdf870f0e8a7b3cb11d60266266e28 100644 (file)
@@ -317,8 +317,8 @@ public:
         }
         RefPtr<DatabaseWithObjectStores> result = DatabaseWithObjectStores::create()
             .setName(databaseMetadata.name)
-            .setIntVersion(databaseMetadata.intVersion)
-            .setVersion(databaseMetadata.version)
+            .setIntVersion(databaseMetadata.version)
+            .setVersion(String::number(databaseMetadata.version))
             .setObjectStores(objectStores);
 
         m_requestCallback->sendSuccess(result);