| Differences between
and this patch
- a/Source/WebCore/ChangeLog +40 lines
Lines 1-5 a/Source/WebCore/ChangeLog_sec1
1
2013-10-21  Brady Eidson  <beidson@apple.com>
1
2013-10-21  Brady Eidson  <beidson@apple.com>
2
2
3
        Add a cross-platform IDBRecordIdentifier
4
        https://bugs.webkit.org/show_bug.cgi?id=123138
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Add the cross-platform header:
9
        * Modules/indexeddb/IDBRecordIdentifier.h: Added.
10
        (WebCore::IDBRecordIdentifier::create):
11
        (WebCore::IDBRecordIdentifier::encodedPrimaryKey):
12
        (WebCore::IDBRecordIdentifier::version):
13
        (WebCore::IDBRecordIdentifier::reset):
14
        (WebCore::IDBRecordIdentifier::IDBRecordIdentifier):
15
        * WebCore.xcodeproj/project.pbxproj:
16
        * GNUmakefile.list.am:
17
18
        Remove the old abstract and LevelDB classes:
19
        * Modules/indexeddb/IDBBackingStoreInterface.h:
20
        * Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h:
21
22
        Use the cross-platform one everywhere:
23
        * Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
24
        (WebCore::IDBBackingStoreLevelDB::putRecord):
25
        (WebCore::IDBBackingStoreLevelDB::deleteRecord):
26
        (WebCore::IDBBackingStoreLevelDB::keyExistsInObjectStore):
27
        (WebCore::IDBBackingStoreLevelDB::putIndexDataForRecord):
28
        (WebCore::ObjectStoreKeyCursorImpl::loadCurrentRow):
29
        (WebCore::ObjectStoreCursorImpl::loadCurrentRow):
30
31
        * Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp:
32
        (WebCore::IDBDatabaseBackendLevelDB::setIndexKeys):
33
34
        * Modules/indexeddb/leveldb/IDBObjectStoreBackendLevelDB.cpp:
35
        (WebCore::IDBObjectStoreBackendLevelDB::IndexWriter::writeIndexKeys):
36
37
        * Modules/indexeddb/leveldb/IDBObjectStoreBackendLevelDB.h:
38
        * Modules/indexeddb/leveldb/IDBTransactionBackendLevelDBOperations.cpp:
39
        (WebCore::PutOperation::perform):
40
41
2013-10-21  Brady Eidson  <beidson@apple.com>
42
3
        Make IDBTransactionCoordinatorLevelDB cross platform
43
        Make IDBTransactionCoordinatorLevelDB cross platform
4
        https://bugs.webkit.org/show_bug.cgi?id=123124
44
        https://bugs.webkit.org/show_bug.cgi?id=123124
5
45
- a/Source/WebCore/GNUmakefile.list.am +1 lines
Lines 1841-1846 webcore_modules_sources += \ a/Source/WebCore/GNUmakefile.list.am_sec1
1841
	Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h \
1841
	Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h \
1842
	Source/WebCore/Modules/indexeddb/IDBPendingTransactionMonitor.cpp \
1842
	Source/WebCore/Modules/indexeddb/IDBPendingTransactionMonitor.cpp \
1843
	Source/WebCore/Modules/indexeddb/IDBPendingTransactionMonitor.h \
1843
	Source/WebCore/Modules/indexeddb/IDBPendingTransactionMonitor.h \
1844
	Source/WebCore/Modules/indexeddb/IDBRecordIdentifier.h \
1844
	Source/WebCore/Modules/indexeddb/IDBRequest.cpp \
1845
	Source/WebCore/Modules/indexeddb/IDBRequest.cpp \
1845
	Source/WebCore/Modules/indexeddb/IDBRequest.h \
1846
	Source/WebCore/Modules/indexeddb/IDBRequest.h \
1846
	Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.cpp \
1847
	Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.cpp \
- a/Source/WebCore/Modules/indexeddb/IDBBackingStoreInterface.h -14 / +6 lines
Lines 40-45 namespace WebCore { a/Source/WebCore/Modules/indexeddb/IDBBackingStoreInterface.h_sec1
40
class IDBKey;
40
class IDBKey;
41
class IDBKeyPath;
41
class IDBKeyPath;
42
class IDBKeyRange;
42
class IDBKeyRange;
43
class IDBRecordIdentifier;
43
class SharedBuffer;
44
class SharedBuffer;
44
45
45
class IDBBackingStoreInterface : public RefCounted<IDBBackingStoreInterface> {
46
class IDBBackingStoreInterface : public RefCounted<IDBBackingStoreInterface> {
Lines 51-65 public: a/Source/WebCore/Modules/indexeddb/IDBBackingStoreInterface.h_sec2
51
        virtual ~Transaction() { }
52
        virtual ~Transaction() { }
52
    };
53
    };
53
54
54
    class RecordIdentifier {
55
    public:
56
        virtual ~RecordIdentifier() { }
57
58
        virtual const Vector<char> primaryKey() const = 0;
59
        virtual int64_t version() const = 0;
60
        virtual void reset(const Vector<char>& primaryKey, int64_t version) = 0;
61
    };
62
63
    class Cursor : public RefCounted<Cursor> {
55
    class Cursor : public RefCounted<Cursor> {
64
    public:
56
    public:
65
        enum IteratorState {
57
        enum IteratorState {
Lines 76-98 public: a/Source/WebCore/Modules/indexeddb/IDBBackingStoreInterface.h_sec3
76
        virtual PassRefPtr<Cursor> clone() = 0;
68
        virtual PassRefPtr<Cursor> clone() = 0;
77
        virtual PassRefPtr<IDBKey> primaryKey() const = 0;
69
        virtual PassRefPtr<IDBKey> primaryKey() const = 0;
78
        virtual PassRefPtr<SharedBuffer> value() const = 0;
70
        virtual PassRefPtr<SharedBuffer> value() const = 0;
79
        virtual const RecordIdentifier& recordIdentifier() const = 0;
71
        virtual const IDBRecordIdentifier& recordIdentifier() const = 0;
80
    };
72
    };
81
73
82
    virtual bool getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata*, bool& found) = 0;
74
    virtual bool getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata*, bool& found) = 0;
83
    virtual bool getObjectStores(int64_t databaseId, IDBDatabaseMetadata::ObjectStoreMap* objectStores) = 0;
75
    virtual bool getObjectStores(int64_t databaseId, IDBDatabaseMetadata::ObjectStoreMap* objectStores) = 0;
84
    virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId) = 0;
