| 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/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
| 22 #include "base/memory/weak_ptr.h" |
| 22 #include "base/strings/string_piece.h" | 23 #include "base/strings/string_piece.h" |
| 23 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 24 #include "base/timer/timer.h" | 25 #include "base/timer/timer.h" |
| 25 #include "content/browser/indexed_db/indexed_db.h" | 26 #include "content/browser/indexed_db/indexed_db.h" |
| 26 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" | 27 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" |
| 27 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 28 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
| 28 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" | 29 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" |
| 29 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" | 30 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" |
| 30 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" | 31 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" |
| 31 #include "content/common/content_export.h" | 32 #include "content/common/content_export.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 84 } |
| 84 | 85 |
| 85 private: | 86 private: |
| 86 // TODO(jsbell): Make it more clear that this is the *encoded* version of | 87 // TODO(jsbell): Make it more clear that this is the *encoded* version of |
| 87 // the key. | 88 // the key. |
| 88 std::string primary_key_; | 89 std::string primary_key_; |
| 89 int64_t version_; | 90 int64_t version_; |
| 90 DISALLOW_COPY_AND_ASSIGN(RecordIdentifier); | 91 DISALLOW_COPY_AND_ASSIGN(RecordIdentifier); |
| 91 }; | 92 }; |
| 92 | 93 |
| 94 enum class BlobWriteResult { FAILURE_ASYNC, SUCCESS_ASYNC, SUCCESS_SYNC }; |
| 95 |
| 93 class BlobWriteCallback : public base::RefCounted<BlobWriteCallback> { | 96 class BlobWriteCallback : public base::RefCounted<BlobWriteCallback> { |
| 94 public: | 97 public: |
| 95 virtual void Run(bool succeeded) = 0; | 98 // TODO(dmurph): Make all calls to this method async after measuring |
| 99 // performance. |
| 100 virtual leveldb::Status Run(BlobWriteResult result) = 0; |
| 96 | 101 |
| 97 protected: | 102 protected: |
| 98 friend class base::RefCounted<BlobWriteCallback>; | 103 friend class base::RefCounted<BlobWriteCallback>; |
| 99 virtual ~BlobWriteCallback() {} | 104 virtual ~BlobWriteCallback() {} |
| 100 }; | 105 }; |
| 101 | 106 |
| 102 class BlobChangeRecord { | 107 class BlobChangeRecord { |
| 103 public: | 108 public: |
| 104 BlobChangeRecord(const std::string& key, int64_t object_store_id); | 109 BlobChangeRecord(const std::string& key, int64_t object_store_id); |
| 105 ~BlobChangeRecord(); | 110 ~BlobChangeRecord(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 // be added to either the primary or live blob journal as appropriate | 280 // be added to either the primary or live blob journal as appropriate |
| 276 // following a successful commit. | 281 // following a successful commit. |
| 277 BlobJournalType blobs_to_remove_; | 282 BlobJournalType blobs_to_remove_; |
| 278 scoped_refptr<ChainedBlobWriter> chained_blob_writer_; | 283 scoped_refptr<ChainedBlobWriter> chained_blob_writer_; |
| 279 | 284 |
| 280 // Set to true between CommitPhaseOne and CommitPhaseTwo/Rollback, to | 285 // Set to true between CommitPhaseOne and CommitPhaseTwo/Rollback, to |
| 281 // indicate that the committing_transaction_count_ on the backing store | 286 // indicate that the committing_transaction_count_ on the backing store |
| 282 // has been bumped, and journal cleaning should be deferred. | 287 // has been bumped, and journal cleaning should be deferred. |
| 283 bool committing_; | 288 bool committing_; |
| 284 | 289 |
| 290 base::WeakPtrFactory<Transaction> ptr_factory_; |
| 291 |
| 285 DISALLOW_COPY_AND_ASSIGN(Transaction); | 292 DISALLOW_COPY_AND_ASSIGN(Transaction); |
| 286 }; | 293 }; |
| 287 | 294 |
| 288 class Cursor { | 295 class Cursor { |
| 289 public: | 296 public: |
| 290 enum IteratorState { READY = 0, SEEK }; | 297 enum IteratorState { READY = 0, SEEK }; |
| 291 | 298 |
| 292 virtual ~Cursor(); | 299 virtual ~Cursor(); |
| 293 | 300 |
| 294 struct CursorOptions { | 301 struct CursorOptions { |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 // complete. While > 0, temporary journal entries may exist so out-of-band | 694 // complete. While > 0, temporary journal entries may exist so out-of-band |
| 688 // journal cleaning must be deferred. | 695 // journal cleaning must be deferred. |
| 689 size_t committing_transaction_count_; | 696 size_t committing_transaction_count_; |
| 690 | 697 |
| 691 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); | 698 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); |
| 692 }; | 699 }; |
| 693 | 700 |
| 694 } // namespace content | 701 } // namespace content |
| 695 | 702 |
| 696 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 703 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
| OLD | NEW |