IDB Database versions are uint64_t, not int64_t
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2013 06:27:02 +0000 (06:27 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2013 06:27:02 +0000 (06:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123556

Reviewed by Alexey Proskuryakov.

Source/WebCore:

* Modules/indexeddb/IDBBackingStoreInterface.h:

* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(WebCore::IDBDatabaseBackendImpl::processPendingCalls):
(WebCore::IDBDatabaseBackendImpl::openConnection):
* Modules/indexeddb/IDBDatabaseBackendImpl.h:

* Modules/indexeddb/IDBFactoryBackendInterface.h:

* Modules/indexeddb/IDBPendingOpenCall.h:
(WebCore::IDBPendingOpenCall::create):
(WebCore::IDBPendingOpenCall::version):
(WebCore::IDBPendingOpenCall::IDBPendingOpenCall):

* Modules/indexeddb/IDBTransactionBackendOperations.cpp:
(WebCore::IDBDatabaseBackendImpl::VersionChangeOperation::perform):

* Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
(WebCore::IDBBackingStoreLevelDB::updateIDBDatabaseVersion):
* Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h:

* Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp:
(WebCore::IDBFactoryBackendLevelDB::open):
* Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h:

Source/WebKit2:

* WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp:
(WebKit::WebIDBFactoryBackend::open):
* WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h:

* WebProcess/Databases/IndexedDB/WebProcessIDBDatabaseBackend.cpp:
(WebKit::WebProcessIDBDatabaseBackend::openConnection):
* WebProcess/Databases/IndexedDB/WebProcessIDBDatabaseBackend.h:

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

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBBackingStoreInterface.h
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h
Source/WebCore/Modules/indexeddb/IDBPendingOpenCall.h
Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp
Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp
Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h
Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp
Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h
Source/WebKit2/WebProcess/Databases/IndexedDB/WebProcessIDBDatabaseBackend.cpp
Source/WebKit2/WebProcess/Databases/IndexedDB/WebProcessIDBDatabaseBackend.h

index f6241d6..f055476 100644 (file)
@@ -1,3 +1,35 @@
+2013-10-30  Brady Eidson  <beidson@apple.com>
+
+        IDB Database versions are uint64_t, not int64_t
+        https://bugs.webkit.org/show_bug.cgi?id=123556
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Modules/indexeddb/IDBBackingStoreInterface.h:
+
+        * Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
+        (WebCore::IDBDatabaseBackendImpl::processPendingCalls):
+        (WebCore::IDBDatabaseBackendImpl::openConnection):
+        * Modules/indexeddb/IDBDatabaseBackendImpl.h:
+
+        * Modules/indexeddb/IDBFactoryBackendInterface.h:
+
+        * Modules/indexeddb/IDBPendingOpenCall.h:
+        (WebCore::IDBPendingOpenCall::create):
+        (WebCore::IDBPendingOpenCall::version):
+        (WebCore::IDBPendingOpenCall::IDBPendingOpenCall):
+
+        * Modules/indexeddb/IDBTransactionBackendOperations.cpp:
+        (WebCore::IDBDatabaseBackendImpl::VersionChangeOperation::perform):
+
+        * Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
+        (WebCore::IDBBackingStoreLevelDB::updateIDBDatabaseVersion):
+        * Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h:
+
+        * Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp:
+        (WebCore::IDBFactoryBackendLevelDB::open):
+        * Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h:
+
 2013-10-30  Brendan Long  <b.long@cablelabs.com>
 
         [Gtk] Build is failing after r158317
index 0f8a82d..dad6690 100644 (file)
@@ -90,7 +90,7 @@ public:
     virtual bool keyExistsInIndex(IDBBackingStoreInterface::Transaction&, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, RefPtr<IDBKey>& foundPrimaryKey, bool& exists) = 0;
 
     virtual bool deleteDatabase(const String& name) = 0;
-    virtual bool updateIDBDatabaseIntVersion(IDBBackingStoreInterface::Transaction&, int64_t rowId, int64_t intVersion) = 0;
+    virtual bool updateIDBDatabaseVersion(IDBBackingStoreInterface::Transaction&, int64_t rowId, uint64_t version) = 0;
 
     virtual bool getRecord(IDBBackingStoreInterface::Transaction&, int64_t databaseId, int64_t objectStoreId, const IDBKey&, Vector<char>& record) = 0;
     virtual bool putRecord(IDBBackingStoreInterface::Transaction&, int64_t databaseId, int64_t objectStoreId, const IDBKey&, PassRefPtr<SharedBuffer> value, IDBRecordIdentifier*) = 0;
index 0a1a617..3a9c0b4 100644 (file)
@@ -391,8 +391,7 @@ size_t IDBDatabaseBackendImpl::connectionCount()
 void IDBDatabaseBackendImpl::processPendingCalls()
 {
     if (m_pendingSecondHalfOpen) {
-        // 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_pendingSecondHalfOpen->version() == m_metadata.version);
         ASSERT(m_metadata.id != InvalidId);
         m_pendingSecondHalfOpen->callbacks()->onSuccess(this, this->metadata());
         m_pendingSecondHalfOpen.release();
@@ -439,7 +438,7 @@ void IDBDatabaseBackendImpl::createTransaction(int64_t transactionId, PassRefPtr
     m_transactions.add(transactionId, transaction.get());
 }
 
-void IDBDatabaseBackendImpl::openConnection(PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, int64_t transactionId, int64_t version)
+void IDBDatabaseBackendImpl::openConnection(PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, int64_t transactionId, uint64_t version)
 {
     ASSERT(m_backingStore.get());
     RefPtr<IDBCallbacks> callbacks = prpCallbacks;
@@ -460,7 +459,7 @@ void IDBDatabaseBackendImpl::openConnection(PassRefPtr<IDBCallbacks> prpCallback
             if (version == IDBDatabaseMetadata::NoIntVersion)
                 message = "Internal error opening database with no version specified.";
             else
-                message = String::format("Internal error opening database with version %lld", static_cast<long long>(version));
+                message = String::format("Internal error opening database with version %llu", static_cast<unsigned long long>(version));
             callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, message));
             return;
         }
@@ -488,20 +487,17 @@ void IDBDatabaseBackendImpl::openConnection(PassRefPtr<IDBCallbacks> prpCallback
         version = 1;
     }
 
-    // FIXME: Database versions are now of type uint64_t, but this code expected int64_t.
-    if (version > (int64_t)m_metadata.version) {
+    if (version > m_metadata.version) {
         runIntVersionChangeTransaction(callbacks, databaseCallbacks, transactionId, version);
         return;
     }
 
-    // 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))));
+    if (version < m_metadata.version) {
+        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::VersionError, String::format("The requested version (%llu) is less than the existing version (%llu).", static_cast<unsigned long long>(version), static_cast<unsigned long long>(m_metadata.version))));
         return;
     }
 
-    // FIXME: Database versions are now of type uint64_t, but this code expected int64_t.
-    ASSERT(version == (int64_t)m_metadata.version);
+    ASSERT(version == m_metadata.version);
     m_databaseCallbacksSet.add(databaseCallbacks);
     callbacks->onSuccess(this, this->metadata());
 }
index f407585..40006c9 100644 (file)
@@ -57,7 +57,7 @@ public:
     virtual void addIndex(int64_t objectStoreId, const IDBIndexMetadata&, int64_t newMaxIndexId) OVERRIDE;
     virtual void removeIndex(int64_t objectStoreId, int64_t indexId) OVERRIDE;
 
-    void openConnection(PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, int64_t transactionId, int64_t version);
+    void openConnection(PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, int64_t transactionId, uint64_t version);
     void deleteDatabase(PassRefPtr<IDBCallbacks>);
 
     // IDBDatabaseBackendInterface
index 639a6a7..36c9953 100644 (file)
@@ -59,7 +59,7 @@ public:
     virtual ~IDBFactoryBackendInterface() { }
 
     virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) = 0;
