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

Side by Side Diff: content/browser/indexed_db/leveldb/leveldb_transaction.h

Issue 2904603003: [IndexedDB] Adding txn, value, and key size metrics (Closed)
Patch Set: made sure size is 0'd out Created 3 years, 6 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 // 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 <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 22 matching lines...) Expand all
33 bool upper_open); 33 bool upper_open);
34 34
35 virtual leveldb::Status Get(const base::StringPiece& key, 35 virtual leveldb::Status Get(const base::StringPiece& key,
36 std::string* value, 36 std::string* value,
37 bool* found); 37 bool* found);
38 virtual leveldb::Status Commit(); 38 virtual leveldb::Status Commit();
39 void Rollback(); 39 void Rollback();
40 40
41 std::unique_ptr<LevelDBIterator> CreateIterator(); 41 std::unique_ptr<LevelDBIterator> CreateIterator();
42 42
43 uint64_t GetTransactionSize() const { return size_; }
44
43 protected: 45 protected:
44 virtual ~LevelDBTransaction(); 46 virtual ~LevelDBTransaction();
45 explicit LevelDBTransaction(LevelDBDatabase* db); 47 explicit LevelDBTransaction(LevelDBDatabase* db);
46 friend class IndexedDBClassFactory; 48 friend class IndexedDBClassFactory;
47 49
48 private: 50 private:
49 friend class base::RefCounted<LevelDBTransaction>; 51 friend class base::RefCounted<LevelDBTransaction>;
50 friend class LevelDBTransactionRangeTest; 52 friend class LevelDBTransactionRangeTest;
51 friend class LevelDBTransactionTest; 53 friend class LevelDBTransactionTest;
52 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, GetAndPut); 54 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, GetPutDelete);
53 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, Commit); 55 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, Commit);
54 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, Iterator); 56 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, Iterator);
55 57
56 struct Record { 58 struct Record {
57 Record(); 59 Record();
58 ~Record(); 60 ~Record();
59 std::string key; 61 std::string key;
60 std::string value; 62 std::string value;
61 bool deleted = false; 63 bool deleted = false;
62 }; 64 };
65 static constexpr uint64_t SizeOfRecordInMap(size_t key_size);
63 66
64 class Comparator { 67 class Comparator {
65 public: 68 public:
66 explicit Comparator(const LevelDBComparator* comparator) 69 explicit Comparator(const LevelDBComparator* comparator)
67 : comparator_(comparator) {} 70 : comparator_(comparator) {}
68 bool operator()(const base::StringPiece& a, 71 bool operator()(const base::StringPiece& a,
69 const base::StringPiece& b) const { 72 const base::StringPiece& b) const {
70 return comparator_->Compare(a, b) < 0; 73 return comparator_->Compare(a, b) < 0;
71 } 74 }
72 75
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void Set(const base::StringPiece& key, std::string* value, bool deleted); 160 void Set(const base::StringPiece& key, std::string* value, bool deleted);
158 void RegisterIterator(TransactionIterator* iterator); 161 void RegisterIterator(TransactionIterator* iterator);
159 void UnregisterIterator(TransactionIterator* iterator); 162 void UnregisterIterator(TransactionIterator* iterator);
160 void NotifyIterators(); 163 void NotifyIterators();
161 164
162 LevelDBDatabase* db_; 165 LevelDBDatabase* db_;
163 const LevelDBSnapshot snapshot_; 166 const LevelDBSnapshot snapshot_;
164 const LevelDBComparator* comparator_; 167 const LevelDBComparator* comparator_;
165 Comparator data_comparator_; 168 Comparator data_comparator_;
166 DataType data_; 169 DataType data_;
170 uint64_t size_ = 0ull;
167 bool finished_ = false; 171 bool finished_ = false;
168 std::set<TransactionIterator*> iterators_; 172 std::set<TransactionIterator*> iterators_;
169 173
170 DISALLOW_COPY_AND_ASSIGN(LevelDBTransaction); 174 DISALLOW_COPY_AND_ASSIGN(LevelDBTransaction);
171 }; 175 };
172 176
173 // Reads go straight to the database, ignoring any writes cached in 177 // Reads go straight to the database, ignoring any writes cached in
174 // write_batch_, and writes are write-through, without consolidation. 178 // write_batch_, and writes are write-through, without consolidation.
175 class LevelDBDirectTransaction { 179 class LevelDBDirectTransaction {
176 public: 180 public:
(...skipping 13 matching lines...) Expand all
190 LevelDBDatabase* db_; 194 LevelDBDatabase* db_;
191 std::unique_ptr<LevelDBWriteBatch> write_batch_; 195 std::unique_ptr<LevelDBWriteBatch> write_batch_;
192 bool finished_ = false; 196 bool finished_ = false;
193 197
194 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); 198 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction);
195 }; 199 };
196 200
197 } // namespace content 201 } // namespace content
198 202
199 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ 203 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_transaction.cc ('k') | content/browser/indexed_db/leveldb/leveldb_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698