| 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 <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" | 24 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" |
| 25 #include "content/browser/indexed_db/indexed_db_metadata.h" | 25 #include "content/browser/indexed_db/indexed_db_metadata.h" |
| 26 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" | 26 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" |
| 27 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" | 27 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" |
| 28 #include "content/common/content_export.h" | 28 #include "content/common/content_export.h" |
| 29 #include "content/common/indexed_db/indexed_db_key.h" | 29 #include "content/common/indexed_db/indexed_db_key.h" |
| 30 #include "content/common/indexed_db/indexed_db_key_path.h" | 30 #include "content/common/indexed_db/indexed_db_key_path.h" |
| 31 #include "content/common/indexed_db/indexed_db_key_range.h" | 31 #include "content/common/indexed_db/indexed_db_key_range.h" |
| 32 #include "third_party/leveldatabase/src/include/leveldb/status.h" | 32 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
| 33 #include "url/gurl.h" | 33 #include "url/gurl.h" |
| 34 #include "webkit/browser/blob/blob_data_handle.h" | 34 #include "storage/browser/blob/blob_data_handle.h" |
| 35 | 35 |
| 36 namespace base { | 36 namespace base { |
| 37 class SequencedTaskRunner; | 37 class SequencedTaskRunner; |
| 38 } | 38 } |
| 39 | 39 |
| 40 namespace fileapi { | 40 namespace storage { |
| 41 class FileWriterDelegate; | 41 class FileWriterDelegate; |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace net { | 44 namespace net { |
| 45 class URLRequestContext; | 45 class URLRequestContext; |
| 46 } | 46 } |
| 47 | 47 |
| 48 namespace content { | 48 namespace content { |
| 49 | 49 |
| 50 class IndexedDBFactory; | 50 class IndexedDBFactory; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 int64 database_id, | 184 int64 database_id, |
| 185 int64 object_store_id, | 185 int64 object_store_id, |
| 186 const IndexedDBKey& key, | 186 const IndexedDBKey& key, |
| 187 IndexedDBValue* record) WARN_UNUSED_RESULT; | 187 IndexedDBValue* record) WARN_UNUSED_RESULT; |
| 188 virtual leveldb::Status PutRecord( | 188 virtual leveldb::Status PutRecord( |
| 189 IndexedDBBackingStore::Transaction* transaction, | 189 IndexedDBBackingStore::Transaction* transaction, |
| 190 int64 database_id, | 190 int64 database_id, |
| 191 int64 object_store_id, | 191 int64 object_store_id, |
| 192 const IndexedDBKey& key, | 192 const IndexedDBKey& key, |
| 193 IndexedDBValue* value, | 193 IndexedDBValue* value, |
| 194 ScopedVector<webkit_blob::BlobDataHandle>* handles, | 194 ScopedVector<storage::BlobDataHandle>* handles, |
| 195 RecordIdentifier* record) WARN_UNUSED_RESULT; | 195 RecordIdentifier* record) WARN_UNUSED_RESULT; |
| 196 virtual leveldb::Status ClearObjectStore( | 196 virtual leveldb::Status ClearObjectStore( |
| 197 IndexedDBBackingStore::Transaction* transaction, | 197 IndexedDBBackingStore::Transaction* transaction, |
| 198 int64 database_id, | 198 int64 database_id, |
| 199 int64 object_store_id) WARN_UNUSED_RESULT; | 199 int64 object_store_id) WARN_UNUSED_RESULT; |
| 200 virtual leveldb::Status DeleteRecord( | 200 virtual leveldb::Status DeleteRecord( |
| 201 IndexedDBBackingStore::Transaction* transaction, | 201 IndexedDBBackingStore::Transaction* transaction, |
| 202 int64 database_id, | 202 int64 database_id, |
| 203 int64 object_store_id, | 203 int64 object_store_id, |
| 204 const RecordIdentifier& record) WARN_UNUSED_RESULT; | 204 const RecordIdentifier& record) WARN_UNUSED_RESULT; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 public: | 372 public: |
| 373 BlobChangeRecord(const std::string& key, int64 object_store_id); | 373 BlobChangeRecord(const std::string& key, int64 object_store_id); |
| 374 ~BlobChangeRecord(); | 374 ~BlobChangeRecord(); |
| 375 const std::string& key() const { return key_; } | 375 const std::string& key() const { return key_; } |
| 376 int64 object_store_id() const { return object_store_id_; } | 376 int64 object_store_id() const { return object_store_id_; } |
| 377 void SetBlobInfo(std::vector<IndexedDBBlobInfo>* blob_info); | 377 void SetBlobInfo(std::vector<IndexedDBBlobInfo>* blob_info); |
| 378 std::vector<IndexedDBBlobInfo>& mutable_blob_info() { return blob_info_; } | 378 std::vector<IndexedDBBlobInfo>& mutable_blob_info() { return blob_info_; } |
| 379 const std::vector<IndexedDBBlobInfo>& blob_info() const { | 379 const std::vector<IndexedDBBlobInfo>& blob_info() const { |
| 380 return blob_info_; | 380 return blob_info_; |
| 381 } | 381 } |
| 382 void SetHandles(ScopedVector<webkit_blob::BlobDataHandle>* handles); | 382 void SetHandles(ScopedVector<storage::BlobDataHandle>* handles); |
| 383 scoped_ptr<BlobChangeRecord> Clone() const; | 383 scoped_ptr<BlobChangeRecord> Clone() const; |
| 384 | 384 |
| 385 private: | 385 private: |
| 386 std::string key_; | 386 std::string key_; |
| 387 int64 object_store_id_; | 387 int64 object_store_id_; |
| 388 std::vector<IndexedDBBlobInfo> blob_info_; | 388 std::vector<IndexedDBBlobInfo> blob_info_; |
| 389 ScopedVector<webkit_blob::BlobDataHandle> handles_; | 389 ScopedVector<storage::BlobDataHandle> handles_; |
| 390 DISALLOW_COPY_AND_ASSIGN(BlobChangeRecord); | 390 DISALLOW_COPY_AND_ASSIGN(BlobChangeRecord); |
| 391 }; | 391 }; |
| 392 typedef std::map<std::string, BlobChangeRecord*> BlobChangeMap; | 392 typedef std::map<std::string, BlobChangeRecord*> BlobChangeMap; |
| 393 | 393 |
| 394 class Transaction { | 394 class Transaction { |
| 395 public: | 395 public: |
| 396 explicit Transaction(IndexedDBBackingStore* backing_store); | 396 explicit Transaction(IndexedDBBackingStore* backing_store); |
| 397 virtual ~Transaction(); | 397 virtual ~Transaction(); |
| 398 virtual void Begin(); | 398 virtual void Begin(); |
| 399 // The callback will be called eventually on success or failure, or | 399 // The callback will be called eventually on success or failure, or |
| 400 // immediately if phase one is complete due to lack of any blobs to write. | 400 // immediately if phase one is complete due to lack of any blobs to write. |
| 401 virtual leveldb::Status CommitPhaseOne(scoped_refptr<BlobWriteCallback>); | 401 virtual leveldb::Status CommitPhaseOne(scoped_refptr<BlobWriteCallback>); |
| 402 virtual leveldb::Status CommitPhaseTwo(); | 402 virtual leveldb::Status CommitPhaseTwo(); |
| 403 virtual void Rollback(); | 403 virtual void Rollback(); |
| 404 void Reset() { | 404 void Reset() { |
| 405 backing_store_ = NULL; | 405 backing_store_ = NULL; |
| 406 transaction_ = NULL; | 406 transaction_ = NULL; |
| 407 } | 407 } |
| 408 leveldb::Status PutBlobInfoIfNeeded( | 408 leveldb::Status PutBlobInfoIfNeeded( |
| 409 int64 database_id, | 409 int64 database_id, |
| 410 int64 object_store_id, | 410 int64 object_store_id, |
| 411 const std::string& object_store_data_key, | 411 const std::string& object_store_data_key, |
| 412 std::vector<IndexedDBBlobInfo>*, | 412 std::vector<IndexedDBBlobInfo>*, |
| 413 ScopedVector<webkit_blob::BlobDataHandle>* handles); | 413 ScopedVector<storage::BlobDataHandle>* handles); |
| 414 void PutBlobInfo(int64 database_id, | 414 void PutBlobInfo(int64 database_id, |
| 415 int64 object_store_id, | 415 int64 object_store_id, |
| 416 const std::string& object_store_data_key, | 416 const std::string& object_store_data_key, |
| 417 std::vector<IndexedDBBlobInfo>*, | 417 std::vector<IndexedDBBlobInfo>*, |
| 418 ScopedVector<webkit_blob::BlobDataHandle>* handles); | 418 ScopedVector<storage::BlobDataHandle>* handles); |
| 419 | 419 |
| 420 LevelDBTransaction* transaction() { return transaction_; } | 420 LevelDBTransaction* transaction() { return transaction_; } |
| 421 | 421 |
| 422 leveldb::Status GetBlobInfoForRecord( | 422 leveldb::Status GetBlobInfoForRecord( |
| 423 int64 database_id, | 423 int64 database_id, |
| 424 const std::string& object_store_data_key, | 424 const std::string& object_store_data_key, |
| 425 IndexedDBValue* value); | 425 IndexedDBValue* value); |
| 426 | 426 |
| 427 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored | 427 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored |
| 428 // under that key. | 428 // under that key. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 456 base::FilePath file_path_; | 456 base::FilePath file_path_; |
| 457 int64_t key_; | 457 int64_t key_; |
| 458 int64_t size_; | 458 int64_t size_; |
| 459 base::Time last_modified_; | 459 base::Time last_modified_; |
| 460 }; | 460 }; |
| 461 | 461 |
| 462 class ChainedBlobWriter | 462 class ChainedBlobWriter |
| 463 : public base::RefCountedThreadSafe<ChainedBlobWriter> { | 463 : public base::RefCountedThreadSafe<ChainedBlobWriter> { |
| 464 public: | 464 public: |
| 465 virtual void set_delegate( | 465 virtual void set_delegate( |
| 466 scoped_ptr<fileapi::FileWriterDelegate> delegate) = 0; | 466 scoped_ptr<storage::FileWriterDelegate> delegate) = 0; |
| 467 | 467 |
| 468 // TODO(ericu): Add a reason in the event of failure. | 468 // TODO(ericu): Add a reason in the event of failure. |
| 469 virtual void ReportWriteCompletion(bool succeeded, | 469 virtual void ReportWriteCompletion(bool succeeded, |
| 470 int64 bytes_written) = 0; | 470 int64 bytes_written) = 0; |
| 471 | 471 |
| 472 virtual void Abort() = 0; | 472 virtual void Abort() = 0; |
| 473 | 473 |
| 474 protected: | 474 protected: |
| 475 friend class base::RefCountedThreadSafe<ChainedBlobWriter>; | 475 friend class base::RefCountedThreadSafe<ChainedBlobWriter>; |
| 476 virtual ~ChainedBlobWriter() {} | 476 virtual ~ChainedBlobWriter() {} |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 // will hold a reference to this backing store. | 580 // will hold a reference to this backing store. |
| 581 IndexedDBActiveBlobRegistry active_blob_registry_; | 581 IndexedDBActiveBlobRegistry active_blob_registry_; |
| 582 base::OneShotTimer<IndexedDBBackingStore> close_timer_; | 582 base::OneShotTimer<IndexedDBBackingStore> close_timer_; |
| 583 | 583 |
| 584 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); | 584 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); |
| 585 }; | 585 }; |
| 586 | 586 |
| 587 } // namespace content | 587 } // namespace content |
| 588 | 588 |
| 589 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 589 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
| OLD | NEW |