-    virtual void open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin) = 0;
+    virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin) = 0;
     virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) = 0;
 
     virtual void removeIDBDatabaseBackend(const String& uniqueIdentifier) = 0;
index 1675c73..193ceea 100644 (file)
@@ -38,17 +38,17 @@ class IDBDatabaseCallbacks;
 
 class IDBPendingOpenCall {
 public:
-    static PassOwnPtr<IDBPendingOpenCall> create(IDBCallbacks& callbacks, IDBDatabaseCallbacks& databaseCallbacks, int64_t transactionId, int64_t version)
+    static PassOwnPtr<IDBPendingOpenCall> create(IDBCallbacks& callbacks, IDBDatabaseCallbacks& databaseCallbacks, int64_t transactionId, uint64_t version)
     {
         return adoptPtr(new IDBPendingOpenCall(callbacks, databaseCallbacks, transactionId, version));
     }
     IDBCallbacks* callbacks() { return m_callbacks.get(); }
     IDBDatabaseCallbacks* databaseCallbacks() { return m_databaseCallbacks.get(); }
-    int64_t version() { return m_version; }
+    uint64_t version() { return m_version; }
     int64_t transactionId() const { return m_transactionId; }
 
 private:
-    IDBPendingOpenCall(IDBCallbacks& callbacks, IDBDatabaseCallbacks& databaseCallbacks, int64_t transactionId, int64_t version)
+    IDBPendingOpenCall(IDBCallbacks& callbacks, IDBDatabaseCallbacks& databaseCallbacks, int64_t transactionId, uint64_t version)
         : m_callbacks(&callbacks)
         , m_databaseCallbacks(&databaseCallbacks)
         , m_version(version)
@@ -57,7 +57,7 @@ private:
     }
     RefPtr<IDBCallbacks> m_callbacks;
     RefPtr<IDBDatabaseCallbacks> m_databaseCallbacks;
