Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(938)

Side by Side Diff: Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp

Issue 10422005: Merge 116562 - IndexedDB: call abort handler when there are problems committing (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 const Vector<char> startKey = DatabaseMetaDataKey::encode(databaseId, Databa seMetaDataKey::kOriginName); 302 const Vector<char> startKey = DatabaseMetaDataKey::encode(databaseId, Databa seMetaDataKey::kOriginName);
303 const Vector<char> stopKey = DatabaseMetaDataKey::encode(databaseId + 1, Dat abaseMetaDataKey::kOriginName); 303 const Vector<char> stopKey = DatabaseMetaDataKey::encode(databaseId + 1, Dat abaseMetaDataKey::kOriginName);
304 if (!deleteRange(m_currentTransaction.get(), startKey, stopKey)) { 304 if (!deleteRange(m_currentTransaction.get(), startKey, stopKey)) {
305 transaction->rollback(); 305 transaction->rollback();
306 return false; 306 return false;
307 } 307 }
308 308
309 const Vector<char> key = DatabaseNameKey::encode(m_identifier, name); 309 const Vector<char> key = DatabaseNameKey::encode(m_identifier, name);
310 m_currentTransaction->remove(key); 310 m_currentTransaction->remove(key);
311 311
312 transaction->commit(); 312 return transaction->commit();
313 return true;
314 } 313 }
315 314
316 static bool checkObjectStoreAndMetaDataType(const LevelDBIterator* it, const Vec tor<char>& stopKey, int64_t objectStoreId, int64_t metaDataType) 315 static bool checkObjectStoreAndMetaDataType(const LevelDBIterator* it, const Vec tor<char>& stopKey, int64_t objectStoreId, int64_t metaDataType)
317 { 316 {
318 if (!it->isValid() || compareKeys(it->key(), stopKey) >= 0) 317 if (!it->isValid() || compareKeys(it->key(), stopKey) >= 0)
319 return false; 318 return false;
320 319
321 ObjectStoreMetaDataKey metaDataKey; 320 ObjectStoreMetaDataKey metaDataKey;
322 const char* p = ObjectStoreMetaDataKey::decode(it->key().begin(), it->key(). end(), &metaDataKey); 321 const char* p = ObjectStoreMetaDataKey::decode(it->key().begin(), it->key(). end(), &metaDataKey);
323 ASSERT_UNUSED(p, p); 322 ASSERT_UNUSED(p, p);
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 : m_backingStore(backingStore) 1567 : m_backingStore(backingStore)
1569 { 1568 {
1570 } 1569 }
1571 1570
1572 void IDBLevelDBBackingStore::Transaction::begin() 1571 void IDBLevelDBBackingStore::Transaction::begin()
1573 { 1572 {
1574 ASSERT(!m_backingStore->m_currentTransaction); 1573 ASSERT(!m_backingStore->m_currentTransaction);
1575 m_backingStore->m_currentTransaction = LevelDBTransaction::create(m_backingS tore->m_db.get()); 1574 m_backingStore->m_currentTransaction = LevelDBTransaction::create(m_backingS tore->m_db.get());
1576 } 1575 }
1577 1576
1578 void IDBLevelDBBackingStore::Transaction::commit() 1577 bool IDBLevelDBBackingStore::Transaction::commit()
1579 { 1578 {
1580 ASSERT(m_backingStore->m_currentTransaction); 1579 ASSERT(m_backingStore->m_currentTransaction);
1581 m_backingStore->m_currentTransaction->commit(); 1580 bool result = m_backingStore->m_currentTransaction->commit();
1582 m_backingStore->m_currentTransaction.clear(); 1581 m_backingStore->m_currentTransaction.clear();
1582 return result;
1583 } 1583 }
1584 1584
1585 void IDBLevelDBBackingStore::Transaction::rollback() 1585 void IDBLevelDBBackingStore::Transaction::rollback()
1586 { 1586 {
1587 ASSERT(m_backingStore->m_currentTransaction); 1587 ASSERT(m_backingStore->m_currentTransaction);
1588 m_backingStore->m_currentTransaction->rollback(); 1588 m_backingStore->m_currentTransaction->rollback();
1589 m_backingStore->m_currentTransaction.clear(); 1589 m_backingStore->m_currentTransaction.clear();
1590 } 1590 }
1591 1591
1592 bool IDBLevelDBBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String&, const String& pathBaseArg) 1592 bool IDBLevelDBBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String&, const String& pathBaseArg)
1593 { 1593 {
1594 String pathBase = pathBaseArg; 1594 String pathBase = pathBaseArg;
1595 1595
1596 if (pathBase.isEmpty()) 1596 if (pathBase.isEmpty())
1597 return false; 1597 return false;
1598 1598
1599 // FIXME: We should eventually use the same LevelDB database for all origins . 1599 // FIXME: We should eventually use the same LevelDB database for all origins .
1600 String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIde ntifier() + ".indexeddb.leveldb"); 1600 String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIde ntifier() + ".indexeddb.leveldb");
1601 1601
1602 // FIXME: this is checking for presence of the domain, not the database itse lf 1602 // FIXME: this is checking for presence of the domain, not the database itse lf
1603 return fileExists(path+"/CURRENT"); 1603 return fileExists(path+"/CURRENT");
1604 } 1604 }
1605 1605
1606 } // namespace WebCore 1606 } // namespace WebCore
1607 1607
1608 #endif // USE(LEVELDB) 1608 #endif // USE(LEVELDB)
1609 #endif // ENABLE(INDEXED_DATABASE) 1609 #endif // ENABLE(INDEXED_DATABASE)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698