| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 SetupMetadata, | 64 SetupMetadata, |
| 65 GetPrimaryKeyViaIndex, | 65 GetPrimaryKeyViaIndex, |
| 66 KeyExistsInIndex, | 66 KeyExistsInIndex, |
| 67 VersionExists, | 67 VersionExists, |
| 68 DeleteObjectStore, | 68 DeleteObjectStore, |
| 69 SetMaxObjectStoreId, | 69 SetMaxObjectStoreId, |
| 70 SetMaxIndexId, | 70 SetMaxIndexId, |
| 71 GetNewDatabaseId, | 71 GetNewDatabaseId, |
| 72 GetNewVersionNumber, | 72 GetNewVersionNumber, |
| 73 CreateIDBDatabaseMetaData, | 73 CreateIDBDatabaseMetaData, |
| 74 DeleteDatabase, |
| 75 TransactionCommit, |
| 74 IDBLevelDBBackingStoreInternalErrorMax, | 76 IDBLevelDBBackingStoreInternalErrorMax, |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 static void recordInternalError(const char* type, IDBBackingStoreErrorSource loc
ation) | 79 static void recordInternalError(const char* type, IDBBackingStoreErrorSource loc
ation) |
| 78 { | 80 { |
| 79 String name = String::format("WebCore.IndexedDB.BackingStore.%sError", type)
; | 81 String name = String::format("WebCore.IndexedDB.BackingStore.%sError", type)
; |
| 80 HistogramSupport::histogramEnumeration(name.utf8().data(), location, IDBLeve
lDBBackingStoreInternalErrorMax); | 82 HistogramSupport::histogramEnumeration(name.utf8().data(), location, IDBLeve
lDBBackingStoreInternalErrorMax); |
| 81 } | 83 } |
| 82 | 84 |
| 83 // Use to signal conditions that usually indicate developer error, but could be
caused by data corruption. | 85 // Use to signal conditions that usually indicate developer error, but could be
caused by data corruption. |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 582 |
| 581 const Vector<char> startKey = DatabaseMetaDataKey::encode(metadata.id, Datab
aseMetaDataKey::OriginName); | 583 const Vector<char> startKey = DatabaseMetaDataKey::encode(metadata.id, Datab
aseMetaDataKey::OriginName); |
| 582 const Vector<char> stopKey = DatabaseMetaDataKey::encode(metadata.id + 1, Da
tabaseMetaDataKey::OriginName); | 584 const Vector<char> stopKey = DatabaseMetaDataKey::encode(metadata.id + 1, Da
tabaseMetaDataKey::OriginName); |
| 583 OwnPtr<LevelDBIterator> it = m_db->createIterator(); | 585 OwnPtr<LevelDBIterator> it = m_db->createIterator(); |
| 584 for (it->seek(startKey); it->isValid() && compareKeys(it->key(), stopKey) <
0; it->next()) | 586 for (it->seek(startKey); it->isValid() && compareKeys(it->key(), stopKey) <
0; it->next()) |
| 585 transaction->remove(it->key()); | 587 transaction->remove(it->key()); |
| 586 | 588 |
| 587 const Vector<char> key = DatabaseNameKey::encode(m_identifier, name); | 589 const Vector<char> key = DatabaseNameKey::encode(m_identifier, name); |
| 588 transaction->remove(key); | 590 transaction->remove(key); |
| 589 | 591 |
| 590 return transaction->commit(); | 592 if (!transaction->commit()) { |
| 593 INTERNAL_WRITE_ERROR(DeleteDatabase); |
| 594 return false; |
| 595 } |
| 596 return true; |
| 591 } | 597 } |
| 592 | 598 |
| 593 static bool checkObjectStoreAndMetaDataType(const LevelDBIterator* it, const Vec
tor<char>& stopKey, int64_t objectStoreId, int64_t metaDataType) | 599 static bool checkObjectStoreAndMetaDataType(const LevelDBIterator* it, const Vec
tor<char>& stopKey, int64_t objectStoreId, int64_t metaDataType) |
| 594 { | 600 { |
| 595 if (!it->isValid() || compareKeys(it->key(), stopKey) >= 0) | 601 if (!it->isValid() || compareKeys(it->key(), stopKey) >= 0) |
| 596 return false; | 602 return false; |
| 597 | 603 |
| 598 ObjectStoreMetaDataKey metaDataKey; | 604 ObjectStoreMetaDataKey metaDataKey; |
| 599 const char* p = ObjectStoreMetaDataKey::decode(it->key().begin(), it->key().
end(), &metaDataKey); | 605 const char* p = ObjectStoreMetaDataKey::decode(it->key().begin(), it->key().
end(), &metaDataKey); |
| 600 ASSERT_UNUSED(p, p); | 606 ASSERT_UNUSED(p, p); |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 ASSERT(!m_transaction); | 1842 ASSERT(!m_transaction); |
| 1837 m_transaction = LevelDBTransaction::create(m_backingStore->m_db.get()); | 1843 m_transaction = LevelDBTransaction::create(m_backingStore->m_db.get()); |
| 1838 } | 1844 } |
| 1839 | 1845 |
| 1840 bool IDBBackingStore::Transaction::commit() | 1846 bool IDBBackingStore::Transaction::commit() |
| 1841 { | 1847 { |
| 1842 IDB_TRACE("IDBBackingStore::Transaction::commit"); | 1848 IDB_TRACE("IDBBackingStore::Transaction::commit"); |
| 1843 ASSERT(m_transaction); | 1849 ASSERT(m_transaction); |
| 1844 bool result = m_transaction->commit(); | 1850 bool result = m_transaction->commit(); |
| 1845 m_transaction.clear(); | 1851 m_transaction.clear(); |
| 1852 if (!result) |
| 1853 INTERNAL_WRITE_ERROR(TransactionCommit); |
| 1846 return result; | 1854 return result; |
| 1847 } | 1855 } |
| 1848 | 1856 |
| 1849 void IDBBackingStore::Transaction::rollback() | 1857 void IDBBackingStore::Transaction::rollback() |
| 1850 { | 1858 { |
| 1851 IDB_TRACE("IDBBackingStore::Transaction::rollback"); | 1859 IDB_TRACE("IDBBackingStore::Transaction::rollback"); |
| 1852 ASSERT(m_transaction); | 1860 ASSERT(m_transaction); |
| 1853 m_transaction->rollback(); | 1861 m_transaction->rollback(); |
| 1854 m_transaction.clear(); | 1862 m_transaction.clear(); |
| 1855 } | 1863 } |
| 1856 | 1864 |
| 1857 } // namespace WebCore | 1865 } // namespace WebCore |
| 1858 | 1866 |
| 1859 #endif // ENABLE(INDEXED_DATABASE) | 1867 #endif // ENABLE(INDEXED_DATABASE) |
| OLD | NEW |