Changeset 88019 in webkit


Ignore:
Timestamp:
Jun 3, 2011 8:02:48 AM (13 years ago)
Author:
hans@chromium.org
Message:

2011-06-03 Hans Wennborg <hans@chromium.org>

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 Hans Wennborg <hans@chromium.org>

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):
Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r88016 r88019  
     12011-06-03  Hans Wennborg  <hans@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        IndexedDB: Clean-up use of INT64_MAX in LevelDB back-end
     6        https://bugs.webkit.org/show_bug.cgi?id=62009
     7
     8        This constant should only be needed inside IDBLevelDBCoding.cpp.
     9
     10        No new functionality, no new tests.
     11
     12        * storage/IDBLevelDBBackingStore.cpp:
     13        (WebCore::getNewDatabaseId):
     14        (WebCore::IDBLevelDBBackingStore::getObjectStores):
     15        (WebCore::getNewObjectStoreId):
     16        (WebCore::IDBLevelDBBackingStore::deleteObjectStore):
     17        (WebCore::getNewIndexId):
     18        * storage/IDBLevelDBCoding.cpp:
     19        (WebCore::IDBLevelDBCoding::DatabaseFreeListKey::encodeMaxKey):
     20        (WebCore::IDBLevelDBCoding::ObjectStoreMetaDataKey::encodeMaxKey):
     21        (WebCore::IDBLevelDBCoding::IndexMetaDataKey::encodeMaxKey):
     22        (WebCore::IDBLevelDBCoding::ObjectStoreFreeListKey::encodeMaxKey):
     23        (WebCore::IDBLevelDBCoding::IndexFreeListKey::encodeMaxKey):
     24        * storage/IDBLevelDBCoding.h:
     25
    1262011-06-03  Siddharth Mathur  <siddharth.mathur@nokia.com>
    227
  • trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp

    r87491 r88019  
    4242#include "SecurityOrigin.h"
    4343
    44 #ifndef INT64_MAX
    45 // FIXME: We shouldn't need to rely on these macros.
    46 #define INT64_MAX 0x7fffffffffffffffLL
    47 #endif
    48 
    4944namespace WebCore {
    5045
     
    184179{
    185180    const Vector<char> freeListStartKey = DatabaseFreeListKey::encode(0);
    186     const Vector<char> freeListStopKey = DatabaseFreeListKey::encode(INT64_MAX);
     181    const Vector<char> freeListStopKey = DatabaseFreeListKey::encodeMaxKey();
    187182
    188183    OwnPtr<LevelDBIterator> it = db->createIterator();
     
    235230{
    236231    const Vector<char> startKey = ObjectStoreMetaDataKey::encode(databaseId, 1, 0);
    237     const Vector<char> stopKey = ObjectStoreMetaDataKey::encode(databaseId, INT64_MAX, 0);
     232    const Vector<char> stopKey = ObjectStoreMetaDataKey::encodeMaxKey(databaseId);
    238233
    239234    OwnPtr<LevelDBIterator> it = m_db->createIterator();
     
    292287{
    293288    const Vector<char> freeListStartKey = ObjectStoreFreeListKey::encode(databaseId, 0);
    294     const Vector<char> freeListStopKey = ObjectStoreFreeListKey::encode(databaseId, INT64_MAX);
     289    const Vector<char> freeListStopKey = ObjectStoreFreeListKey::encodeMaxKey(databaseId);
    295290
    296291    OwnPtr<LevelDBIterator> it = transaction->createIterator();
     
    407402    m_currentTransaction->remove(ObjectStoreNamesKey::encode(databaseId, objectStoreName));
    408403
    409     if (!deleteRange(m_currentTransaction.get(), IndexFreeListKey::encode(databaseId, objectStoreId, 0), IndexFreeListKey::encode(databaseId, objectStoreId, INT64_MAX)))
     404    if (!deleteRange(m_currentTransaction.get(), IndexFreeListKey::encode(databaseId, objectStoreId, 0), IndexFreeListKey::encodeMaxKey(databaseId, objectStoreId)))
    410405        return; // FIXME: Report error.
    411     if (!deleteRange(m_currentTransaction.get(), IndexMetaDataKey::encode(databaseId, objectStoreId, 0, 0), IndexMetaDataKey::encode(databaseId, objectStoreId, INT64_MAX, 0)))
     406    if (!deleteRange(m_currentTransaction.get(), IndexMetaDataKey::encode(databaseId, objectStoreId, 0, 0), IndexMetaDataKey::encodeMaxKey(databaseId, objectStoreId)))
    412407        return; // FIXME: Report error.
    413408
     
    640635{
    641636    const Vector<char> startKey = IndexFreeListKey::encode(databaseId, objectStoreId, 0);
    642     const Vector<char> stopKey = IndexFreeListKey::encode(databaseId, objectStoreId, INT64_MAX);
     637    const Vector<char> stopKey = IndexFreeListKey::encodeMaxKey(databaseId, objectStoreId);
    643638
    644639    OwnPtr<LevelDBIterator> it = transaction->createIterator();
  • trunk/Source/WebCore/storage/IDBLevelDBCoding.cpp

    r86425 r88019  
    146146
    147147#ifndef INT64_MAX
    148 // FIXME: We shouldn't need to rely on these macros.
    149148#define INT64_MAX 0x7fffffffffffffffLL
    150149#endif
     
    751750}
    752751
     752Vector<char> DatabaseFreeListKey::encodeMaxKey()
     753{
     754    return encode(INT64_MAX);
     755}
     756
    753757int64_t DatabaseFreeListKey::databaseId() const
    754758{
     
    847851    ret.append(encodeVarInt(metaDataType));
    848852    return ret;
     853}
     854
     855Vector<char> ObjectStoreMetaDataKey::encodeMaxKey(int64_t databaseId)
     856{
     857    return encode(databaseId, INT64_MAX, INT64_MAX);
    849858}
    850859
     
    914923}
    915924
     925Vector<char> IndexMetaDataKey::encodeMaxKey(int64_t databaseId, int64_t objectStoreId)
     926{
     927    return encode(databaseId, objectStoreId, INT64_MAX, 255);
     928}
     929
    916930int IndexMetaDataKey::compare(const IndexMetaDataKey& other)
    917931{
     
    964978}
    965979
     980Vector<char> ObjectStoreFreeListKey::encodeMaxKey(int64_t databaseId)
     981{
     982    return encode(databaseId, INT64_MAX);
     983}
     984
    966985int64_t ObjectStoreFreeListKey::objectStoreId() const
    967986{
     
    10141033    ret.append(encodeVarInt(indexId));
    10151034    return ret;
     1035}
     1036
     1037Vector<char> IndexFreeListKey::encodeMaxKey(int64_t databaseId, int64_t objectStoreId)
     1038{
     1039    return encode(databaseId, objectStoreId, INT64_MAX);
    10161040}
    10171041
  • trunk/Source/WebCore/storage/IDBLevelDBCoding.h

    r85045 r88019  
    105105    static const char* decode(const char* start, const char* limit, DatabaseFreeListKey* result);
    106106    static Vector<char> encode(int64_t databaseId);
     107    static Vector<char> encodeMaxKey();
    107108    int64_t databaseId() const;
    108109    int compare(const DatabaseFreeListKey& other) const;
     
    142143    static const char* decode(const char* start, const char* limit, ObjectStoreMetaDataKey* result);
    143144    static Vector<char> encode(int64_t databaseId, int64_t objectStoreId, int64_t metaDataType);
     145    static Vector<char> encodeMaxKey(int64_t databaseId);
    144146    int64_t objectStoreId() const;
    145147    int64_t metaDataType() const;
     
    156158    static const char* decode(const char* start, const char* limit, IndexMetaDataKey* result);
    157159    static Vector<char> encode(int64_t databaseId, int64_t objectStoreId, int64_t indexId, unsigned char metaDataType);
     160    static Vector<char> encodeMaxKey(int64_t databaseId, int64_t objectStoreId);
    158161    int compare(const IndexMetaDataKey& other);
    159162    int64_t indexId() const;
     
    171174    static const char* decode(const char* start, const char* limit, ObjectStoreFreeListKey* result);
    172175    static Vector<char> encode(int64_t databaseId, int64_t objectStoreId);
     176    static Vector<char> encodeMaxKey(int64_t databaseId);
    173177    int64_t objectStoreId() const;
    174178    int compare(const ObjectStoreFreeListKey& other);
     
    183187    static const char* decode(const char* start, const char* limit, IndexFreeListKey* result);
    184188    static Vector<char> encode(int64_t databaseId, int64_t objectStoreId, int64_t indexId);
     189    static Vector<char> encodeMaxKey(int64_t databaseId, int64_t objectStoreId);
    185190    int compare(const IndexFreeListKey& other);
    186191    int64_t objectStoreId() const;
  • trunk/Source/WebKit/chromium/ChangeLog

    r88010 r88019  
     12011-06-03  Hans Wennborg  <hans@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        IndexedDB: Clean-up use of INT64_MAX in LevelDB back-end
     6        https://bugs.webkit.org/show_bug.cgi?id=62009
     7
     8        Don't use INT64_MAX, use the various encodeMaxKey() functions instead.
     9
     10        * tests/IDBLevelDBCodingTest.cpp:
     11        (IDBLevelDBCoding::TEST):
     12
    1132011-06-03  Mikhail Naganov  <mnaganov@chromium.org>
    214
  • trunk/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp

    r86425 r88019  
    3535#include <wtf/Vector.h>
    3636
    37 #ifndef INT64_MAX
    38 // FIXME: We shouldn't need to rely on these macros.
    39 #define INT64_MAX 0x7fffffffffffffffLL
    40 #endif
    41 
    4237using namespace WebCore;
    4338using namespace IDBLevelDBCoding;
     
    346341    keys.append(MaxDatabaseIdKey::encode());
    347342    keys.append(DatabaseFreeListKey::encode(0));
    348     keys.append(DatabaseFreeListKey::encode(INT64_MAX));
     343    keys.append(DatabaseFreeListKey::encodeMaxKey());
    349344    keys.append(DatabaseNameKey::encode("", ""));
    350345    keys.append(DatabaseNameKey::encode("", "a"));
     
    352347    keys.append(DatabaseMetaDataKey::encode(1, DatabaseMetaDataKey::kOriginName));
    353348    keys.append(ObjectStoreMetaDataKey::encode(1, 1, 0));
    354     keys.append(ObjectStoreMetaDataKey::encode(1, INT64_MAX, 0));
     349    keys.append(ObjectStoreMetaDataKey::encodeMaxKey(1));
    355350    keys.append(IndexMetaDataKey::encode(1, 1, 30, 0));
    356     keys.append(IndexMetaDataKey::encode(1, 1, INT64_MAX, 0));
     351    keys.append(IndexMetaDataKey::encode(1, 1, 31, 0));
     352    keys.append(IndexMetaDataKey::encode(1, 1, 31, 1));
    357353    keys.append(ObjectStoreFreeListKey::encode(1, 1));
    358     keys.append(ObjectStoreFreeListKey::encode(1, INT64_MAX));
    359     keys.append(IndexFreeListKey::encode(1, 1, 30));
    360     keys.append(IndexFreeListKey::encode(1, 1, INT64_MAX));
    361     keys.append(IndexFreeListKey::encode(1, INT64_MAX, 30));
    362     keys.append(IndexFreeListKey::encode(1, INT64_MAX, INT64_MAX));
     354    keys.append(ObjectStoreFreeListKey::encodeMaxKey(1));
     355    keys.append(IndexFreeListKey::encode(1, 1, kMinimumIndexId));
     356    keys.append(IndexFreeListKey::encodeMaxKey(1, 1));
     357    keys.append(IndexFreeListKey::encode(1, 2, kMinimumIndexId));
     358    keys.append(IndexFreeListKey::encodeMaxKey(1, 2));
    363359    keys.append(ObjectStoreNamesKey::encode(1, ""));
    364360    keys.append(ObjectStoreNamesKey::encode(1, "a"));
    365361    keys.append(IndexNamesKey::encode(1, 1, ""));
    366362    keys.append(IndexNamesKey::encode(1, 1, "a"));
    367     keys.append(IndexNamesKey::encode(1, INT64_MAX, "a"));
     363    keys.append(IndexNamesKey::encode(1, 2, "a"));
    368364    keys.append(ObjectStoreDataKey::encode(1, 1, minIDBKey()));
    369365    keys.append(ObjectStoreDataKey::encode(1, 1, maxIDBKey()));
     
    371367    keys.append(ExistsEntryKey::encode(1, 1, maxIDBKey()));
    372368    keys.append(IndexDataKey::encode(1, 1, 30, minIDBKey(), 0));
    373     keys.append(IndexDataKey::encode(1, 1, 30, minIDBKey(), INT64_MAX));
     369    keys.append(IndexDataKey::encode(1, 1, 30, minIDBKey(), 1));
    374370    keys.append(IndexDataKey::encode(1, 1, 30, maxIDBKey(), 0));
    375     keys.append(IndexDataKey::encode(1, 1, 30, maxIDBKey(), INT64_MAX));
     371    keys.append(IndexDataKey::encode(1, 1, 30, maxIDBKey(), 1));
    376372    keys.append(IndexDataKey::encode(1, 1, 31, minIDBKey(), 0));
    377373    keys.append(IndexDataKey::encode(1, 2, 30, minIDBKey(), 0));
    378374    keys.append(IndexDataKey::encodeMaxKey(1, 2));
    379     keys.append(ObjectStoreDataKey::encode(1, INT64_MAX, minIDBKey()));
    380     keys.append(ExistsEntryKey::encode(1, INT64_MAX, maxIDBKey()));
    381     keys.append(IndexDataKey::encodeMaxKey(1, INT64_MAX));
    382     keys.append(DatabaseMetaDataKey::encode(INT64_MAX, DatabaseMetaDataKey::kOriginName));
    383     keys.append(IndexDataKey::encodeMaxKey(INT64_MAX, INT64_MAX));
    384375
    385376    for (size_t i = 0; i < keys.size(); ++i) {
Note: See TracChangeset for help on using the changeset viewer.