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_INDEXED_DB_BACKING_STORE_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <utility> | 15 #include <utility> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
21 #include "base/memory/scoped_vector.h" | |
22 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
23 #include "base/time/time.h" | 22 #include "base/time/time.h" |
24 #include "base/timer/timer.h" | 23 #include "base/timer/timer.h" |
25 #include "content/browser/indexed_db/indexed_db.h" | 24 #include "content/browser/indexed_db/indexed_db.h" |
26 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" | 25 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" |
27 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 26 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
28 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" | 27 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" |
29 #include "content/browser/indexed_db/indexed_db_metadata.h" | 28 #include "content/browser/indexed_db/indexed_db_metadata.h" |
30 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" | 29 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" |
31 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" | 30 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 BlobChangeRecord(const std::string& key, int64_t object_store_id); | 103 BlobChangeRecord(const std::string& key, int64_t object_store_id); |
105 ~BlobChangeRecord(); | 104 ~BlobChangeRecord(); |
106 | 105 |
107 const std::string& key() const { return key_; } | 106 const std::string& key() const { return key_; } |
108 int64_t object_store_id() const { return object_store_id_; } | 107 int64_t object_store_id() const { return object_store_id_; } |
109 void SetBlobInfo(std::vector<IndexedDBBlobInfo>* blob_info); | 108 void SetBlobInfo(std::vector<IndexedDBBlobInfo>* blob_info); |
110 std::vector<IndexedDBBlobInfo>& mutable_blob_info() { return blob_info_; } | 109 std::vector<IndexedDBBlobInfo>& mutable_blob_info() { return blob_info_; } |
111 const std::vector<IndexedDBBlobInfo>& blob_info() const { | 110 const std::vector<IndexedDBBlobInfo>& blob_info() const { |
112 return blob_info_; | 111 return blob_info_; |
113 } | 112 } |
114 void SetHandles(ScopedVector<storage::BlobDataHandle>* handles); | 113 void SetHandles( |
| 114 std::vector<std::unique_ptr<storage::BlobDataHandle>>* handles); |
115 std::unique_ptr<BlobChangeRecord> Clone() const; | 115 std::unique_ptr<BlobChangeRecord> Clone() const; |
116 | 116 |
117 private: | 117 private: |
118 std::string key_; | 118 std::string key_; |
119 int64_t object_store_id_; | 119 int64_t object_store_id_; |
120 std::vector<IndexedDBBlobInfo> blob_info_; | 120 std::vector<IndexedDBBlobInfo> blob_info_; |
121 ScopedVector<storage::BlobDataHandle> handles_; | 121 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles_; |
122 DISALLOW_COPY_AND_ASSIGN(BlobChangeRecord); | 122 DISALLOW_COPY_AND_ASSIGN(BlobChangeRecord); |
123 }; | 123 }; |
124 | 124 |
125 class CONTENT_EXPORT Transaction { | 125 class CONTENT_EXPORT Transaction { |
126 public: | 126 public: |
127 explicit Transaction(IndexedDBBackingStore* backing_store); | 127 explicit Transaction(IndexedDBBackingStore* backing_store); |
128 virtual ~Transaction(); | 128 virtual ~Transaction(); |
129 | 129 |
130 virtual void Begin(); | 130 virtual void Begin(); |
131 | 131 |
(...skipping 14 matching lines...) Expand all Loading... |
146 virtual void Rollback(); | 146 virtual void Rollback(); |
147 void Reset() { | 147 void Reset() { |
148 backing_store_ = NULL; | 148 backing_store_ = NULL; |
149 transaction_ = NULL; | 149 transaction_ = NULL; |
150 } | 150 } |
151 leveldb::Status PutBlobInfoIfNeeded( | 151 leveldb::Status PutBlobInfoIfNeeded( |
152 int64_t database_id, | 152 int64_t database_id, |
153 int64_t object_store_id, | 153 int64_t object_store_id, |
154 const std::string& object_store_data_key, | 154 const std::string& object_store_data_key, |
155 std::vector<IndexedDBBlobInfo>*, | 155 std::vector<IndexedDBBlobInfo>*, |
156 ScopedVector<storage::BlobDataHandle>* handles); | 156 std::vector<std::unique_ptr<storage::BlobDataHandle>>* handles); |
157 void PutBlobInfo(int64_t database_id, | 157 void PutBlobInfo( |
158 int64_t object_store_id, | 158 int64_t database_id, |
159 const std::string& object_store_data_key, | 159 int64_t object_store_id, |
160 std::vector<IndexedDBBlobInfo>*, | 160 const std::string& object_store_data_key, |
161 ScopedVector<storage::BlobDataHandle>* handles); | 161 std::vector<IndexedDBBlobInfo>*, |
| 162 std::vector<std::unique_ptr<storage::BlobDataHandle>>* handles); |
162 | 163 |
163 LevelDBTransaction* transaction() { return transaction_.get(); } | 164 LevelDBTransaction* transaction() { return transaction_.get(); } |
164 | 165 |
165 leveldb::Status GetBlobInfoForRecord( | 166 leveldb::Status GetBlobInfoForRecord( |
166 int64_t database_id, | 167 int64_t database_id, |
167 const std::string& object_store_data_key, | 168 const std::string& object_store_data_key, |
168 IndexedDBValue* value); | 169 IndexedDBValue* value); |
169 | 170 |
170 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored | 171 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored |
171 // under that key. | 172 // under that key. |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 int64_t database_id, | 447 int64_t database_id, |
447 int64_t object_store_id, | 448 int64_t object_store_id, |
448 const IndexedDBKey& key, | 449 const IndexedDBKey& key, |
449 IndexedDBValue* record) WARN_UNUSED_RESULT; | 450 IndexedDBValue* record) WARN_UNUSED_RESULT; |
450 virtual leveldb::Status PutRecord( | 451 virtual leveldb::Status PutRecord( |
451 IndexedDBBackingStore::Transaction* transaction, | 452 IndexedDBBackingStore::Transaction* transaction, |
452 int64_t database_id, | 453 int64_t database_id, |
453 int64_t object_store_id, | 454 int64_t object_store_id, |
454 const IndexedDBKey& key, | 455 const IndexedDBKey& key, |
455 IndexedDBValue* value, | 456 IndexedDBValue* value, |
456 ScopedVector<storage::BlobDataHandle>* handles, | 457 std::vector<std::unique_ptr<storage::BlobDataHandle>>* handles, |
457 RecordIdentifier* record) WARN_UNUSED_RESULT; | 458 RecordIdentifier* record) WARN_UNUSED_RESULT; |
458 virtual leveldb::Status ClearObjectStore( | 459 virtual leveldb::Status ClearObjectStore( |
459 IndexedDBBackingStore::Transaction* transaction, | 460 IndexedDBBackingStore::Transaction* transaction, |
460 int64_t database_id, | 461 int64_t database_id, |
461 int64_t object_store_id) WARN_UNUSED_RESULT; | 462 int64_t object_store_id) WARN_UNUSED_RESULT; |
462 virtual leveldb::Status DeleteRecord( | 463 virtual leveldb::Status DeleteRecord( |
463 IndexedDBBackingStore::Transaction* transaction, | 464 IndexedDBBackingStore::Transaction* transaction, |
464 int64_t database_id, | 465 int64_t database_id, |
465 int64_t object_store_id, | 466 int64_t object_store_id, |
466 const RecordIdentifier& record) WARN_UNUSED_RESULT; | 467 const RecordIdentifier& record) WARN_UNUSED_RESULT; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // complete. While > 0, temporary journal entries may exist so out-of-band | 671 // complete. While > 0, temporary journal entries may exist so out-of-band |
671 // journal cleaning must be deferred. | 672 // journal cleaning must be deferred. |
672 size_t committing_transaction_count_; | 673 size_t committing_transaction_count_; |
673 | 674 |
674 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); | 675 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); |
675 }; | 676 }; |
676 | 677 |
677 } // namespace content | 678 } // namespace content |
678 | 679 |
679 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 680 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
OLD | NEW |