Source/WebCore/ChangeLog

 12012-11-12 Alec Flett <alecflett@chromium.org>
 2
 3 IndexedDB: simplify RecordIdentifier
 4 https://bugs.webkit.org/show_bug.cgi?id=102018
 5
 6 Reviewed by Tony Chang.
 7
 8 Make IDBBackingStore's RecordIdentifier be a simple
 9 class, existing only as an inline or stack-based instance.
 10 This makes much of the copy semantics more explicit, and
 11 removes refcounting from an object that only ever had a refcount
 12 of 1 or 2.
 13
 14 No new tests, just a refactor.
 15
 16 * Modules/indexeddb/IDBBackingStore.cpp:
 17 (WebCore::IDBBackingStore::putRecord):
 18 (WebCore::IDBBackingStore::deleteRecord):
 19 (WebCore::IDBBackingStore::maybeUpdateKeyGeneratorCurrentNumber):
 20 (WebCore::IDBBackingStore::keyExistsInObjectStore):
 21 (WebCore::IDBBackingStore::putIndexDataForRecord):
 22 (WebCore::IDBBackingStore::deleteIndexDataForRecord):
 23 (WebCore::ObjectStoreKeyCursorImpl::loadCurrentRow):
 24 (ObjectStoreCursorImpl):
 25 (WebCore::ObjectStoreCursorImpl::loadCurrentRow):
 26 (WebCore::IndexKeyCursorImpl::recordIdentifier):
 27 (WebCore::IndexCursorImpl::recordIdentifier):
 28 * Modules/indexeddb/IDBBackingStore.h:
 29 (WebCore::IDBBackingStore::RecordIdentifier::RecordIdentifier):
 30 (WebCore::IDBBackingStore::RecordIdentifier::isValid):
 31 (WebCore::IDBBackingStore::RecordIdentifier::reset):
 32 (RecordIdentifier):
 33 (IDBBackingStore):
 34 (WebCore::IDBBackingStore::Cursor::recordIdentifier):
 35 (WebCore::IDBBackingStore::Cursor::Cursor):
 36 (Cursor):
 37 * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
 38 (WebCore):
 39 (WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
 40 (WebCore::IDBObjectStoreBackendImpl::putInternal):
 41 (WebCore::IDBObjectStoreBackendImpl::deleteInternal):
 42
1432012-11-19 Nate Chapin <japhet@chromium.org>
244
345 Move empty loading to DocumentLoader, simplify FrameLoader::init()

Source/WebKit/chromium/ChangeLog

 12012-11-12 Alec Flett <alecflett@chromium.org>
 2
 3 IndexedDB: simplify RecordIdentifier
 4 https://bugs.webkit.org/show_bug.cgi?id=102018
 5
 6 Reviewed by Tony Chang.
 7
 8 Update IDBFakeBackingStore to match its parent class.
 9
 10 * tests/IDBFakeBackingStore.h:
 11
1122012-11-19 Vincent Scheib <scheib@chromium.org>
213
314 [Chromium] Remove WebKit::WebRuntimeFeatures::enablePointerLock.

Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp

@@static int64_t getNewVersionNumber(LevelDBTransaction* transaction, int64_t data
656656 return version;
657657}
658658
659 bool IDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, RecordIdentifier* recordIdentifier)
 659void IDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, RecordIdentifier* recordIdentifier)
660660{
661661 IDB_TRACE("IDBBackingStore::putRecord");
662662 ASSERT(key.isValid());

@@bool IDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64
673673 const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, key);
674674 levelDBTransaction->put(existsEntryKey, encodeInt(version));
675675
676  recordIdentifier->setPrimaryKey(encodeIDBKey(key));
677  recordIdentifier->setVersion(version);
678  return true;
 676 recordIdentifier->reset(encodeIDBKey(key), version);
679677}
680678
681679void IDBBackingStore::clearObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId)

@@void IDBBackingStore::clearObjectStore(IDBBackingStore::Transaction* transaction
688686 deleteRange(levelDBTransaction, startKey, stopKey);
689687}
690688
691 void IDBBackingStore::deleteRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier* recordIdentifier)
 689void IDBBackingStore::deleteRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier& recordIdentifier)
692690{
693691 IDB_TRACE("IDBBackingStore::deleteRecord");
694692 LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
695693
696  const Vector<char> objectStoreDataKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, recordIdentifier->primaryKey());
 694 const Vector<char> objectStoreDataKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, recordIdentifier.primaryKey());
697695 levelDBTransaction->remove(objectStoreDataKey);
698696
699  const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, recordIdentifier->primaryKey());
 697 const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, recordIdentifier.primaryKey());