-    int64_t m_version;
+    uint64_t m_version;
     const int64_t m_transactionId;
 };
 
index c816939..73bbe7b 100644 (file)
@@ -352,7 +352,7 @@ void IDBDatabaseBackendImpl::VersionChangeOperation::perform()
     // FIXME: Database versions are now of type uint64_t, but this code expected int64_t.
     ASSERT(m_version > (int64_t)oldVersion);
     database.setCurrentVersion(m_version);
-    if (!database.backingStore()->updateIDBDatabaseIntVersion(m_transaction->backingStoreTransaction(), databaseId, database.metadata().version)) {
+    if (!database.backingStore()->updateIDBDatabaseVersion(m_transaction->backingStoreTransaction(), databaseId, database.metadata().version)) {
         RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Error writing data to stable storage when updating version.");
         m_callbacks->onError(error);
         m_transaction->abort(error);
index 1dbe3bf..e5a3256 100644 (file)
@@ -592,12 +592,12 @@ bool IDBBackingStoreLevelDB::createIDBDatabaseMetaData(const String& name, const
     return true;
 }
 
-bool IDBBackingStoreLevelDB::updateIDBDatabaseIntVersion(IDBBackingStoreInterface::Transaction& transaction, int64_t rowId, int64_t intVersion)
+bool IDBBackingStoreLevelDB::updateIDBDatabaseVersion(IDBBackingStoreInterface::Transaction& transaction, int64_t rowId, uint64_t version)
 {
-    if (intVersion == IDBDatabaseMetadata::NoIntVersion)
-        intVersion = IDBDatabaseMetadata::DefaultIntVersion;
-    ASSERT_WITH_MESSAGE(intVersion >= 0, "intVersion was %lld", static_cast<long long>(intVersion));
-    putVarInt(Transaction::levelDBTransactionFrom(transaction), DatabaseMetaDataKey::encode(rowId, DatabaseMetaDataKey::UserIntVersion), intVersion);
+    if (version == IDBDatabaseMetadata::NoIntVersion)
+        version = IDBDatabaseMetadata::DefaultIntVersion;
+    ASSERT_WITH_MESSAGE(version >= 0, "version was %llu", static_cast<unsigned long long>(version));
+    putVarInt(Transaction::levelDBTransactionFrom(transaction), DatabaseMetaDataKey::encode(rowId, DatabaseMetaDataKey::UserIntVersion), version);
     return true;
 }
 
index e0ce529..e922186 100644 (file)
@@ -73,7 +73,7 @@ public:
     virtual bool getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata*, bool& success) OVERRIDE WARN_UNUSED_RETURN;
     virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId) OVERRIDE;
     virtual bool updateIDBDatabaseMetaData(IDBBackingStoreInterface::Transaction&, int64_t rowId, const String& version);