76
    virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId) = 0;
85
    virtual bool keyExistsInObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, IDBBackingStoreInterface::RecordIdentifier* foundRecordIdentifier, bool& found) = 0;
77
    virtual bool keyExistsInObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RefPtr<IDBRecordIdentifier>& foundIDBRecordIdentifier) = 0;
86
78
87
    virtual bool putIndexDataForRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const IDBBackingStoreInterface::RecordIdentifier&) = 0;
79
    virtual bool putIndexDataForRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const IDBRecordIdentifier*) = 0;
88
    virtual bool keyExistsInIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, RefPtr<IDBKey>& foundPrimaryKey, bool& exists) = 0;
80
    virtual bool keyExistsInIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, RefPtr<IDBKey>& foundPrimaryKey, bool& exists) = 0;
89
81
90
    virtual bool deleteDatabase(const String& name) = 0;
82
    virtual bool deleteDatabase(const String& name) = 0;
91
    virtual bool updateIDBDatabaseIntVersion(IDBBackingStoreInterface::Transaction*, int64_t rowId, int64_t intVersion) = 0;
83
    virtual bool updateIDBDatabaseIntVersion(IDBBackingStoreInterface::Transaction*, int64_t rowId, int64_t intVersion) = 0;
92
84
93
    virtual bool getRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, Vector<char>& record) = 0;
85
    virtual bool getRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, Vector<char>& record) = 0;
94
    virtual bool putRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, PassRefPtr<SharedBuffer> value, IDBBackingStoreInterface::RecordIdentifier*) = 0;
86
    virtual bool putRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, PassRefPtr<SharedBuffer> value, IDBRecordIdentifier*) = 0;
95
    virtual bool deleteRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBBackingStoreInterface::RecordIdentifier&) = 0;
87
    virtual bool deleteRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBRecordIdentifier&) = 0;
96
88
97
    virtual bool createObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) = 0;
89
    virtual bool createObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) = 0;
98
    virtual bool deleteObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId) = 0;
90
    virtual bool deleteObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId) = 0;
