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

Unified Diff: content/browser/indexed_db/leveldb/leveldb_transaction.cc

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle the rest of Josh's feedback. Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/leveldb/leveldb_transaction.cc
diff --git a/content/browser/indexed_db/leveldb/leveldb_transaction.cc b/content/browser/indexed_db/leveldb/leveldb_transaction.cc
index 0c3619465bb8545f709ab6bca486d671dc20143e..28342591fdde928dd1d6d0b27be0e3461965dbcf 100644
--- a/content/browser/indexed_db/leveldb/leveldb_transaction.cc
+++ b/content/browser/indexed_db/leveldb/leveldb_transaction.cc
@@ -423,24 +423,44 @@ void LevelDBTransaction::NotifyIterators() {
}
}
-scoped_ptr<LevelDBWriteOnlyTransaction> LevelDBWriteOnlyTransaction::Create(
+scoped_ptr<LevelDBUncachedTransaction> LevelDBUncachedTransaction::Create(
LevelDBDatabase* db) {
- return make_scoped_ptr(new LevelDBWriteOnlyTransaction(db));
+ return make_scoped_ptr(new LevelDBUncachedTransaction(db));
}
-LevelDBWriteOnlyTransaction::LevelDBWriteOnlyTransaction(LevelDBDatabase* db)
+LevelDBUncachedTransaction::LevelDBUncachedTransaction(LevelDBDatabase* db)
: db_(db), write_batch_(LevelDBWriteBatch::Create()), finished_(false) {}
-LevelDBWriteOnlyTransaction::~LevelDBWriteOnlyTransaction() {
+LevelDBUncachedTransaction::~LevelDBUncachedTransaction() {
write_batch_->Clear();
}
-void LevelDBWriteOnlyTransaction::Remove(const StringPiece& key) {
+void LevelDBUncachedTransaction::Put(const StringPiece& key,
+ const std::string* value) {
+ DCHECK(!finished_);
+ write_batch_->Put(key, *value);
+}
+
+bool LevelDBUncachedTransaction::Get(const StringPiece& key,
+ std::string* value,
+ bool* found) {
+ *found = false;
+ DCHECK(!finished_);
+
+ bool ok = db_->Get(key, value, found);
+ if (!ok) {
+ DCHECK(!found);
jsbell 2013/12/20 00:44:20 How about: DCHECK(ok || !found); return ok;
ericu 2014/02/20 00:50:29 That's nicer, thanks.
+ return false;
+ }
+ return true;
+}
+
+void LevelDBUncachedTransaction::Remove(const StringPiece& key) {
DCHECK(!finished_);
write_batch_->Remove(key);
}
-bool LevelDBWriteOnlyTransaction::Commit() {
+bool LevelDBUncachedTransaction::Commit() {
DCHECK(!finished_);
if (!db_->Write(*write_batch_))

Powered by Google App Engine
This is Rietveld 408576698