700698 levelDBTransaction->remove(existsEntryKey);
701699}
702700

@@int64_t IDBBackingStore::getKeyGeneratorCurrentNumber(IDBBackingStore::Transacti
743741 return keyGeneratorCurrentNumber;
744742}
745743
746 bool IDBBackingStore::maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent)
 744void IDBBackingStore::maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent)
747745{
748746 LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
749747
750748 if (checkCurrent) {
751749 int64_t currentNumber = getKeyGeneratorCurrentNumber(transaction, databaseId, objectStoreId);
752750 if (newNumber <= currentNumber)
753  return true;
 751 return;
754752 }
755753
756754 const Vector<char> keyGeneratorCurrentNumberKey = ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::KeyGeneratorCurrentNumber);
757755 putInt(levelDBTransaction, keyGeneratorCurrentNumberKey, newNumber);
758  return true;
759756}
760757
761758bool IDBBackingStore::keyExistsInObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, RecordIdentifier* foundRecordIdentifier)

@@bool IDBBackingStore::keyExistsInObjectStore(IDBBackingStore::Transaction* trans
772769 if (!decodeVarInt(data.begin(), data.end(), version))
773770 return false;
774771
775  foundRecordIdentifier->setPrimaryKey(encodeIDBKey(key));
776  foundRecordIdentifier->setVersion(version);
 772 foundRecordIdentifier->reset(encodeIDBKey(key), version);
777773 return true;
778774}
779775

@@void IDBBackingStore::deleteIndex(IDBBackingStore::Transaction* transaction, int
897893 deleteRange(levelDBTransaction, indexDataStart, indexDataEnd);
898894}
899895
900 bool IDBBackingStore::putIndexDataForRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const RecordIdentifier* recordIdentifier)
 896void IDBBackingStore::putIndexDataForRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const RecordIdentifier& recordIdentifier)
901897{
902898 IDB_TRACE("IDBBackingStore::putIndexDataForRecord");
903899 ASSERT(key.isValid());
904900 ASSERT(indexId >= MinimumIndexId);
905901
906902 LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
907  const Vector<char> indexDataKey = IndexDataKey::encode(databaseId, objectStoreId, indexId, encodeIDBKey(key), recordIdentifier->primaryKey());
 903 const Vector<char> indexDataKey = IndexDataKey::encode(databaseId, objectStoreId, indexId, encodeIDBKey(key), recordIdentifier.primaryKey());
908904
909905 Vector<char> data;
910  data.append(encodeVarInt(recordIdentifier->version()));
911  data.append(recordIdentifier->primaryKey());
 906 data.append(encodeVarInt(recordIdentifier.version()));
 907 data.append(recordIdentifier.primaryKey());
912908
913909 levelDBTransaction->put(indexDataKey, data);
914  return true;
915910}
916911
917912static bool findGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction, const Vector<char>& target, Vector<char>& foundKey)

@@static bool findGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction, cons
942937 return true;
943938}
944939
945 bool IDBBackingStore::deleteIndexDataForRecord(IDBBackingStore::Transaction*, int64_t, int64_t, int64_t, const RecordIdentifier*)
946 {
947  // FIXME: This isn't needed since we invalidate index data via the version number mechanism.
948  return true;
949 }
950 
951940static bool versionExists(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t version, const Vector<char>& encodedPrimaryKey)
952941{
953942 const Vector<char> key = ExistsEntryKey::encode(databaseId, objectStoreId, encodedPrimaryKey);

@@public:
11881177
11891178 // IDBBackingStore::Cursor
11901179 virtual String value() const { ASSERT_NOT_REACHED(); return String(); }
1191  virtual PassRefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier() OVERRIDE
1192  {
1193  return m_identifier;
1194  }
11951180 virtual bool loadCurrentRow();
11961181
11971182private:

@@private:
12051190 {
12061191 }
12071192
1208  RefPtr<IDBBackingStore::RecordIdentifier> m_identifier;
12091193};
12101194
12111195bool ObjectStoreKeyCursorImpl::loadCurrentRow()

@@bool ObjectStoreKeyCursorImpl::loadCurrentRow()
12301214 }
12311215
12321216 // FIXME: This re-encodes what was just decoded; try and optimize.
1233  m_identifier = IDBBackingStore::RecordIdentifier::create(encodeIDBKey(*m_currentKey), version);
 1217 m_recordIdentifier.reset(encodeIDBKey(*m_currentKey), version);
12341218
12351219 return true;
12361220}