- a/Source/WebCore/Modules/indexeddb/IDBRecordIdentifier.h +79 lines
Line 0 a/Source/WebCore/Modules/indexeddb/IDBRecordIdentifier.h_sec1
1
/*
2
 * Copyright (C) 2010 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer.
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution.
13
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14
 *     its contributors may be used to endorse or promote products derived
15
 *     from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
#ifndef IDBRecordIdentifier_h
29
#define IDBRecordIdentifier_h
30
31
#include <wtf/RefCounted.h>
32
#include <wtf/Vector.h>
33
34
#if ENABLE(INDEXED_DATABASE)
35
36
namespace WebCore {
37
38
class IDBRecordIdentifier : public RefCounted<IDBRecordIdentifier> {
39
public:
40
    static PassRefPtr<IDBRecordIdentifier> create(const Vector<char>& encodedPrimaryKey, int64_t version)
41
    {
42
        return adoptRef(new IDBRecordIdentifier(encodedPrimaryKey, version));
43
    }
44
45
    static PassRefPtr<IDBRecordIdentifier> create()
46
    {
47
        return adoptRef(new IDBRecordIdentifier);
48
    }
49
50
    const Vector<char>& encodedPrimaryKey() const { return m_encodedPrimaryKey; }
51
    int64_t version() const { return m_version; }
52
    void reset(const Vector<char>& encodedPrimaryKey, int64_t version)
53
    {
54
        m_encodedPrimaryKey = encodedPrimaryKey;
55
        m_version = version;
56
    }
57
58
private:
59
    IDBRecordIdentifier(const Vector<char>& encodedPrimaryKey, int64_t version)
60
        : m_encodedPrimaryKey(encodedPrimaryKey)
61
        , m_version(version)
62
    {
63
        ASSERT(!encodedPrimaryKey.isEmpty());
64
    }
65
66
    IDBRecordIdentifier()
67
        : m_version(-1)
68
    {
69
    }
70
71
    Vector<char> m_encodedPrimaryKey;
72
    int64_t m_version;
73
};
74
75
} // namespace WebCore
76
77
#endif
78
79
#endif // IDBRecordIdentifier_h
- a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp -27 / +32 lines
Lines 898-904 WARN_UNUSED_RETURN static bool getNewVersionNumber(LevelDBTransaction* transacti a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec1
898
    return true;
898
    return true;
899
}
899
}
900
900
901
bool IDBBackingStoreLevelDB::putRecord(IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, PassRefPtr<SharedBuffer> prpValue, IDBBackingStoreInterface::RecordIdentifier* recordIdentifier)
901
bool IDBBackingStoreLevelDB::putRecord(IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, PassRefPtr<SharedBuffer> prpValue, IDBRecordIdentifier* recordIdentifier)
902
{
902
{
903
    LOG(StorageAPI, "IDBBackingStoreLevelDB::putRecord");
903
    LOG(StorageAPI, "IDBBackingStoreLevelDB::putRecord");
904
    if (!KeyPrefix::validIds(databaseId, objectStoreId))
904
    if (!KeyPrefix::validIds(databaseId, objectStoreId))
Lines 941-957 bool IDBBackingStoreLevelDB::clearObjectStore(IDBBackingStoreInterface::Transact a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec2
941
    return true;
941
    return true;
942
}
942
}
943
943
944
bool IDBBackingStoreLevelDB::deleteRecord(IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBBackingStoreInterface::RecordIdentifier& recordIdentifier)
944
bool IDBBackingStoreLevelDB::deleteRecord(IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBRecordIdentifier& recordIdentifier)
945
{
945
{
946
    LOG(StorageAPI, "IDBBackingStoreLevelDB::deleteRecord");
946
    LOG(StorageAPI, "IDBBackingStoreLevelDB::deleteRecord");
947
947
    if (!KeyPrefix::validIds(databaseId, objectStoreId))
948
    if (!KeyPrefix::validIds(databaseId, objectStoreId))
948
        return false;
949
        return false;
949
    LevelDBTransaction* levelDBTransaction = IDBBackingStoreLevelDB::Transaction::levelDBTransactionFrom(transaction);
950
    LevelDBTransaction* levelDBTransaction = IDBBackingStoreLevelDB::Transaction::levelDBTransactionFrom(transaction);
950
951
951
    const Vector<char> objectStoreDataKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, recordIdentifier.primaryKey());
952
    const Vector<char> objectStoreDataKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, recordIdentifier.encodedPrimaryKey());
952
    levelDBTransaction->remove(objectStoreDataKey);
953
    levelDBTransaction->remove(objectStoreDataKey);
953
954
954
    const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, recordIdentifier.primaryKey());
955
    const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, recordIdentifier.encodedPrimaryKey());
955
    levelDBTransaction->remove(existsEntryKey);
956
    levelDBTransaction->remove(existsEntryKey);
956
    return true;
957
    return true;
957
}
958
}
Lines 1027-1038 bool IDBBackingStoreLevelDB::maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStor a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec3
1027
    return true;
1028
    return true;
1028
}
1029
}
1029
1030
1030
bool IDBBackingStoreLevelDB::keyExistsInObjectStore(IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, IDBBackingStoreInterface::RecordIdentifier* foundRecordIdentifier, bool& found)
1031
bool IDBBackingStoreLevelDB::keyExistsInObjectStore(IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, RefPtr<IDBRecordIdentifier>& foundIDBRecordIdentifier)
1031
{
1032
{
1032
    LOG(StorageAPI, "IDBBackingStoreLevelDB::keyExistsInObjectStore");
1033
    LOG(StorageAPI, "IDBBackingStoreLevelDB::keyExistsInObjectStore");
1033
    if (!KeyPrefix::validIds(databaseId, objectStoreId))
1034
    if (!KeyPrefix::validIds(databaseId, objectStoreId))
1034
        return false;
1035
        return false;
1035
    found = false;
1036
    bool found = false;
1036
    LevelDBTransaction* levelDBTransaction = IDBBackingStoreLevelDB::Transaction::levelDBTransactionFrom(transaction);
1037
    LevelDBTransaction* levelDBTransaction = IDBBackingStoreLevelDB::Transaction::levelDBTransactionFrom(transaction);
1037
    const Vector<char> leveldbKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
1038
    const Vector<char> leveldbKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
1038
    Vector<char> data;
1039
    Vector<char> data;
Lines 1049-1055 bool IDBBackingStoreLevelDB::keyExistsInObjectStore(IDBBackingStoreInterface::Tr a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec4
1049
    if (!decodeVarInt(data.begin(), data.end(), version))
1050
    if (!decodeVarInt(data.begin(), data.end(), version))
1050
        return false;
1051
        return false;
1051
1052
1052
    foundRecordIdentifier->reset(encodeIDBKey(key), version);
1053
    foundIDBRecordIdentifier = IDBRecordIdentifier::create(encodeIDBKey(key), version);
1053
    return true;
1054
    return true;
1054
}
1055
}
1055
1056
Lines 1186-1204 bool IDBBackingStoreLevelDB::deleteIndex(IDBBackingStoreInterface::Transaction* a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec5
1186
    return true;
1187
    return true;
1187
}
1188
}
1188
1189
1189
bool IDBBackingStoreLevelDB::putIndexDataForRecord(IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const IDBBackingStoreInterface::RecordIdentifier& recordIdentifier)
1190
bool IDBBackingStoreLevelDB::putIndexDataForRecord(IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const IDBRecordIdentifier* recordIdentifier)
1190
{
1191
{
1191
    LOG(StorageAPI, "IDBBackingStoreLevelDB::putIndexDataForRecord");
1192
    LOG(StorageAPI, "IDBBackingStoreLevelDB::putIndexDataForRecord");
1192
    ASSERT(key.isValid());
1193
    ASSERT(key.isValid());
1194
    ASSERT(recordIdentifier);
1193
    if (!KeyPrefix::validIds(databaseId, objectStoreId, indexId))
1195
    if (!KeyPrefix::validIds(databaseId, objectStoreId, indexId))
1194
        return false;
1196
        return false;
1195
1197
1196
    LevelDBTransaction* levelDBTransaction = IDBBackingStoreLevelDB::Transaction::levelDBTransactionFrom(transaction);
1198
    LevelDBTransaction* levelDBTransaction = IDBBackingStoreLevelDB::Transaction::levelDBTransactionFrom(transaction);
1197
    const Vector<char> indexDataKey = IndexDataKey::encode(databaseId, objectStoreId, indexId, encodeIDBKey(key), recordIdentifier.primaryKey());
1199
    const Vector<char> indexDataKey = IndexDataKey::encode(databaseId, objectStoreId, indexId, encodeIDBKey(key), recordIdentifier->encodedPrimaryKey());
1198
1200
1199
    Vector<char> data;
1201
    Vector<char> data;
1200
    data.appendVector(encodeVarInt(recordIdentifier.version()));
1202
    data.appendVector(encodeVarInt(recordIdentifier->version()));
1201
    data.appendVector(recordIdentifier.primaryKey());
1203
    data.appendVector(recordIdentifier->encodedPrimaryKey());
1202
1204
1203
    levelDBTransaction->put(indexDataKey, data);
1205
    levelDBTransaction->put(indexDataKey, data);
1204
    return true;
1206
    return true;
Lines 1336-1341 IDBBackingStoreLevelDB::Cursor::Cursor(const IDBBackingStoreLevelDB::Cursor* oth a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec6
1336
    : m_transaction(other->m_transaction)
1338
    : m_transaction(other->m_transaction)
1337
    , m_cursorOptions(other->m_cursorOptions)
1339
    , m_cursorOptions(other->m_cursorOptions)
1338
    , m_currentKey(other->m_currentKey)
1340
    , m_currentKey(other->m_currentKey)
1341
    , m_recordIdentifier(IDBRecordIdentifier::create())
1339
{
1342
{
1340
    if (other->m_iterator) {
1343
    if (other->m_iterator) {
1341
        m_iterator = m_transaction->createIterator();
1344
        m_iterator = m_transaction->createIterator();
Lines 1345-1350 IDBBackingStoreLevelDB::Cursor::Cursor(const IDBBackingStoreLevelDB::Cursor* oth a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec7
1345
            ASSERT(m_iterator->isValid());
1348
            ASSERT(m_iterator->isValid());
1346
        }
1349
        }
1347
    }
1350
    }
1351
1352
    m_recordIdentifier->reset(other->m_recordIdentifier->encodedPrimaryKey(), other->m_recordIdentifier->version());
1348
}
1353
}
1349
1354
1350
bool IDBBackingStoreLevelDB::Cursor::firstSeek()
1355
bool IDBBackingStoreLevelDB::Cursor::firstSeek()
Lines 1505-1512 public: a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec8
1505
    }
1510
    }
1506
1511
1507
    // IDBBackingStoreLevelDB::Cursor
1512
    // IDBBackingStoreLevelDB::Cursor
1508
    virtual PassRefPtr<SharedBuffer> value() const { ASSERT_NOT_REACHED(); return 0; }
1513
    virtual PassRefPtr<SharedBuffer> value() const OVERRIDE { ASSERT_NOT_REACHED(); return 0; }
1509
    virtual bool loadCurrentRow();
1514
    virtual bool loadCurrentRow() OVERRIDE;
1510
1515
1511
protected:
1516
protected:
1512
    virtual Vector<char> encodeKey(const IDBKey &key)
1517
    virtual Vector<char> encodeKey(const IDBKey &key)
Lines 1548-1554 bool ObjectStoreKeyCursorImpl::loadCurrentRow() a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec9
1548
    }
1553
    }
1549
1554
1550
    // FIXME: This re-encodes what was just decoded; try and optimize.
1555
    // FIXME: This re-encodes what was just decoded; try and optimize.
1551
    m_recordIdentifier.reset(encodeIDBKey(*m_currentKey), version);
1556
    m_recordIdentifier->reset(encodeIDBKey(*m_currentKey), version);
1552
1557
1553
    return true;
1558
    return true;
1554
}
1559
}
Lines 1566-1573 public: a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec10
1566
    }
1571
    }
1567
1572
1568
    // IDBBackingStoreLevelDB::Cursor
1573
    // IDBBackingStoreLevelDB::Cursor
1569
    virtual PassRefPtr<SharedBuffer> value() const { return m_currentValue; }
1574
    virtual PassRefPtr<SharedBuffer> value() const OVERRIDE { return m_currentValue; }
1570
    virtual bool loadCurrentRow();
1575
    virtual bool loadCurrentRow() OVERRIDE;
1571
1576
1572
protected:
1577
protected:
1573
    virtual Vector<char> encodeKey(const IDBKey &key)
1578
    virtual Vector<char> encodeKey(const IDBKey &key)
Lines 1612-1618 bool ObjectStoreCursorImpl::loadCurrentRow() a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec11
1612
    }
1617
    }
1613
1618
1614
    // FIXME: This re-encodes what was just decoded; try and optimize.
1619
    // FIXME: This re-encodes what was just decoded; try and optimize.
1615
    m_recordIdentifier.reset(encodeIDBKey(*m_currentKey), version);
1620
    m_recordIdentifier->reset(encodeIDBKey(*m_currentKey), version);
1616
1621
1617
    Vector<char> value;
1622
    Vector<char> value;
1618
    value.append(valuePosition, m_iterator->value().end() - valuePosition);
1623
    value.append(valuePosition, m_iterator->value().end() - valuePosition);
Lines 1620-1626 bool ObjectStoreCursorImpl::loadCurrentRow() a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec12
1620
    return true;
1625
    return true;
1621
}
1626
}
1622
1627
1623
class IndexKeyCursorImpl : public IDBBackingStoreLevelDB::Cursor {
1628
class IndexKeyCursorImpl FINAL : public IDBBackingStoreLevelDB::Cursor {
1624
public:
1629
public:
1625
    static PassRefPtr<IndexKeyCursorImpl> create(LevelDBTransaction* transaction, const IDBBackingStoreLevelDB::Cursor::CursorOptions& cursorOptions)
1630
    static PassRefPtr<IndexKeyCursorImpl> create(LevelDBTransaction* transaction, const IDBBackingStoreLevelDB::Cursor::CursorOptions& cursorOptions)
1626
    {
1631
    {
Lines 1633-1642 public: a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec13
1633
    }
1638
    }
1634
1639
1635
    // IDBBackingStoreLevelDB::Cursor
1640
    // IDBBackingStoreLevelDB::Cursor
1636
    virtual PassRefPtr<SharedBuffer> value() const { ASSERT_NOT_REACHED(); return 0; }
1641
    virtual PassRefPtr<SharedBuffer> value() const OVERRIDE { ASSERT_NOT_REACHED(); return 0; }
1637
    virtual PassRefPtr<IDBKey> primaryKey() const { return m_primaryKey; }
1642
    virtual PassRefPtr<IDBKey> primaryKey() const OVERRIDE { return m_primaryKey; }
1638
    virtual const IDBBackingStoreLevelDB::RecordIdentifier& recordIdentifier() const { ASSERT_NOT_REACHED(); return m_recordIdentifier; }
1643
    virtual const IDBRecordIdentifier& recordIdentifier() const OVERRIDE { ASSERT_NOT_REACHED(); return *(m_recordIdentifier.get()); }
1639
    virtual bool loadCurrentRow();
1644
    virtual bool loadCurrentRow() OVERRIDE;
1640
1645
1641
protected:
1646
protected:
1642
    virtual Vector<char> encodeKey(const IDBKey &key)
1647
    virtual Vector<char> encodeKey(const IDBKey &key)
Lines 1711-1717 bool IndexKeyCursorImpl::loadCurrentRow() a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec14
1711
    return true;
1716
    return true;
1712
}
1717
}
1713
1718
1714
class IndexCursorImpl : public IDBBackingStoreLevelDB::Cursor {
1719
class IndexCursorImpl FINAL : public IDBBackingStoreLevelDB::Cursor {
1715
public:
1720
public:
1716
    static PassRefPtr<IndexCursorImpl> create(LevelDBTransaction* transaction, const IDBBackingStoreLevelDB::Cursor::CursorOptions& cursorOptions)
1721
    static PassRefPtr<IndexCursorImpl> create(LevelDBTransaction* transaction, const IDBBackingStoreLevelDB::Cursor::CursorOptions& cursorOptions)
1717
    {
1722
    {
Lines 1724-1733 public: a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp_sec15
1724
    }
1729
    }
1725
1730
1726
    // IDBBackingStoreLevelDB::Cursor
1731
    // IDBBackingStoreLevelDB::Cursor
1727
    virtual PassRefPtr<SharedBuffer> value() const { return m_currentValue; }
1732
    virtual PassRefPtr<SharedBuffer> value() const OVERRIDE { return m_currentValue; }
1728
    virtual PassRefPtr<IDBKey> primaryKey() const { return m_primaryKey; }
1733
    virtual PassRefPtr<IDBKey> primaryKey() const OVERRIDE { return m_primaryKey; }
1729
    virtual const IDBBackingStoreLevelDB::RecordIdentifier& recordIdentifier() const { ASSERT_NOT_REACHED(); return m_recordIdentifier; }
1734
    virtual const IDBRecordIdentifier& recordIdentifier() const OVERRIDE { ASSERT_NOT_REACHED(); return *(m_recordIdentifier.get()); }
1730
    bool loadCurrentRow();
1735
    virtual bool loadCurrentRow() OVERRIDE;
1731
1736
1732
protected:
1737
protected:
1733
    virtual Vector<char> encodeKey(const IDBKey &key)
1738
    virtual Vector<char> encodeKey(const IDBKey &key)
- a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h -32 / +8 lines
Lines 31-36 a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h_sec1
31
#include "IDBBackingStoreInterface.h"
31
#include "IDBBackingStoreInterface.h"
32
#include "IDBKey.h"
32
#include "IDBKey.h"
33
#include "IDBMetadata.h"
33
#include "IDBMetadata.h"
34
#include "IDBRecordIdentifier.h"
34
#include "IndexedDB.h"
35
#include "IndexedDB.h"
35
#include "LevelDBIterator.h"
36
#include "LevelDBIterator.h"
36
#include "LevelDBTransaction.h"
37
#include "LevelDBTransaction.h"
Lines 77-119 public: a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h_sec2
77
    virtual bool createObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE;
78
    virtual bool createObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE;
78
    virtual bool deleteObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE WARN_UNUSED_RETURN;
79
    virtual bool deleteObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE WARN_UNUSED_RETURN;
79
80
80
    class RecordIdentifier : public IDBBackingStoreInterface::RecordIdentifier {
81
    public:
82
        RecordIdentifier(const Vector<char>& primaryKey, int64_t version)
83
            : IDBBackingStoreInterface::RecordIdentifier()
84
            , m_primaryKey(primaryKey)
85
            , m_version(version)
86
        {
87
            ASSERT(!primaryKey.isEmpty());
88
        }
89
90
        RecordIdentifier()
91
            : IDBBackingStoreInterface::RecordIdentifier()
92
            , m_primaryKey()
93
            , m_version(-1)
94
        {
95
        }
96
97
        const Vector<char> primaryKey() const OVERRIDE { return m_primaryKey; }
98
        int64_t version() const OVERRIDE { return m_version; }
99
        virtual void reset(const Vector<char>& primaryKey, int64_t version) OVERRIDE { m_primaryKey = primaryKey; m_version = version; }
100
101
    private:
102
        Vector<char> m_primaryKey; // FIXME: Make it more clear that this is the *encoded* version of the key.
103
        int64_t m_version;
104
    };
105
106
    virtual bool getRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, Vector<char>& record) OVERRIDE WARN_UNUSED_RETURN;
81
    virtual bool getRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, Vector<char>& record) OVERRIDE WARN_UNUSED_RETURN;
107
    virtual bool putRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, PassRefPtr<SharedBuffer> value, IDBBackingStoreInterface::RecordIdentifier*) OVERRIDE WARN_UNUSED_RETURN;
82
    virtual bool putRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, PassRefPtr<SharedBuffer> value, IDBRecordIdentifier*) OVERRIDE WARN_UNUSED_RETURN;
108
    virtual bool clearObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE WARN_UNUSED_RETURN;
83
    virtual bool clearObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE WARN_UNUSED_RETURN;
109
    virtual bool deleteRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBBackingStoreInterface::RecordIdentifier&) OVERRIDE WARN_UNUSED_RETURN;
84
    virtual bool deleteRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBRecordIdentifier&) OVERRIDE WARN_UNUSED_RETURN;
110
    virtual bool getKeyGeneratorCurrentNumber(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t& currentNumber) OVERRIDE WARN_UNUSED_RETURN;
85
    virtual bool getKeyGeneratorCurrentNumber(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t& currentNumber) OVERRIDE WARN_UNUSED_RETURN;
111
    virtual bool maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newState, bool checkCurrent) OVERRIDE WARN_UNUSED_RETURN;
86
    virtual bool maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newState, bool checkCurrent) OVERRIDE WARN_UNUSED_RETURN;
112
    virtual bool keyExistsInObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, IDBBackingStoreInterface::RecordIdentifier* foundRecordIdentifier, bool& found) OVERRIDE WARN_UNUSED_RETURN;
87
    virtual bool keyExistsInObjectStore(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RefPtr<IDBRecordIdentifier>& foundIDBRecordIdentifier) OVERRIDE WARN_UNUSED_RETURN;
113
88
114
    virtual bool createIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry) OVERRIDE WARN_UNUSED_RETURN;
89
    virtual bool createIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry) OVERRIDE WARN_UNUSED_RETURN;
115
    virtual bool deleteIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE WARN_UNUSED_RETURN;
90
    virtual bool deleteIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE WARN_UNUSED_RETURN;
116
    virtual bool putIndexDataForRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const IDBBackingStoreInterface::RecordIdentifier&) OVERRIDE WARN_UNUSED_RETURN;
91
    virtual bool putIndexDataForRecord(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const IDBRecordIdentifier*) OVERRIDE WARN_UNUSED_RETURN;
117
    virtual bool getPrimaryKeyViaIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, RefPtr<IDBKey>& primaryKey) OVERRIDE WARN_UNUSED_RETURN;
92
    virtual bool getPrimaryKeyViaIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, RefPtr<IDBKey>& primaryKey) OVERRIDE WARN_UNUSED_RETURN;
118
    virtual bool keyExistsInIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey, bool& exists) OVERRIDE WARN_UNUSED_RETURN;
93
    virtual bool keyExistsInIndex(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey, bool& exists) OVERRIDE WARN_UNUSED_RETURN;
119
94
Lines 139-145 public: a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h_sec3
139
        virtual PassRefPtr<IDBBackingStoreInterface::Cursor> clone() OVERRIDE = 0;
114
        virtual PassRefPtr<IDBBackingStoreInterface::Cursor> clone() OVERRIDE = 0;
140
        virtual PassRefPtr<IDBKey> primaryKey() const OVERRIDE { return m_currentKey; }
115
        virtual PassRefPtr<IDBKey> primaryKey() const OVERRIDE { return m_currentKey; }
141
        virtual PassRefPtr<SharedBuffer> value() const OVERRIDE = 0;
116
        virtual PassRefPtr<SharedBuffer> value() const OVERRIDE = 0;
142
        virtual const RecordIdentifier& recordIdentifier() const OVERRIDE { return m_recordIdentifier; }
117
        virtual const IDBRecordIdentifier& recordIdentifier() const OVERRIDE { return *(m_recordIdentifier.get()); }
143
        virtual ~Cursor() { }
118
        virtual ~Cursor() { }
144
        virtual bool loadCurrentRow() = 0;
119
        virtual bool loadCurrentRow() = 0;
145
120
Lines 147-152 public: a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h_sec4
147
        Cursor(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
122
        Cursor(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
148
            : m_transaction(transaction)
123
            : m_transaction(transaction)
149
            , m_cursorOptions(cursorOptions)
124
            , m_cursorOptions(cursorOptions)
125
            , m_recordIdentifier(IDBRecordIdentifier::create())
150
        {
126
        {
151
        }
127
        }
152
        explicit Cursor(const IDBBackingStoreLevelDB::Cursor* other);
128
        explicit Cursor(const IDBBackingStoreLevelDB::Cursor* other);
Lines 160-166 public: a/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h_sec5
160
        const CursorOptions m_cursorOptions;
136
        const CursorOptions m_cursorOptions;
161
        OwnPtr<LevelDBIterator> m_iterator;
137
        OwnPtr<LevelDBIterator> m_iterator;
162
        RefPtr<IDBKey> m_currentKey;
138
        RefPtr<IDBKey> m_currentKey;
163
        IDBBackingStoreLevelDB::RecordIdentifier m_recordIdentifier;
139
        RefPtr<IDBRecordIdentifier> m_recordIdentifier;
164
    };
140
    };
165
141
166
    virtual PassRefPtr<IDBBackingStoreInterface::Cursor> openObjectStoreKeyCursor(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IndexedDB::CursorDirection) OVERRIDE;
142
    virtual PassRefPtr<IDBBackingStoreInterface::Cursor> openObjectStoreKeyCursor(IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IndexedDB::CursorDirection) OVERRIDE;
- a/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp -6 / +5 lines
Lines 28-34 a/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp_sec1
28
28
29
#if ENABLE(INDEXED_DATABASE) && USE(LEVELDB)
29
#if ENABLE(INDEXED_DATABASE) && USE(LEVELDB)
30
30
31
#include "IDBBackingStoreLevelDB.h"
31
#include "IDBBackingStoreInterface.h"
32
#include "IDBCursorBackendLevelDB.h"
32
#include "IDBCursorBackendLevelDB.h"
33
#include "IDBDatabaseException.h"
33
#include "IDBDatabaseException.h"
34
#include "IDBFactoryBackendLevelDB.h"
34
#include "IDBFactoryBackendLevelDB.h"
Lines 248-261 void IDBDatabaseBackendLevelDB::setIndexKeys(int64_t transactionId, int64_t obje a/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp_sec2
248
    RefPtr<IDBKey> primaryKey = prpPrimaryKey;
248
    RefPtr<IDBKey> primaryKey = prpPrimaryKey;
249
    RefPtr<IDBBackingStoreInterface> store = backingStore();
249
    RefPtr<IDBBackingStoreInterface> store = backingStore();
250
    // FIXME: This method could be asynchronous, but we need to evaluate if it's worth the extra complexity.
250
    // FIXME: This method could be asynchronous, but we need to evaluate if it's worth the extra complexity.
251
    IDBBackingStoreLevelDB::RecordIdentifier recordIdentifier;
251
    RefPtr<IDBRecordIdentifier> recordIdentifier;
252
    bool found = false;
252
    bool ok = store->keyExistsInObjectStore(transaction->backingStoreTransaction(), m_metadata.id, objectStoreId, *primaryKey, recordIdentifier);
253
    bool ok = store->keyExistsInObjectStore(transaction->backingStoreTransaction(), m_metadata.id, objectStoreId, *primaryKey, &recordIdentifier, found);
254
    if (!ok) {
253
    if (!ok) {
255
        transaction->abort(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error setting index keys."));
254
        transaction->abort(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error setting index keys."));
256
        return;
255
        return;
257
    }
256
    }
258
    if (!found) {
257
    if (!recordIdentifier) {
259
        RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error setting index keys for object store."));
258
        RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error setting index keys for object store."));
260
        transaction->abort(error.release());
259
        transaction->abort(error.release());
261
        return;
260
        return;
Lines 278-284 void IDBDatabaseBackendLevelDB::setIndexKeys(int64_t transactionId, int64_t obje a/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp_sec3
278
277
279
    for (size_t i = 0; i < indexWriters.size(); ++i) {
278
    for (size_t i = 0; i < indexWriters.size(); ++i) {
280
        IDBObjectStoreBackendLevelDB::IndexWriter* indexWriter = indexWriters[i].get();
279
        IDBObjectStoreBackendLevelDB::IndexWriter* indexWriter = indexWriters[i].get();
281
        indexWriter->writeIndexKeys(recordIdentifier, *store.get(), transaction->backingStoreTransaction(), id(), objectStoreId);
280
        indexWriter->writeIndexKeys(recordIdentifier.get(), *store.get(), transaction->backingStoreTransaction(), id(), objectStoreId);
282
    }
281
    }
283
}
282
}
284
283
- a/Source/WebCore/Modules/indexeddb/leveldb/IDBObjectStoreBackendLevelDB.cpp -1 / +2 lines
Lines 61-68 bool IDBObjectStoreBackendLevelDB::IndexWriter::verifyIndexKeys(IDBBackingStoreI a/Source/WebCore/Modules/indexeddb/leveldb/IDBObjectStoreBackendLevelDB.cpp_sec1
61
    return true;
61
    return true;
62
}
62
}
63
63
64
void IDBObjectStoreBackendLevelDB::IndexWriter::writeIndexKeys(const IDBBackingStoreLevelDB::RecordIdentifier& recordIdentifier, IDBBackingStoreInterface& backingStore, IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId) const
64
void IDBObjectStoreBackendLevelDB::IndexWriter::writeIndexKeys(const IDBRecordIdentifier* recordIdentifier, IDBBackingStoreInterface& backingStore, IDBBackingStoreInterface::Transaction* transaction, int64_t databaseId, int64_t objectStoreId) const
65
{
65
{
66
    ASSERT(recordIdentifier);
66
    int64_t indexId = m_indexMetadata.id;
67
    int64_t indexId = m_indexMetadata.id;
67
    for (size_t i = 0; i < m_indexKeys.size(); ++i) {
68
    for (size_t i = 0; i < m_indexKeys.size(); ++i) {
68
        bool ok = backingStore.putIndexDataForRecord(transaction, databaseId, objectStoreId, indexId, *(m_indexKeys)[i].get(), recordIdentifier);
69
        bool ok = backingStore.putIndexDataForRecord(transaction, databaseId, objectStoreId, indexId, *(m_indexKeys)[i].get(), recordIdentifier);
- a/Source/WebCore/Modules/indexeddb/leveldb/IDBObjectStoreBackendLevelDB.h -1 / +1 lines
Lines 57-63 namespace IDBObjectStoreBackendLevelDB { a/Source/WebCore/Modules/indexeddb/leveldb/IDBObjectStoreBackendLevelDB.h_sec1
57
57
58
        bool verifyIndexKeys(IDBBackingStoreInterface&, IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, bool& canAddKeys, const IDBKey* primaryKey = 0, String* errorMessage = 0) const WARN_UNUSED_RETURN;
58
        bool verifyIndexKeys(IDBBackingStoreInterface&, IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, bool& canAddKeys, const IDBKey* primaryKey = 0, String* errorMessage = 0) const WARN_UNUSED_RETURN;
59
59
60
        void writeIndexKeys(const IDBBackingStoreLevelDB::RecordIdentifier&, IDBBackingStoreInterface&, IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId) const;
60
        void writeIndexKeys(const IDBRecordIdentifier*, IDBBackingStoreInterface&, IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId) const;
61
61
62
    private:
62
    private:
63
        bool addingKeyAllowed(IDBBackingStoreInterface&, IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey* indexKey, const IDBKey* primaryKey, bool& allowed) const WARN_UNUSED_RETURN;
63
        bool addingKeyAllowed(IDBBackingStoreInterface&, IDBBackingStoreInterface::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey* indexKey, const IDBKey* primaryKey, bool& allowed) const WARN_UNUSED_RETURN;
- a/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDBOperations.cpp -6 / +5 lines
Lines 193-207 void PutOperation::perform() a/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDBOperations.cpp_sec1
193
    ASSERT(key);
193
    ASSERT(key);
194
    ASSERT(key->isValid());
194
    ASSERT(key->isValid());
195
195
196
    IDBBackingStoreLevelDB::RecordIdentifier recordIdentifier;
196
    RefPtr<IDBRecordIdentifier> recordIdentifier;
197
    if (m_putMode == IDBDatabaseBackendInterface::AddOnly) {
197
    if (m_putMode == IDBDatabaseBackendInterface::AddOnly) {
198
        bool found = false;
198
        bool ok = m_backingStore->keyExistsInObjectStore(m_transaction->backingStoreTransaction(), m_databaseId, m_objectStore.id, *key, recordIdentifier);
199
        bool ok = m_backingStore->keyExistsInObjectStore(m_transaction->backingStoreTransaction(), m_databaseId, m_objectStore.id, *key, &recordIdentifier, found);
200
        if (!ok) {
199
        if (!ok) {
201
            m_callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error checking key existence."));
200
            m_callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error checking key existence."));
202
            return;
201
            return;
203
        }
202
        }
204
        if (found) {
203
        if (recordIdentifier) {
205
            m_callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::ConstraintError, "Key already exists in the object store."));
204
            m_callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::ConstraintError, "Key already exists in the object store."));
206
            return;
205
            return;
207
        }
206
        }
Lines 221-227 void PutOperation::perform() a/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDBOperations.cpp_sec2
221
    }
220
    }
222
221
223
    // Before this point, don't do any mutation. After this point, rollback the transaction in case of error.
222
    // Before this point, don't do any mutation. After this point, rollback the transaction in case of error.
224
    backingStoreSuccess = m_backingStore->putRecord(m_transaction->backingStoreTransaction(), m_databaseId, m_objectStore.id, *key, m_value, &recordIdentifier);
223
    backingStoreSuccess = m_backingStore->putRecord(m_transaction->backingStoreTransaction(), m_databaseId, m_objectStore.id, *key, m_value, recordIdentifier.get());
225
    if (!backingStoreSuccess) {
224
    if (!backingStoreSuccess) {
226
        m_callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error: backing store error performing put/add."));
225
        m_callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error: backing store error performing put/add."));
227
        return;
226
        return;
Lines 229-235 void PutOperation::perform() a/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDBOperations.cpp_sec3
229
228
230
    for (size_t i = 0; i < indexWriters.size(); ++i) {
229
    for (size_t i = 0; i < indexWriters.size(); ++i) {
231
        IDBObjectStoreBackendLevelDB::IndexWriter* indexWriter = indexWriters[i].get();
230
        IDBObjectStoreBackendLevelDB::IndexWriter* indexWriter = indexWriters[i].get();
232
        indexWriter->writeIndexKeys(recordIdentifier, *m_backingStore, m_transaction->backingStoreTransaction(), m_databaseId, m_objectStore.id);
231
        indexWriter->writeIndexKeys(recordIdentifier.get(), *m_backingStore, m_transaction->backingStoreTransaction(), m_databaseId, m_objectStore.id);
233
    }
232
    }
234
233
235
    if (m_objectStore.autoIncrement && m_putMode != IDBDatabaseBackendInterface::CursorUpdate && key->type() == IDBKey::NumberType) {
234
    if (m_objectStore.autoIncrement && m_putMode != IDBDatabaseBackendInterface::CursorUpdate && key->type() == IDBKey::NumberType) {
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +4 lines
Lines 1813-1818 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
1813
		51E6821016387302003BBF3C /* LoaderStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E6820F16387302003BBF3C /* LoaderStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
1813
		51E6821016387302003BBF3C /* LoaderStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E6820F16387302003BBF3C /* LoaderStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
1814
		51EAC5671815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51EAC5651815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp */; };
