WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-100700-20121029144739.patch (text/plain), 17.00 KB, created by
Joshua Bell
on 2012-10-29 14:49:12 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Joshua Bell
Created:
2012-10-29 14:49:12 PDT
Size:
17.00 KB
patch
obsolete
>Subversion Revision: 132804 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 07dede97d688b75a3407e020afb8ced614b8bc31..51c5ee26e703e56d58b0979580e6a2dbf04e1f74 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,41 @@ >+2012-10-29 Joshua Bell <jsbell@chromium.org> >+ >+ IndexedDB: Remove unused error handling clauses when writing to transaction >+ https://bugs.webkit.org/show_bug.cgi?id=100700 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Transactions are written into in-memory data structures. This can only fail if allocation >+ fails, so "success" results are always returned. Change the return types to void, and delete >+ all of the unreachable error handling code. >+ >+ No new tests - just refactoring/dead code removal. >+ >+ * Modules/indexeddb/IDBLevelDBBackingStore.cpp: >+ (WebCore::putBool): Fork into "put to database" vs. "put to transaction" variants >+ (WebCore): >+ (WebCore::putInt): Ditto. >+ (WebCore::putVarInt): Ditto. >+ (WebCore::putString): Ditto. >+ (WebCore::putIDBKeyPath): Ditto. >+ (WebCore::IDBLevelDBBackingStore::updateIDBDatabaseIntVersion): >+ (WebCore::IDBLevelDBBackingStore::updateIDBDatabaseMetaData): >+ (WebCore::deleteRange): >+ (WebCore::setMaxObjectStoreId): >+ (WebCore::IDBLevelDBBackingStore::createObjectStore): >+ (WebCore::getNewVersionNumber): >+ (WebCore::IDBLevelDBBackingStore::putObjectStoreRecord): >+ (WebCore::IDBLevelDBBackingStore::maybeUpdateKeyGeneratorCurrentNumber): >+ (WebCore::setMaxIndexId): >+ (WebCore::IDBLevelDBBackingStore::createIndex): >+ (WebCore::IDBLevelDBBackingStore::putIndexDataForRecord): >+ * platform/leveldb/LevelDBTransaction.cpp: >+ (WebCore::LevelDBTransaction::set): Return type is void. >+ (WebCore::LevelDBTransaction::put): Ditto. >+ (WebCore::LevelDBTransaction::remove): Ditto. >+ * platform/leveldb/LevelDBTransaction.h: >+ (LevelDBTransaction): >+ > 2012-10-29 Csaba Osztrogonác <ossy@webkit.org> > > [Qt] Text with zero font size renders as X px sometimes, causing fast/text/zero-font-size-2.html to fail >diff --git a/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp b/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp >index 35f5ffb192e0f72703b2b6534c23d3837b240f15..b627f9cf3b7620296eb30d2895f72d6d77458abc 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp >@@ -83,12 +83,17 @@ static bool getBool(DBOrTransaction* db, const Vector<char>& key, bool& foundBoo > return true; > } > >-template <typename DBOrTransaction> >-static bool putBool(DBOrTransaction* db, const Vector<char>& key, bool value) >+static bool putBool(LevelDBDatabase* db, const Vector<char>& key, bool value) > { > return db->put(key, encodeBool(value)); > } > >+static bool putBool(LevelDBTransaction* db, const Vector<char>& key, bool value) >+{ >+ db->put(key, encodeBool(value)); >+ return true; >+} >+ > template <typename DBOrTransaction> > static bool getInt(DBOrTransaction* db, const Vector<char>& key, int64_t& foundInt) > { >@@ -100,8 +105,7 @@ static bool getInt(DBOrTransaction* db, const Vector<char>& key, int64_t& foundI > return true; > } > >-template <typename DBOrTransaction> >-static bool putInt(DBOrTransaction* db, const Vector<char>& key, int64_t value) >+static bool putInt(LevelDBDatabase* db, const Vector<char>& key, int64_t value) > { > ASSERT(value >= 0); > if (value < 0) >@@ -109,6 +113,12 @@ static bool putInt(DBOrTransaction* db, const Vector<char>& key, int64_t value) > return db->put(key, encodeInt(value)); > } > >+static void putInt(LevelDBTransaction* db, const Vector<char>& key, int64_t value) >+{ >+ ASSERT(value >= 0); >+ db->put(key, encodeInt(value)); >+} >+ > template <typename DBOrTransaction> > static bool getVarInt(DBOrTransaction* db, const Vector<char>& key, int64_t& foundInt) > { >@@ -119,12 +129,16 @@ static bool getVarInt(DBOrTransaction* db, const Vector<char>& key, int64_t& fou > return decodeVarInt(result.begin(), result.end(), foundInt) == result.end(); > } > >-template <typename DBOrTransaction> >-static bool putVarInt(DBOrTransaction* db, const Vector<char>& key, int64_t value) >+static bool putVarInt(LevelDBDatabase* db, const Vector<char>& key, int64_t value) > { > return db->put(key, encodeVarInt(value)); > } > >+static void putVarInt(LevelDBTransaction* db, const Vector<char>& key, int64_t value) >+{ >+ db->put(key, encodeVarInt(value)); >+} >+ > template <typename DBOrTransaction> > static bool getString(DBOrTransaction* db, const Vector<char>& key, String& foundString) > { >@@ -136,20 +150,24 @@ static bool getString(DBOrTransaction* db, const Vector<char>& key, String& foun > return true; > } > >-template <typename DBOrTransaction> >-static bool putString(DBOrTransaction* db, const Vector<char> key, const String& value) >+static bool putString(LevelDBDatabase* db, const Vector<char> key, const String& value) > { >- if (!db->put(key, encodeString(value))) >- return false; >- return true; >+ return db->put(key, encodeString(value)); > } > >-template <typename DBOrTransaction> >-static bool putIDBKeyPath(DBOrTransaction* db, const Vector<char> key, const IDBKeyPath& value) >+static void putString(LevelDBTransaction* db, const Vector<char> key, const String& value) > { >- if (!db->put(key, encodeIDBKeyPath(value))) >- return false; >- return true; >+ db->put(key, encodeString(value)); >+} >+ >+static bool putIDBKeyPath(LevelDBDatabase* db, const Vector<char> key, const IDBKeyPath& value) >+{ >+ return db->put(key, encodeIDBKeyPath(value)); >+} >+ >+static void putIDBKeyPath(LevelDBTransaction* db, const Vector<char> key, const IDBKeyPath& value) >+{ >+ db->put(key, encodeIDBKeyPath(value)); > } > > static int compareKeys(const LevelDBSlice& a, const LevelDBSlice& b) >@@ -430,33 +448,21 @@ bool IDBLevelDBBackingStore::updateIDBDatabaseIntVersion(IDBBackingStore::Transa > if (intVersion == IDBDatabaseMetadata::NoIntVersion) > intVersion = IDBDatabaseMetadata::DefaultIntVersion; > ASSERT_WITH_MESSAGE(intVersion >= 0, "intVersion was %lld", static_cast<long long>(intVersion)); >- if (!putVarInt(Transaction::levelDBTransactionFrom(transaction), DatabaseMetaDataKey::encode(rowId, DatabaseMetaDataKey::UserIntVersion), intVersion)) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >+ putVarInt(Transaction::levelDBTransactionFrom(transaction), DatabaseMetaDataKey::encode(rowId, DatabaseMetaDataKey::UserIntVersion), intVersion); > return true; > } > > bool IDBLevelDBBackingStore::updateIDBDatabaseMetaData(IDBBackingStore::Transaction* transaction, int64_t rowId, const String& version) > { >- if (!putString(Transaction::levelDBTransactionFrom(transaction), DatabaseMetaDataKey::encode(rowId, DatabaseMetaDataKey::UserVersion), version)) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >+ putString(Transaction::levelDBTransactionFrom(transaction), DatabaseMetaDataKey::encode(rowId, DatabaseMetaDataKey::UserVersion), version); > return true; > } > > static bool deleteRange(LevelDBTransaction* transaction, const Vector<char>& begin, const Vector<char>& end) > { > OwnPtr<LevelDBIterator> it = transaction->createIterator(); >- for (it->seek(begin); it->isValid() && compareKeys(it->key(), end) < 0; it->next()) { >- if (!transaction->remove(it->key())) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- } >- >+ for (it->seek(begin); it->isValid() && compareKeys(it->key(), end) < 0; it->next()) >+ transaction->remove(it->key()); > return true; > } > >@@ -597,10 +603,7 @@ static bool setMaxObjectStoreId(LevelDBTransaction* transaction, int64_t databas > InternalError(IDBLevelDBBackingStoreConsistencyError); > return false; > } >- if (!putInt(transaction, maxObjectStoreIdKey, objectStoreId)) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >+ putInt(transaction, maxObjectStoreIdKey, objectStoreId); > return true; > } > >@@ -621,60 +624,15 @@ bool IDBLevelDBBackingStore::createObjectStore(IDBBackingStore::Transaction* tra > const Vector<char> keyGeneratorCurrentNumberKey = ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::KeyGeneratorCurrentNumber); > const Vector<char> namesKey = ObjectStoreNamesKey::encode(databaseId, name); > >- bool ok = putString(levelDBTransaction, nameKey, name); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putIDBKeyPath(levelDBTransaction, keyPathKey, keyPath); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putInt(levelDBTransaction, autoIncrementKey, autoIncrement); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putInt(levelDBTransaction, evictableKey, false); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putInt(levelDBTransaction, lastVersionKey, 1); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putInt(levelDBTransaction, maxIndexIdKey, MinimumIndexId); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putBool(levelDBTransaction, hasKeyPathKey, !keyPath.isNull()); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putInt(levelDBTransaction, keyGeneratorCurrentNumberKey, KeyGeneratorInitialNumber); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putInt(levelDBTransaction, namesKey, objectStoreId); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >+ putString(levelDBTransaction, nameKey, name); >+ putIDBKeyPath(levelDBTransaction, keyPathKey, keyPath); >+ putInt(levelDBTransaction, autoIncrementKey, autoIncrement); >+ putInt(levelDBTransaction, evictableKey, false); >+ putInt(levelDBTransaction, lastVersionKey, 1); >+ putInt(levelDBTransaction, maxIndexIdKey, MinimumIndexId); >+ putBool(levelDBTransaction, hasKeyPathKey, !keyPath.isNull()); >+ putInt(levelDBTransaction, keyGeneratorCurrentNumberKey, KeyGeneratorInitialNumber); >+ putInt(levelDBTransaction, namesKey, objectStoreId); > return true; > } > >@@ -759,8 +717,7 @@ static int64_t getNewVersionNumber(LevelDBTransaction* transaction, int64_t data > ASSERT(lastVersion >= 0); > > int64_t version = lastVersion + 1; >- bool ok = putInt(transaction, lastVersionKey, version); >- ASSERT_UNUSED(ok, ok); >+ putInt(transaction, lastVersionKey, version); > > ASSERT(version > lastVersion); // FIXME: Think about how we want to handle the overflow scenario. > >@@ -779,16 +736,10 @@ bool IDBLevelDBBackingStore::putObjectStoreRecord(IDBBackingStore::Transaction* > v.append(encodeVarInt(version)); > v.append(encodeString(value)); > >- if (!levelDBTransaction->put(objectStoredataKey, v)) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >+ levelDBTransaction->put(objectStoredataKey, v); > > const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, key); >- if (!levelDBTransaction->put(existsEntryKey, encodeInt(version))) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >+ levelDBTransaction->put(existsEntryKey, encodeInt(version)); > > LevelDBRecordIdentifier* levelDBRecordIdentifier = static_cast<LevelDBRecordIdentifier*>(recordIdentifier); > levelDBRecordIdentifier->setPrimaryKey(encodeIDBKey(key)); >@@ -878,11 +829,7 @@ bool IDBLevelDBBackingStore::maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStor > } > > const Vector<char> keyGeneratorCurrentNumberKey = ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::KeyGeneratorCurrentNumber); >- bool ok = putInt(levelDBTransaction, keyGeneratorCurrentNumberKey, newNumber); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >+ putInt(levelDBTransaction, keyGeneratorCurrentNumberKey, newNumber); > return true; > } > >@@ -1022,10 +969,7 @@ static bool setMaxIndexId(LevelDBTransaction* transaction, int64_t databaseId, i > return false; > } > >- if (!putInt(transaction, maxIndexIdKey, indexId)) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >+ putInt(transaction, maxIndexIdKey, indexId); > return true; > } > >@@ -1041,30 +985,10 @@ bool IDBLevelDBBackingStore::createIndex(IDBBackingStore::Transaction* transacti > const Vector<char> keyPathKey = IndexMetaDataKey::encode(databaseId, objectStoreId, indexId, IndexMetaDataKey::KeyPath); > const Vector<char> multiEntryKey = IndexMetaDataKey::encode(databaseId, objectStoreId, indexId, IndexMetaDataKey::MultiEntry); > >- bool ok = putString(levelDBTransaction, nameKey, name); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putBool(levelDBTransaction, uniqueKey, isUnique); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putIDBKeyPath(levelDBTransaction, keyPathKey, keyPath); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >- ok = putBool(levelDBTransaction, multiEntryKey, isMultiEntry); >- if (!ok) { >- InternalError(IDBLevelDBBackingStoreWriteError); >- return false; >- } >- >+ putString(levelDBTransaction, nameKey, name); >+ putBool(levelDBTransaction, uniqueKey, isUnique); >+ putIDBKeyPath(levelDBTransaction, keyPathKey, keyPath); >+ putBool(levelDBTransaction, multiEntryKey, isMultiEntry); > return true; > } > >@@ -1104,7 +1028,8 @@ bool IDBLevelDBBackingStore::putIndexDataForRecord(IDBBackingStore::Transaction* > data.append(encodeVarInt(levelDBRecordIdentifier->version())); > data.append(levelDBRecordIdentifier->primaryKey()); > >- return levelDBTransaction->put(indexDataKey, data); >+ levelDBTransaction->put(indexDataKey, data); >+ return true; > } > > static bool findGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction, const Vector<char>& target, Vector<char>& foundKey) >diff --git a/Source/WebCore/platform/leveldb/LevelDBTransaction.cpp b/Source/WebCore/platform/leveldb/LevelDBTransaction.cpp >index 8fe3fd08edb279bce38450d5c7b9bba017475953..bf5ccbb7f802a456a82d6fd58134f9f94497bb9e 100644 >--- a/Source/WebCore/platform/leveldb/LevelDBTransaction.cpp >+++ b/Source/WebCore/platform/leveldb/LevelDBTransaction.cpp >@@ -76,7 +76,7 @@ static void initVector(const LevelDBSlice& slice, Vector<char>* vector) > vector->append(slice.begin(), slice.end() - slice.begin()); > } > >-bool LevelDBTransaction::set(const LevelDBSlice& key, const Vector<char>& value, bool deleted) >+void LevelDBTransaction::set(const LevelDBSlice& key, const Vector<char>& value, bool deleted) > { > ASSERT(!m_finished); > bool newNode = false; >@@ -93,17 +93,16 @@ bool LevelDBTransaction::set(const LevelDBSlice& key, const Vector<char>& value, > > if (newNode) > notifyIteratorsOfTreeChange(); >- return true; > } > >-bool LevelDBTransaction::put(const LevelDBSlice& key, const Vector<char>& value) >+void LevelDBTransaction::put(const LevelDBSlice& key, const Vector<char>& value) > { >- return set(key, value, false); >+ set(key, value, false); > } > >-bool LevelDBTransaction::remove(const LevelDBSlice& key) >+void LevelDBTransaction::remove(const LevelDBSlice& key) > { >- return set(key, Vector<char>(), true); >+ set(key, Vector<char>(), true); > } > > bool LevelDBTransaction::get(const LevelDBSlice& key, Vector<char>& value) >diff --git a/Source/WebCore/platform/leveldb/LevelDBTransaction.h b/Source/WebCore/platform/leveldb/LevelDBTransaction.h >index 80a335d47a010af4d382a5f15a19459173744f5f..85b734ff04cfceb9cb6352f2729b2d54320c1092 100644 >--- a/Source/WebCore/platform/leveldb/LevelDBTransaction.h >+++ b/Source/WebCore/platform/leveldb/LevelDBTransaction.h >@@ -52,8 +52,8 @@ public: > static PassRefPtr<LevelDBTransaction> create(LevelDBDatabase*); > > ~LevelDBTransaction(); >- bool put(const LevelDBSlice& key, const Vector<char>& value); >- bool remove(const LevelDBSlice& key); >+ void put(const LevelDBSlice& key, const Vector<char>& value); >+ void remove(const LevelDBSlice& key); > bool get(const LevelDBSlice& key, Vector<char>& value); > bool commit(); > void rollback(); >@@ -157,7 +157,7 @@ private: > mutable bool m_treeChanged; > }; > >- bool set(const LevelDBSlice& key, const Vector<char>& value, bool deleted); >+ void set(const LevelDBSlice& key, const Vector<char>& value, bool deleted); > void clearTree(); > void registerIterator(TransactionIterator*); > void unregisterIterator(TransactionIterator*);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 100700
:
171315
|
171486
|
171492
|
172443
|
173098