-    virtual bool updateIDBDatabaseIntVersion(IDBBackingStoreInterface::Transaction&, int64_t rowId, int64_t intVersion) OVERRIDE;
+    virtual bool updateIDBDatabaseVersion(IDBBackingStoreInterface::Transaction&, int64_t rowId, uint64_t version) OVERRIDE;
     virtual bool deleteDatabase(const String& name) OVERRIDE;
 
     virtual bool getObjectStores(int64_t databaseId, IDBDatabaseMetadata::ObjectStoreMap*) OVERRIDE WARN_UNUSED_RETURN;
index 9432bc1..86374a0 100644 (file)
@@ -162,7 +162,7 @@ PassRefPtr<IDBBackingStoreLevelDB> IDBFactoryBackendLevelDB::openBackingStore(co
     return 0;
 }
 
-void IDBFactoryBackendLevelDB::open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks, const SecurityOrigin& openingOrigin, const SecurityOrigin&)
+void IDBFactoryBackendLevelDB::open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks, const SecurityOrigin& openingOrigin, const SecurityOrigin&)
 {
     LOG(StorageAPI, "IDBFactoryBackendLevelDB::open");
     const String uniqueIdentifier = computeUniqueIdentifier(name, openingOrigin);
index b7194ba..3d74048 100644 (file)
@@ -59,7 +59,7 @@ public:
     virtual void removeIDBDatabaseBackend(const String& uniqueIdentifier) OVERRIDE FINAL;
 
     virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) OVERRIDE FINAL;
-    virtual void open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin) OVERRIDE FINAL;
+    virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin) OVERRIDE FINAL;
 
     virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) OVERRIDE FINAL;
 
index cf15ad5..90461a8 100644 (file)
@@ -1,3 +1,18 @@
+2013-10-30  Brady Eidson  <beidson@apple.com>
+
+        IDB Database versions are uint64_t, not int64_t
+        https://bugs.webkit.org/show_bug.cgi?id=123556
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp:
+        (WebKit::WebIDBFactoryBackend::open):
+        * WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h:
+
+        * WebProcess/Databases/IndexedDB/WebProcessIDBDatabaseBackend.cpp:
+        (WebKit::WebProcessIDBDatabaseBackend::openConnection):
+        * WebProcess/Databases/IndexedDB/WebProcessIDBDatabaseBackend.h:
+
 2013-10-30  Dan Bernstein  <mitz@apple.com>
 
         Fixed a potential race condition around the initializtion of WKObject’s target.
index dc35885..9ff352d 100644 (file)
@@ -70,7 +70,7 @@ void WebIDBFactoryBackend::getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr
     notImplemented();
 }
 
-void WebIDBFactoryBackend::open(const String& databaseName, int64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks, const SecurityOrigin& securityOrigin, const SecurityOrigin&)
+void WebIDBFactoryBackend::open(const String& databaseName, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks, const SecurityOrigin& securityOrigin, const SecurityOrigin&)
 {
     ASSERT(isMainThread());
     LOG(StorageAPI, "WebIDBFactoryBackend::open");
index b405821..e4e2fce 100644 (file)
@@ -40,7 +40,7 @@ public:
     virtual ~WebIDBFactoryBackend();
 
     virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::ScriptExecutionContext*, const String& dataDir) OVERRIDE;
-    virtual void open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin) OVERRIDE;
+    virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin) OVERRIDE;
     virtual void deleteDatabase(const String& name, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::ScriptExecutionContext*, const String& dataDir) OVERRIDE;
 
     virtual void removeIDBDatabaseBackend(const String& uniqueIdentifier) OVERRIDE;
index 7ce510b..f3794b8 100644 (file)
@@ -59,7 +59,7 @@ WebProcessIDBDatabaseBackend::~WebProcessIDBDatabaseBackend()
 {
 }
 
-void WebProcessIDBDatabaseBackend::openConnection(PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, int64_t transactionId, int64_t version)
+void WebProcessIDBDatabaseBackend::openConnection(PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, int64_t transactionId, uint64_t version)
 {
     // FIXME: Make this message include necessary arguments, and save off these callbacks and arguments for later use.
 
index a7ec9d5..3e57716 100644 (file)
@@ -86,7 +86,7 @@ public:
 
     virtual WebCore::IDBFactoryBackendInterface& factoryBackend() OVERRIDE;
 
-    void openConnection(PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, int64_t transactionId, int64_t version);
+    void openConnection(PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, int64_t transactionId, uint64_t version);
 
     void establishDatabaseProcessBackend();