OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
16 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" | 16 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" |
17 #include "content/browser/indexed_db/leveldb/leveldb_database.h" | 17 #include "content/browser/indexed_db/leveldb/leveldb_database.h" |
18 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" | 18 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 class LevelDBWriteBatch; | 22 class LevelDBWriteBatch; |
23 | 23 |
24 class CONTENT_EXPORT LevelDBTransaction | 24 class CONTENT_EXPORT LevelDBTransaction |
25 : public base::RefCounted<LevelDBTransaction> { | 25 : public base::RefCounted<LevelDBTransaction> { |
26 public: | 26 public: |
27 | 27 |
28 void Put(const base::StringPiece& key, std::string* value); | 28 void Put(const base::StringPiece& key, std::string* value); |
29 void Remove(const base::StringPiece& key); | 29 void Remove(const base::StringPiece& key); |
30 leveldb::Status Get(const base::StringPiece& key, | 30 virtual leveldb::Status Get(const base::StringPiece& key, |
31 std::string* value, | 31 std::string* value, |
32 bool* found); | 32 bool* found); |
33 leveldb::Status Commit(); | 33 virtual leveldb::Status Commit(); |
34 void Rollback(); | 34 void Rollback(); |
35 | 35 |
36 scoped_ptr<LevelDBIterator> CreateIterator(); | 36 scoped_ptr<LevelDBIterator> CreateIterator(); |
37 | 37 |
38 private: | 38 protected: |
39 virtual ~LevelDBTransaction(); | 39 virtual ~LevelDBTransaction(); |
40 explicit LevelDBTransaction(LevelDBDatabase* db); | 40 explicit LevelDBTransaction(LevelDBDatabase* db); |
41 friend class IndexedDBClassFactory; | 41 friend class IndexedDBClassFactory; |
| 42 |
| 43 private: |
42 friend class base::RefCounted<LevelDBTransaction>; | 44 friend class base::RefCounted<LevelDBTransaction>; |
43 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, Transaction); | 45 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, Transaction); |
44 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionCommitTest); | 46 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionCommitTest); |
45 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionIterator); | 47 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionIterator); |
46 | 48 |
47 struct Record { | 49 struct Record { |
48 Record(); | 50 Record(); |
49 ~Record(); | 51 ~Record(); |
50 std::string key; | 52 std::string key; |
51 std::string value; | 53 std::string value; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 LevelDBDatabase* db_; | 168 LevelDBDatabase* db_; |
167 scoped_ptr<LevelDBWriteBatch> write_batch_; | 169 scoped_ptr<LevelDBWriteBatch> write_batch_; |
168 bool finished_; | 170 bool finished_; |
169 | 171 |
170 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); | 172 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); |
171 }; | 173 }; |
172 | 174 |
173 } // namespace content | 175 } // namespace content |
174 | 176 |
175 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 177 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
OLD | NEW |