@@public:
12491233
12501234 // IDBBackingStore::Cursor
12511235 virtual String value() const { return m_currentValue; }
1252  virtual PassRefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier() OVERRIDE
1253  {
1254  return m_identifier;
1255  }
12561236 virtual bool loadCurrentRow();
12571237
12581238private:

@@private:
12681248 }
12691249
12701250 String m_currentValue;
1271  RefPtr<IDBBackingStore::RecordIdentifier> m_identifier;
12721251};
12731252
12741253bool ObjectStoreCursorImpl::loadCurrentRow()

@@bool ObjectStoreCursorImpl::loadCurrentRow()
12931272 }
12941273
12951274 // FIXME: This re-encodes what was just decoded; try and optimize.
1296  m_identifier = IDBBackingStore::RecordIdentifier::create(encodeIDBKey(*m_currentKey), version);
 1275 m_recordIdentifier.reset(encodeIDBKey(*m_currentKey), version);
12971276
12981277 m_currentValue = decodeString(valuePosition, m_iterator->value().end());
12991278

@@public:
13151294 // IDBBackingStore::Cursor
13161295 virtual String value() const { ASSERT_NOT_REACHED(); return String(); }
13171296 virtual PassRefPtr<IDBKey> primaryKey() const { return m_primaryKey; }
1318  virtual PassRefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier() { ASSERT_NOT_REACHED(); return 0; }
 1297 virtual const IDBBackingStore::RecordIdentifier& recordIdentifier() const { ASSERT_NOT_REACHED(); return m_recordIdentifier; }
13191298 virtual bool loadCurrentRow();
13201299
13211300private:

@@public:
13941373 // IDBBackingStore::Cursor
13951374 virtual String value() const { return m_value; }
13961375 virtual PassRefPtr<IDBKey> primaryKey() const { return m_primaryKey; }
1397  virtual PassRefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier() { ASSERT_NOT_REACHED(); return 0; }
 1376 virtual const IDBBackingStore::RecordIdentifier& recordIdentifier() const { ASSERT_NOT_REACHED(); return m_recordIdentifier; }
13981377 bool loadCurrentRow();
13991378
14001379private:

Source/WebCore/Modules/indexeddb/IDBBackingStore.h

@@public:
6161 virtual bool createObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement);
6262 virtual void deleteObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId);
6363
64  class RecordIdentifier : public RefCounted<RecordIdentifier> {
 64 class RecordIdentifier {
6565 public:
66  static PassRefPtr<RecordIdentifier> create(const Vector<char>& primaryKey, int64_t version) { return adoptRef(new RecordIdentifier(primaryKey, version)); }
67  static PassRefPtr<RecordIdentifier> create() { return adoptRef(new RecordIdentifier()); }
68  virtual ~RecordIdentifier() { }
 66 RecordIdentifier(const Vector<char>& primaryKey, int64_t version) : m_primaryKey(primaryKey), m_version(version) { ASSERT(!primaryKey.isEmpty()); }
 67 RecordIdentifier() : m_primaryKey(), m_version(-1) { }
6968
70  virtual bool isValid() const { return m_primaryKey.isEmpty(); }
71  Vector<char> primaryKey() const { return m_primaryKey; }
72  void setPrimaryKey(const Vector<char>& primaryKey) { m_primaryKey = primaryKey; }
 69 const Vector<char> primaryKey() const { return m_primaryKey; }
7370 int64_t version() const { return m_version; }
74  void setVersion(int64_t version) { m_version = version; }
 71 void reset(const Vector<char>& primaryKey, int64_t version) { m_primaryKey = primaryKey; m_version = version; }
7572
7673 private:
77  RecordIdentifier(const Vector<char>& primaryKey, int64_t version) : m_primaryKey(primaryKey), m_version(version) { ASSERT(!primaryKey.isEmpty()); }
78  RecordIdentifier() : m_primaryKey(), m_version(-1) { }
79 
8074 Vector<char> m_primaryKey; // FIXME: Make it more clear that this is the *encoded* version of the key.
8175 int64_t m_version;
 76 DISALLOW_COPY_AND_ASSIGN(RecordIdentifier);
8277 };
8378
8479 virtual String getRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&);
85  virtual bool putRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*);
 80 virtual void putRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*);
8681 virtual void clearObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId);
87  virtual void deleteRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier*);
 82 virtual void deleteRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier&);
8883 virtual int64_t getKeyGeneratorCurrentNumber(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId);
89  virtual bool maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newState, bool checkCurrent);
 84 virtual void maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newState, bool checkCurrent);