1814
		51EAC5671815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51EAC5651815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp */; };
1815
		51EAC5681815ED3E004F1BA4 /* IDBTransactionCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 51EAC5661815ED3E004F1BA4 /* IDBTransactionCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
1815
		51EAC5681815ED3E004F1BA4 /* IDBTransactionCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 51EAC5661815ED3E004F1BA4 /* IDBTransactionCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
1816
		51EAC5B218163F4E004F1BA4 /* IDBRecordIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 51EAC5B018163F4E004F1BA4 /* IDBRecordIdentifier.h */; };
1816
		51EC92650CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */; };
1817
		51EC92650CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */; };
1817
		51F6E0A31811D2520058A00A /* IDBTransactionBackendInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F6E08F1811D2520058A00A /* IDBTransactionBackendInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
1818
		51F6E0A31811D2520058A00A /* IDBTransactionBackendInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F6E08F1811D2520058A00A /* IDBTransactionBackendInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
1818
		51FA2D78152132B300C1BA0B /* DOMWindowExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 517FBA18151AA71B00B57959 /* DOMWindowExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
1819
		51FA2D78152132B300C1BA0B /* DOMWindowExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 517FBA18151AA71B00B57959 /* DOMWindowExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 8413-8418 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
8413
		51E6820F16387302003BBF3C /* LoaderStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoaderStrategy.h; sourceTree = "<group>"; };
8414
		51E6820F16387302003BBF3C /* LoaderStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoaderStrategy.h; sourceTree = "<group>"; };
8414
		51EAC5651815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBTransactionCoordinator.cpp; sourceTree = "<group>"; };
8415
		51EAC5651815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBTransactionCoordinator.cpp; sourceTree = "<group>"; };
8415
		51EAC5661815ED3E004F1BA4 /* IDBTransactionCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBTransactionCoordinator.h; sourceTree = "<group>"; };
8416
		51EAC5661815ED3E004F1BA4 /* IDBTransactionCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBTransactionCoordinator.h; sourceTree = "<group>"; };
8417
		51EAC5B018163F4E004F1BA4 /* IDBRecordIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBRecordIdentifier.h; sourceTree = "<group>"; };
8416
		51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomSQLStatementErrorCallback.cpp; sourceTree = "<group>"; };
8418
		51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomSQLStatementErrorCallback.cpp; sourceTree = "<group>"; };
8417
		51F6A3D50663BF04004D2919 /* HTMLCanvasElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLCanvasElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
8419
		51F6A3D50663BF04004D2919 /* HTMLCanvasElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLCanvasElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
8418
		51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLCanvasElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
8420
		51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLCanvasElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
Lines 16753-16758 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
16753
				51D7199E181106E00016DC51 /* IDBOpenDBRequest.idl */,
