Diff
Modified: trunk/Source/WebCore/ChangeLog (88018 => 88019)
--- trunk/Source/WebCore/ChangeLog 2011-06-03 14:58:19 UTC (rev 88018)
+++ trunk/Source/WebCore/ChangeLog 2011-06-03 15:02:48 UTC (rev 88019)
@@ -1,3 +1,28 @@
+2011-06-03 Hans Wennborg <[email protected]>
+
+ Reviewed by Steve Block.
+
+ IndexedDB: Clean-up use of INT64_MAX in LevelDB back-end
+ https://bugs.webkit.org/show_bug.cgi?id=62009
+
+ This constant should only be needed inside IDBLevelDBCoding.cpp.
+
+ No new functionality, no new tests.
+
+ * storage/IDBLevelDBBackingStore.cpp:
+ (WebCore::getNewDatabaseId):
+ (WebCore::IDBLevelDBBackingStore::getObjectStores):
+ (WebCore::getNewObjectStoreId):
+ (WebCore::IDBLevelDBBackingStore::deleteObjectStore):
+ (WebCore::getNewIndexId):
+ * storage/IDBLevelDBCoding.cpp:
+ (WebCore::IDBLevelDBCoding::DatabaseFreeListKey::encodeMaxKey):
+ (WebCore::IDBLevelDBCoding::ObjectStoreMetaDataKey::encodeMaxKey):
+ (WebCore::IDBLevelDBCoding::IndexMetaDataKey::encodeMaxKey):
+ (WebCore::IDBLevelDBCoding::ObjectStoreFreeListKey::encodeMaxKey):
+ (WebCore::IDBLevelDBCoding::IndexFreeListKey::encodeMaxKey):
+ * storage/IDBLevelDBCoding.h:
+
2011-06-03 Siddharth Mathur <[email protected]>
Reviewed by Benjamin Poulain.
Modified: trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp (88018 => 88019)
--- trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp 2011-06-03 14:58:19 UTC (rev 88018)
+++ trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp 2011-06-03 15:02:48 UTC (rev 88019)
@@ -41,11 +41,6 @@
#include "LevelDBTransaction.h"
#include "SecurityOrigin.h"
-#ifndef INT64_MAX
-// FIXME: We shouldn't need to rely on these macros.
-#define INT64_MAX 0x7fffffffffffffffLL
-#endif
-
namespace WebCore {
using namespace IDBLevelDBCoding;
@@ -183,7 +178,7 @@
static int64_t getNewDatabaseId(LevelDBDatabase* db)
{
const Vector<char> freeListStartKey = DatabaseFreeListKey::encode(0);
- const Vector<char> freeListStopKey = DatabaseFreeListKey::encode(INT64_MAX);
+ const Vector<char> freeListStopKey = DatabaseFreeListKey::encodeMaxKey();
OwnPtr<LevelDBIterator> it = db->createIterator();
for (it->seek(freeListStartKey); it->isValid() && compareKeys(it->key(), freeListStopKey) < 0; it->next()) {
@@ -234,7 +229,7 @@
void IDBLevelDBBackingStore::getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags)
{
const Vector<char> startKey = ObjectStoreMetaDataKey::encode(databaseId, 1, 0);
- const Vector<char> stopKey = ObjectStoreMetaDataKey::encode(databaseId, INT64_MAX, 0);
+ const Vector<char> stopKey = ObjectStoreMetaDataKey::encodeMaxKey(databaseId);
OwnPtr<LevelDBIterator> it = m_db->createIterator();
for (it->seek(startKey); it->isValid() && compareKeys(it->key(), stopKey) < 0; it->next()) {
@@ -291,7 +286,7 @@
static int64_t getNewObjectStoreId(LevelDBTransaction* transaction, int64_t databaseId)
{
const Vector<char> freeListStartKey = ObjectStoreFreeListKey::encode(databaseId, 0);
- const Vector<char> freeListStopKey = ObjectStoreFreeListKey::encode(databaseId, INT64_MAX);
+ const Vector<char> freeListStopKey = ObjectStoreFreeListKey::encodeMaxKey(databaseId);
OwnPtr<LevelDBIterator> it = transaction->createIterator();
for (it->seek(freeListStartKey); it->isValid() && compareKeys(it->key(), freeListStopKey) < 0; it->next()) {
@@ -406,9 +401,9 @@
putString(m_currentTransaction.get(), ObjectStoreFreeListKey::encode(databaseId, objectStoreId), "");
m_currentTransaction->remove(ObjectStoreNamesKey::encode(databaseId, objectStoreName));
- if (!deleteRange(m_currentTransaction.get(), IndexFreeListKey::encode(databaseId, objectStoreId, 0), IndexFreeListKey::encode(databaseId, objectStoreId, INT64_MAX)))
+ if (!deleteRange(m_currentTransaction.get(), IndexFreeListKey::encode(databaseId, objectStoreId, 0), IndexFreeListKey::encodeMaxKey(databaseId, objectStoreId)))
return; // FIXME: Report error.
- if (!deleteRange(m_currentTransaction.get(), IndexMetaDataKey::encode(databaseId, objectStoreId, 0, 0), IndexMetaDataKey::encode(databaseId, objectStoreId, INT64_MAX, 0)))
+ if (!deleteRange(m_currentTransaction.get(), IndexMetaDataKey::encode(databaseId, objectStoreId, 0, 0), IndexMetaDataKey::encodeMaxKey(databaseId, objectStoreId)))
return; // FIXME: Report error.
clearObjectStore(databaseId, objectStoreId);
@@ -639,7 +634,7 @@
static int64_t getNewIndexId(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId)
{
const Vector<char> startKey = IndexFreeListKey::encode(databaseId, objectStoreId, 0);
- const Vector<char> stopKey = IndexFreeListKey::encode(databaseId, objectStoreId, INT64_MAX);
+ const Vector<char> stopKey = IndexFreeListKey::encodeMaxKey(databaseId, objectStoreId);
OwnPtr<LevelDBIterator> it = transaction->createIterator();
for (it->seek(startKey); it->isValid() && compareKeys(it->key(), stopKey) < 0; it->next()) {
Modified: trunk/Source/WebCore/storage/IDBLevelDBCoding.cpp (88018 => 88019)
--- trunk/Source/WebCore/storage/IDBLevelDBCoding.cpp 2011-06-03 14:58:19 UTC (rev 88018)
+++ trunk/Source/WebCore/storage/IDBLevelDBCoding.cpp 2011-06-03 15:02:48 UTC (rev 88019)
@@ -145,7 +145,6 @@
static const unsigned char kIndexNamesKeyTypeByte = 201;
#ifndef INT64_MAX
-// FIXME: We shouldn't need to rely on these macros.
#define INT64_MAX 0x7fffffffffffffffLL
#endif
#ifndef INT32_MAX
@@ -750,6 +749,11 @@
return ret;
}
+Vector<char> DatabaseFreeListKey::encodeMaxKey()
+{
+ return encode(INT64_MAX);
+}
+
int64_t DatabaseFreeListKey::databaseId() const
{
ASSERT(m_databaseId >= 0);
@@ -848,6 +852,11 @@
return ret;
}
+Vector<char> ObjectStoreMetaDataKey::encodeMaxKey(int64_t databaseId)
+{
+ return encode(databaseId, INT64_MAX, INT64_MAX);
+}
+
int64_t ObjectStoreMetaDataKey::objectStoreId() const
{
ASSERT(m_objectStoreId >= 0);
@@ -913,6 +922,11 @@
return ret;
}
+Vector<char> IndexMetaDataKey::encodeMaxKey(int64_t databaseId, int64_t objectStoreId)
+{
+ return encode(databaseId, objectStoreId, INT64_MAX, 255);
+}
+
int IndexMetaDataKey::compare(const IndexMetaDataKey& other)
{
ASSERT(m_objectStoreId >= 0);
@@ -963,6 +977,11 @@
return ret;
}
+Vector<char> ObjectStoreFreeListKey::encodeMaxKey(int64_t databaseId)
+{
+ return encode(databaseId, INT64_MAX);
+}
+
int64_t ObjectStoreFreeListKey::objectStoreId() const
{
ASSERT(m_objectStoreId >= 0);
@@ -1015,6 +1034,11 @@
return ret;
}
+Vector<char> IndexFreeListKey::encodeMaxKey(int64_t databaseId, int64_t objectStoreId)
+{
+ return encode(databaseId, objectStoreId, INT64_MAX);
+}
+
int IndexFreeListKey::compare(const IndexFreeListKey& other)
{
ASSERT(m_objectStoreId >= 0);
Modified: trunk/Source/WebCore/storage/IDBLevelDBCoding.h (88018 => 88019)
--- trunk/Source/WebCore/storage/IDBLevelDBCoding.h 2011-06-03 14:58:19 UTC (rev 88018)
+++ trunk/Source/WebCore/storage/IDBLevelDBCoding.h 2011-06-03 15:02:48 UTC (rev 88019)
@@ -104,6 +104,7 @@
DatabaseFreeListKey();
static const char* decode(const char* start, const char* limit, DatabaseFreeListKey* result);
static Vector<char> encode(int64_t databaseId);
+ static Vector<char> encodeMaxKey();
int64_t databaseId() const;
int compare(const DatabaseFreeListKey& other) const;
@@ -141,6 +142,7 @@
ObjectStoreMetaDataKey();
static const char* decode(const char* start, const char* limit, ObjectStoreMetaDataKey* result);
static Vector<char> encode(int64_t databaseId, int64_t objectStoreId, int64_t metaDataType);
+ static Vector<char> encodeMaxKey(int64_t databaseId);
int64_t objectStoreId() const;
int64_t metaDataType() const;
int compare(const ObjectStoreMetaDataKey& other);
@@ -155,6 +157,7 @@
IndexMetaDataKey();
static const char* decode(const char* start, const char* limit, IndexMetaDataKey* result);
static Vector<char> encode(int64_t databaseId, int64_t objectStoreId, int64_t indexId, unsigned char metaDataType);
+ static Vector<char> encodeMaxKey(int64_t databaseId, int64_t objectStoreId);
int compare(const IndexMetaDataKey& other);
int64_t indexId() const;
unsigned char metaDataType() const { return m_metaDataType; }
@@ -170,6 +173,7 @@
ObjectStoreFreeListKey();
static const char* decode(const char* start, const char* limit, ObjectStoreFreeListKey* result);
static Vector<char> encode(int64_t databaseId, int64_t objectStoreId);
+ static Vector<char> encodeMaxKey(int64_t databaseId);
int64_t objectStoreId() const;
int compare(const ObjectStoreFreeListKey& other);
@@ -182,6 +186,7 @@
IndexFreeListKey();
static const char* decode(const char* start, const char* limit, IndexFreeListKey* result);
static Vector<char> encode(int64_t databaseId, int64_t objectStoreId, int64_t indexId);
+ static Vector<char> encodeMaxKey(int64_t databaseId, int64_t objectStoreId);
int compare(const IndexFreeListKey& other);
int64_t objectStoreId() const;
int64_t indexId() const;
Modified: trunk/Source/WebKit/chromium/ChangeLog (88018 => 88019)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-06-03 14:58:19 UTC (rev 88018)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-06-03 15:02:48 UTC (rev 88019)
@@ -1,3 +1,15 @@
+2011-06-03 Hans Wennborg <[email protected]>
+
+ Reviewed by Steve Block.
+
+ IndexedDB: Clean-up use of INT64_MAX in LevelDB back-end
+ https://bugs.webkit.org/show_bug.cgi?id=62009
+
+ Don't use INT64_MAX, use the various encodeMaxKey() functions instead.
+
+ * tests/IDBLevelDBCodingTest.cpp:
+ (IDBLevelDBCoding::TEST):
+
2011-06-03 Mikhail Naganov <[email protected]>
Reviewed by Yury Semikhatsky.
Modified: trunk/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp (88018 => 88019)
--- trunk/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp 2011-06-03 14:58:19 UTC (rev 88018)
+++ trunk/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp 2011-06-03 15:02:48 UTC (rev 88019)
@@ -34,11 +34,6 @@
#include <gtest/gtest.h>
#include <wtf/Vector.h>
-#ifndef INT64_MAX
-// FIXME: We shouldn't need to rely on these macros.
-#define INT64_MAX 0x7fffffffffffffffLL
-#endif
-
using namespace WebCore;
using namespace IDBLevelDBCoding;
@@ -345,42 +340,38 @@
keys.append(SchemaVersionKey::encode());
keys.append(MaxDatabaseIdKey::encode());
keys.append(DatabaseFreeListKey::encode(0));
- keys.append(DatabaseFreeListKey::encode(INT64_MAX));
+ keys.append(DatabaseFreeListKey::encodeMaxKey());
keys.append(DatabaseNameKey::encode("", ""));
keys.append(DatabaseNameKey::encode("", "a"));
keys.append(DatabaseNameKey::encode("a", "a"));
keys.append(DatabaseMetaDataKey::encode(1, DatabaseMetaDataKey::kOriginName));
keys.append(ObjectStoreMetaDataKey::encode(1, 1, 0));
- keys.append(ObjectStoreMetaDataKey::encode(1, INT64_MAX, 0));
+ keys.append(ObjectStoreMetaDataKey::encodeMaxKey(1));
keys.append(IndexMetaDataKey::encode(1, 1, 30, 0));
- keys.append(IndexMetaDataKey::encode(1, 1, INT64_MAX, 0));
+ keys.append(IndexMetaDataKey::encode(1, 1, 31, 0));
+ keys.append(IndexMetaDataKey::encode(1, 1, 31, 1));
keys.append(ObjectStoreFreeListKey::encode(1, 1));
- keys.append(ObjectStoreFreeListKey::encode(1, INT64_MAX));
- keys.append(IndexFreeListKey::encode(1, 1, 30));
- keys.append(IndexFreeListKey::encode(1, 1, INT64_MAX));
- keys.append(IndexFreeListKey::encode(1, INT64_MAX, 30));
- keys.append(IndexFreeListKey::encode(1, INT64_MAX, INT64_MAX));
+ keys.append(ObjectStoreFreeListKey::encodeMaxKey(1));
+ keys.append(IndexFreeListKey::encode(1, 1, kMinimumIndexId));
+ keys.append(IndexFreeListKey::encodeMaxKey(1, 1));
+ keys.append(IndexFreeListKey::encode(1, 2, kMinimumIndexId));
+ keys.append(IndexFreeListKey::encodeMaxKey(1, 2));
keys.append(ObjectStoreNamesKey::encode(1, ""));
keys.append(ObjectStoreNamesKey::encode(1, "a"));
keys.append(IndexNamesKey::encode(1, 1, ""));
keys.append(IndexNamesKey::encode(1, 1, "a"));
- keys.append(IndexNamesKey::encode(1, INT64_MAX, "a"));
+ keys.append(IndexNamesKey::encode(1, 2, "a"));
keys.append(ObjectStoreDataKey::encode(1, 1, minIDBKey()));
keys.append(ObjectStoreDataKey::encode(1, 1, maxIDBKey()));
keys.append(ExistsEntryKey::encode(1, 1, minIDBKey()));
keys.append(ExistsEntryKey::encode(1, 1, maxIDBKey()));
keys.append(IndexDataKey::encode(1, 1, 30, minIDBKey(), 0));
- keys.append(IndexDataKey::encode(1, 1, 30, minIDBKey(), INT64_MAX));
+ keys.append(IndexDataKey::encode(1, 1, 30, minIDBKey(), 1));
keys.append(IndexDataKey::encode(1, 1, 30, maxIDBKey(), 0));
- keys.append(IndexDataKey::encode(1, 1, 30, maxIDBKey(), INT64_MAX));
+ keys.append(IndexDataKey::encode(1, 1, 30, maxIDBKey(), 1));
keys.append(IndexDataKey::encode(1, 1, 31, minIDBKey(), 0));
keys.append(IndexDataKey::encode(1, 2, 30, minIDBKey(), 0));
keys.append(IndexDataKey::encodeMaxKey(1, 2));
- keys.append(ObjectStoreDataKey::encode(1, INT64_MAX, minIDBKey()));
- keys.append(ExistsEntryKey::encode(1, INT64_MAX, maxIDBKey()));
- keys.append(IndexDataKey::encodeMaxKey(1, INT64_MAX));
- keys.append(DatabaseMetaDataKey::encode(INT64_MAX, DatabaseMetaDataKey::kOriginName));
- keys.append(IndexDataKey::encodeMaxKey(INT64_MAX, INT64_MAX));
for (size_t i = 0; i < keys.size(); ++i) {
const LevelDBSlice keyA(keys[i]);