summaryrefslogtreecommitdiffstats
path: root/chromium/content/browser/indexed_db/leveldb/leveldb_transaction.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/browser/indexed_db/leveldb/leveldb_transaction.h')
-rw-r--r--chromium/content/browser/indexed_db/leveldb/leveldb_transaction.h57
1 files changed, 40 insertions, 17 deletions
diff --git a/chromium/content/browser/indexed_db/leveldb/leveldb_transaction.h b/chromium/content/browser/indexed_db/leveldb/leveldb_transaction.h
index b7b5d64df1e..f6b5a95e121 100644
--- a/chromium/content/browser/indexed_db/leveldb/leveldb_transaction.h
+++ b/chromium/content/browser/indexed_db/leveldb/leveldb_transaction.h
@@ -9,6 +9,7 @@
#include <set>
#include <string>
+#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
@@ -23,19 +24,27 @@ class LevelDBWriteBatch;
class CONTENT_EXPORT LevelDBTransaction
: public base::RefCounted<LevelDBTransaction> {
public:
- explicit LevelDBTransaction(LevelDBDatabase* db);
void Put(const base::StringPiece& key, std::string* value);
void Remove(const base::StringPiece& key);
- bool Get(const base::StringPiece& key, std::string* value, bool* found);
- bool Commit();
+ virtual leveldb::Status Get(const base::StringPiece& key,
+ std::string* value,
+ bool* found);
+ virtual leveldb::Status Commit();
void Rollback();
scoped_ptr<LevelDBIterator> CreateIterator();
- private:
+ protected:
virtual ~LevelDBTransaction();
+ explicit LevelDBTransaction(LevelDBDatabase* db);
+ friend class IndexedDBClassFactory;
+
+ private:
friend class base::RefCounted<LevelDBTransaction>;
+ FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, Transaction);
+ FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionCommitTest);
+ FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionIterator);
struct Record {
Record();
@@ -66,10 +75,10 @@ class CONTENT_EXPORT LevelDBTransaction
virtual ~DataIterator();
virtual bool IsValid() const OVERRIDE;
- virtual void SeekToLast() OVERRIDE;
- virtual void Seek(const base::StringPiece& slice) OVERRIDE;
- virtual void Next() OVERRIDE;
- virtual void Prev() OVERRIDE;
+ virtual leveldb::Status SeekToLast() OVERRIDE;
+ virtual leveldb::Status Seek(const base::StringPiece& slice) OVERRIDE;
+ virtual leveldb::Status Next() OVERRIDE;
+ virtual leveldb::Status Prev() OVERRIDE;
virtual base::StringPiece Key() const OVERRIDE;
virtual base::StringPiece Value() const OVERRIDE;
bool IsDeleted() const;
@@ -78,6 +87,8 @@ class CONTENT_EXPORT LevelDBTransaction
explicit DataIterator(LevelDBTransaction* transaction);
DataType* data_;
DataType::iterator iterator_;
+
+ DISALLOW_COPY_AND_ASSIGN(DataIterator);
};
class TransactionIterator : public LevelDBIterator {
@@ -87,10 +98,10 @@ class CONTENT_EXPORT LevelDBTransaction
scoped_refptr<LevelDBTransaction> transaction);
virtual bool IsValid() const OVERRIDE;
- virtual void SeekToLast() OVERRIDE;
- virtual void Seek(const base::StringPiece& target) OVERRIDE;
- virtual void Next() OVERRIDE;
- virtual void Prev() OVERRIDE;
+ virtual leveldb::Status SeekToLast() OVERRIDE;
+ virtual leveldb::Status Seek(const base::StringPiece& target) OVERRIDE;
+ virtual leveldb::Status Next() OVERRIDE;
+ virtual leveldb::Status Prev() OVERRIDE;
virtual base::StringPiece Key() const OVERRIDE;
virtual base::StringPiece Value() const OVERRIDE;
void DataChanged();
@@ -116,6 +127,8 @@ class CONTENT_EXPORT LevelDBTransaction
};
Direction direction_;
mutable bool data_changed_;
+
+ DISALLOW_COPY_AND_ASSIGN(TransactionIterator);
};
void Set(const base::StringPiece& key, std::string* value, bool deleted);
@@ -131,22 +144,32 @@ class CONTENT_EXPORT LevelDBTransaction
DataType data_;
bool finished_;
std::set<TransactionIterator*> iterators_;
+
+ DISALLOW_COPY_AND_ASSIGN(LevelDBTransaction);
};
-class LevelDBWriteOnlyTransaction {
+// Reads go straight to the database, ignoring any writes cached in
+// write_batch_, and writes are write-through, without consolidation.
+class LevelDBDirectTransaction {
public:
- static scoped_ptr<LevelDBWriteOnlyTransaction> Create(LevelDBDatabase* db);
+ static scoped_ptr<LevelDBDirectTransaction> Create(LevelDBDatabase* db);
- ~LevelDBWriteOnlyTransaction();
+ ~LevelDBDirectTransaction();
+ void Put(const base::StringPiece& key, const std::string* value);
+ leveldb::Status Get(const base::StringPiece& key,
+ std::string* value,
+ bool* found);
void Remove(const base::StringPiece& key);
- bool Commit();
+ leveldb::Status Commit();
private:
- explicit LevelDBWriteOnlyTransaction(LevelDBDatabase* db);
+ explicit LevelDBDirectTransaction(LevelDBDatabase* db);
LevelDBDatabase* db_;
scoped_ptr<LevelDBWriteBatch> write_batch_;
bool finished_;
+
+ DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction);
};
} // namespace content