16755
				51D7199E181106E00016DC51 /* IDBOpenDBRequest.idl */,
16754
				51D7199F181106E00016DC51 /* IDBPendingTransactionMonitor.cpp */,
16756
				51D7199F181106E00016DC51 /* IDBPendingTransactionMonitor.cpp */,
16755
				51D719A0181106E00016DC51 /* IDBPendingTransactionMonitor.h */,
16757
				51D719A0181106E00016DC51 /* IDBPendingTransactionMonitor.h */,
16758
				51EAC5B018163F4E004F1BA4 /* IDBRecordIdentifier.h */,
16756
				51D719A1181106E00016DC51 /* IDBRequest.cpp */,
16759
				51D719A1181106E00016DC51 /* IDBRequest.cpp */,
16757
				51D719A2181106E00016DC51 /* IDBRequest.h */,
16760
				51D719A2181106E00016DC51 /* IDBRequest.h */,
16758
				51D719A3181106E00016DC51 /* IDBRequest.idl */,
16761
				51D719A3181106E00016DC51 /* IDBRequest.idl */,
Lines 21818-21823 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
21818
				BC53C6920DA591140021EB5D /* CSSGradientValue.h in Headers */,
21821
				BC53C6920DA591140021EB5D /* CSSGradientValue.h in Headers */,
21819
				078E094317D16E1C00420AA1 /* RTCSessionDescriptionDescriptor.h in Headers */,
21822
				078E094317D16E1C00420AA1 /* RTCSessionDescriptionDescriptor.h in Headers */,
21820
				650F53DC09D15DDA00C9B0C8 /* CSSGrammar.h in Headers */,
21823
				650F53DC09D15DDA00C9B0C8 /* CSSGrammar.h in Headers */,
21824
				51EAC5B218163F4E004F1BA4 /* IDBRecordIdentifier.h in Headers */,
21821
				FB3056C2169E5DAC0096A232 /* CSSGroupingRule.h in Headers */,
21825
				FB3056C2169E5DAC0096A232 /* CSSGroupingRule.h in Headers */,
21822
				BC772B3C0C4EA91E0083285F /* CSSHelper.h in Headers */,
21826
				BC772B3C0C4EA91E0083285F /* CSSHelper.h in Headers */,
21823
				FB49C39D16784947007FFB5D /* CSSHostRule.h in Headers */,
21827
				FB49C39D16784947007FFB5D /* CSSHostRule.h in Headers */,

Return to Bug 123138