9085 virtual bool keyExistsInObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RecordIdentifier* foundRecordIdentifier);
9186
9287 virtual Vector<IDBIndexMetadata> getIndexes(int64_t databaseId, int64_t objectStoreId);
9388 virtual bool createIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry);
9489 virtual void deleteIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId);
95  virtual bool putIndexDataForRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier*);
96  virtual bool deleteIndexDataForRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const RecordIdentifier*);
 90 virtual void putIndexDataForRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier&);
9791 virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&);
9892 virtual bool keyExistsInIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey);
9993

@@public:
113107 bool unique;
114108 };
115109
116  Cursor(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
117  : m_transaction(transaction)
118  , m_cursorOptions(cursorOptions)
119  {
120  }
121  explicit Cursor(const IDBBackingStore::Cursor* other);
122 
123110 PassRefPtr<IDBKey> key() const { return m_currentKey; }
124111 bool continueFunction(const IDBKey* = 0, IteratorState = Seek);
125112 bool advance(unsigned long);

@@public:
128115 virtual PassRefPtr<Cursor> clone() = 0;
129116 virtual PassRefPtr<IDBKey> primaryKey() const { return m_currentKey; }
130117 virtual String value() const = 0;
131  virtual PassRefPtr<RecordIdentifier> recordIdentifier() = 0;
 118 virtual const RecordIdentifier& recordIdentifier() const { return m_recordIdentifier; }
132119 virtual ~Cursor() { }
133120 virtual bool loadCurrentRow() = 0;
134121
135122 protected:
 123 Cursor(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
 124 : m_transaction(transaction)
 125 , m_cursorOptions(cursorOptions)
 126 {
 127 }
 128 explicit Cursor(const IDBBackingStore::Cursor* other);
 129
136130 bool isPastBounds() const;
137131 bool haveEnteredRange() const;
138132

@@public:
140134 const CursorOptions m_cursorOptions;
141135 OwnPtr<LevelDBIterator> m_iterator;
142136 RefPtr<IDBKey> m_currentKey;
 137 IDBBackingStore::RecordIdentifier m_recordIdentifier;
143138 };
144139
145140 virtual PassRefPtr<Cursor> openObjectStoreKeyCursor(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction);

Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp

@@public:
155155 return true;
156156 }
157157
158  bool writeIndexKeys(const IDBBackingStore::RecordIdentifier* recordIdentifier, IDBBackingStore& backingStore, IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId) const
 158 void writeIndexKeys(const IDBBackingStore::RecordIdentifier& recordIdentifier, IDBBackingStore& backingStore, IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId) const
159159 {
160160 int64_t indexId = m_indexMetadata.id;
161161 for (size_t i = 0; i < m_indexKeys.size(); ++i) {
162  if (!backingStore.deleteIndexDataForRecord(transaction, databaseId, objectStoreId, indexId, recordIdentifier))
163  return false;
164  if (!backingStore.putIndexDataForRecord(transaction, databaseId, objectStoreId, indexId, *(m_indexKeys)[i].get(), recordIdentifier))
165  return false;
 162 backingStore.putIndexDataForRecord(transaction, databaseId, objectStoreId, indexId, *(m_indexKeys)[i].get(), recordIdentifier);
166163 }
167  return true;
168164 }
169165
170166private:

@@void IDBObjectStoreBackendImpl::setIndexKeys(PassRefPtr<IDBKey> prpPrimaryKey, c
232228 RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr);
233229
234230 // FIXME: This method could be asynchronous, but we need to evaluate if it's worth the extra complexity.
235  RefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier = IDBBackingStore::RecordIdentifier::create();
236  if (!backingStore()->keyExistsInObjectStore(transaction->backingStoreTransaction(), databaseId(), id(), *primaryKey, recordIdentifier.get())) {
 231 IDBBackingStore::RecordIdentifier recordIdentifier;
 232 if (!backingStore()->keyExistsInObjectStore(transaction->backingStoreTransaction(), databaseId(), id(), *primaryKey, &recordIdentifier)) {
237233 transaction->abort();
238234 return;
239235 }

@@void IDBObjectStoreBackendImpl::setIndexKeys(PassRefPtr<IDBKey> prpPrimaryKey, c
248244
249245 for (size_t i = 0; i < indexWriters.size(); ++i) {
250246 IndexWriter* indexWriter = indexWriters[i].get();
251  if (!indexWriter->writeIndexKeys(recordIdentifier.get(), *backingStore(), transaction->backingStoreTransaction(), databaseId(), m_metadata.id)) {
252  transaction->abort();
253  return;
254  }
 247 indexWriter->writeIndexKeys(recordIdentifier, *backingStore(), transaction->backingStoreTransaction(), databaseId(), m_metadata.id);
255248 }
256249}
257250

@@void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr<
303296
304297 ASSERT(key && key->isValid());
305298
306  RefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier = IDBBackingStore::RecordIdentifier::create();
307  if (putMode == AddOnly && objectStore->backingStore()->keyExistsInObjectStore(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key, recordIdentifier.get())) {
 299 IDBBackingStore::RecordIdentifier recordIdentifier;
 300 if (putMode == AddOnly && objectStore->backingStore()->keyExistsInObjectStore(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key, &recordIdentifier)) {
308301 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "Key already exists in the object store."));
309302 return;
310303 }

@@void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr<
318311
319312 // Before this point, don't do any mutation. After this point, rollback the transaction in case of error.
320313
321  if (!objectStore->backingStore()->putRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key, value->toWireString(), recordIdentifier.get())) {
322  RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.");
323  callbacks->onError(error);
324  transaction->abort(error);
325  return;
326  }
 314 objectStore->backingStore()->putRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key, value->toWireString(), &recordIdentifier);
327315
328316 for (size_t i = 0; i < indexWriters.size(); ++i) {
329317 IndexWriter* indexWriter = indexWriters[i].get();
330  if (!indexWriter->writeIndexKeys(recordIdentifier.get(), *objectStore->backingStore(), transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->m_metadata.id)) {
331 
332  RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.");
333  callbacks->onError(error);
334  transaction->abort(error);
335  return;
336  }
 318 indexWriter->writeIndexKeys(recordIdentifier, *objectStore->backingStore(), transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->m_metadata.id);
337319 }
338320
339321 if (autoIncrement && putMode != CursorUpdate && key->type() == IDBKey::NumberType)

@@void IDBObjectStoreBackendImpl::deleteFunction(PassRefPtr<IDBKeyRange> prpKeyRan
361343void IDBObjectStoreBackendImpl::deleteInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBKeyRange> keyRange, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBTransactionBackendImpl> transaction)
362344{
363345 IDB_TRACE("IDBObjectStoreBackendImpl::deleteInternal");
364  RefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier;
365346
366347 RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->backingStore()->openObjectStoreCursor(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), keyRange.get(), IDBCursor::NEXT);
367348 if (backingStoreCursor) {
368349
369350 do {
370  recordIdentifier = backingStoreCursor->recordIdentifier();
371 
372  for (IDBObjectStoreBackendImpl::IndexMap::iterator it = objectStore->m_indexes.begin(); it != objectStore->m_indexes.end(); ++it) {
373  bool success = objectStore->backingStore()->deleteIndexDataForRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), it->key, recordIdentifier.get());
374  ASSERT_UNUSED(success, success);
375  }
376 
377  objectStore->backingStore()->deleteRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), recordIdentifier.get());
 351 objectStore->backingStore()->deleteRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), backingStoreCursor->recordIdentifier());
378352
379353 } while (backingStoreCursor->continueFunction(0));
380354 }

Source/WebKit/chromium/tests/IDBFakeBackingStore.h

@@public:
4444 virtual void deleteObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { }
4545
4646 virtual String getRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&) OVERRIDE { return String(); }
47  virtual bool putRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*) OVERRIDE { return false; }
 47 virtual void putRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*) OVERRIDE { }
4848 virtual void clearObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { }
49  virtual void deleteRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier*) OVERRIDE { }
 49 virtual void deleteRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier&) OVERRIDE { }
5050 virtual int64_t getKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { return 0; }
51  virtual bool maybeUpdateKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent) OVERRIDE { return false; }
 51 virtual void maybeUpdateKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent) OVERRIDE { }
5252 virtual bool keyExistsInObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RecordIdentifier* foundRecordIdentifier) OVERRIDE { return false; }
5353
5454 virtual Vector<IDBIndexMetadata> getIndexes(int64_t databaseId, int64_t objectStoreId) OVERRIDE { return Vector<IDBIndexMetadata>(); }
5555 virtual bool createIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry) OVERRIDE { return false; };
5656 virtual void deleteIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE { }
57  virtual bool putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier*) OVERRIDE { return false; }
58  virtual bool deleteIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const RecordIdentifier*) OVERRIDE { return false; }
 57 virtual void putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier&) OVERRIDE { }
5958 virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) OVERRIDE { return PassRefPtr<IDBKey>(); }
6059 virtual bool keyExistsInIndex(Transaction*, int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey) OVERRIDE { return false; }
6160