| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 bool Advance(uint32 count, leveldb::Status*); | 301 bool Advance(uint32 count, leveldb::Status*); |
| 302 bool FirstSeek(leveldb::Status*); | 302 bool FirstSeek(leveldb::Status*); |
| 303 | 303 |
| 304 virtual Cursor* Clone() = 0; | 304 virtual Cursor* Clone() = 0; |
| 305 virtual const IndexedDBKey& primary_key() const; | 305 virtual const IndexedDBKey& primary_key() const; |
| 306 virtual IndexedDBValue* value() = 0; | 306 virtual IndexedDBValue* value() = 0; |
| 307 virtual const RecordIdentifier& record_identifier() const; | 307 virtual const RecordIdentifier& record_identifier() const; |
| 308 virtual bool LoadCurrentRow() = 0; | 308 virtual bool LoadCurrentRow() = 0; |
| 309 | 309 |
| 310 protected: | 310 protected: |
| 311 Cursor(scoped_refptr<IndexedDBBackingStore> backing_store, | 311 Cursor(LevelDBTransaction* transaction, |
| 312 Transaction* transaction, | |
| 313 int64 database_id, | |
| 314 const CursorOptions& cursor_options); | 312 const CursorOptions& cursor_options); |
| 315 explicit Cursor(const IndexedDBBackingStore::Cursor* other); | 313 explicit Cursor(const IndexedDBBackingStore::Cursor* other); |
| 316 | 314 |
| 317 virtual std::string EncodeKey(const IndexedDBKey& key) = 0; | 315 virtual std::string EncodeKey(const IndexedDBKey& key) = 0; |
| 318 virtual std::string EncodeKey(const IndexedDBKey& key, | 316 virtual std::string EncodeKey(const IndexedDBKey& key, |
| 319 const IndexedDBKey& primary_key) = 0; | 317 const IndexedDBKey& primary_key) = 0; |
| 320 | 318 |
| 321 bool IsPastBounds() const; | 319 bool IsPastBounds() const; |
| 322 bool HaveEnteredRange() const; | 320 bool HaveEnteredRange() const; |
| 323 | 321 |
| 324 IndexedDBBackingStore* backing_store_; | 322 LevelDBTransaction* transaction_; |
| 325 Transaction* transaction_; | |
| 326 int64 database_id_; | |
| 327 const CursorOptions cursor_options_; | 323 const CursorOptions cursor_options_; |
| 328 scoped_ptr<LevelDBIterator> iterator_; | 324 scoped_ptr<LevelDBIterator> iterator_; |
| 329 scoped_ptr<IndexedDBKey> current_key_; | 325 scoped_ptr<IndexedDBKey> current_key_; |
| 330 IndexedDBBackingStore::RecordIdentifier record_identifier_; | 326 IndexedDBBackingStore::RecordIdentifier record_identifier_; |
| 331 }; | 327 }; |
| 332 | 328 |
| 333 virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor( | 329 virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor( |
| 334 IndexedDBBackingStore::Transaction* transaction, | 330 IndexedDBBackingStore::Transaction* transaction, |
| 335 int64 database_id, | 331 int64 database_id, |
| 336 int64 object_store_id, | 332 int64 object_store_id, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 transaction_ = NULL; | 392 transaction_ = NULL; |
| 397 } | 393 } |
| 398 void PutBlobInfo(int64 database_id, | 394 void PutBlobInfo(int64 database_id, |
| 399 int64 object_store_id, | 395 int64 object_store_id, |
| 400 const std::string& object_store_data_key, | 396 const std::string& object_store_data_key, |
| 401 std::vector<IndexedDBBlobInfo>*, | 397 std::vector<IndexedDBBlobInfo>*, |
| 402 ScopedVector<webkit_blob::BlobDataHandle>* handles); | 398 ScopedVector<webkit_blob::BlobDataHandle>* handles); |
| 403 | 399 |
| 404 LevelDBTransaction* transaction() { return transaction_; } | 400 LevelDBTransaction* transaction() { return transaction_; } |
| 405 | 401 |
| 406 leveldb::Status GetBlobInfoForRecord( | |
| 407 int64 database_id, | |
| 408 const std::string& object_store_data_key, | |
| 409 IndexedDBValue* value); | |
| 410 | |
| 411 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored | 402 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored |
| 412 // under that key. | 403 // under that key. |
| 413 typedef std::vector<std::pair<BlobEntryKey, std::string> > | 404 typedef std::vector<std::pair<BlobEntryKey, std::string> > |
| 414 BlobEntryKeyValuePairVec; | 405 BlobEntryKeyValuePairVec; |
| 415 | 406 |
| 416 class WriteDescriptor { | 407 class WriteDescriptor { |
| 417 public: | 408 public: |
| 418 WriteDescriptor(const GURL& url, int64_t key); | 409 WriteDescriptor(const GURL& url, int64_t key); |
| 419 WriteDescriptor(const base::FilePath& path, int64_t key); | 410 WriteDescriptor(const base::FilePath& path, int64_t key); |
| 420 | 411 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 const base::FilePath& blob_path, | 468 const base::FilePath& blob_path, |
| 478 net::URLRequestContext* request_context, | 469 net::URLRequestContext* request_context, |
| 479 scoped_ptr<LevelDBDatabase> db, | 470 scoped_ptr<LevelDBDatabase> db, |
| 480 scoped_ptr<LevelDBComparator> comparator, | 471 scoped_ptr<LevelDBComparator> comparator, |
| 481 base::TaskRunner* task_runner); | 472 base::TaskRunner* task_runner); |
| 482 virtual ~IndexedDBBackingStore(); | 473 virtual ~IndexedDBBackingStore(); |
| 483 friend class base::RefCounted<IndexedDBBackingStore>; | 474 friend class base::RefCounted<IndexedDBBackingStore>; |
| 484 | 475 |
| 485 bool is_incognito() const { return !indexed_db_factory_; } | 476 bool is_incognito() const { return !indexed_db_factory_; } |
| 486 | 477 |
| 487 bool SetUpMetadata(); | |
| 488 | |
| 489 virtual bool WriteBlobFile( | 478 virtual bool WriteBlobFile( |
| 490 int64 database_id, | 479 int64 database_id, |
| 491 const Transaction::WriteDescriptor& descriptor, | 480 const Transaction::WriteDescriptor& descriptor, |
| 492 Transaction::ChainedBlobWriter* chained_blob_writer); | 481 Transaction::ChainedBlobWriter* chained_blob_writer); |
| 493 virtual bool RemoveBlobFile(int64 database_id, int64 key); | 482 virtual bool RemoveBlobFile(int64 database_id, int64 key); |
| 494 virtual void StartJournalCleaningTimer(); | 483 virtual void StartJournalCleaningTimer(); |
| 495 void CleanPrimaryJournalIgnoreReturn(); | 484 void CleanPrimaryJournalIgnoreReturn(); |
| 496 | 485 |
| 497 private: | 486 private: |
| 498 static scoped_refptr<IndexedDBBackingStore> Create( | 487 static scoped_refptr<IndexedDBBackingStore> Create( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 scoped_ptr<LevelDBComparator> comparator_; | 534 scoped_ptr<LevelDBComparator> comparator_; |
| 546 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ | 535 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ |
| 547 // will hold a reference to this backing store. | 536 // will hold a reference to this backing store. |
| 548 IndexedDBActiveBlobRegistry active_blob_registry_; | 537 IndexedDBActiveBlobRegistry active_blob_registry_; |
| 549 base::OneShotTimer<IndexedDBBackingStore> close_timer_; | 538 base::OneShotTimer<IndexedDBBackingStore> close_timer_; |
| 550 }; | 539 }; |
| 551 | 540 |
| 552 } // namespace content | 541 } // namespace content |
| 553 | 542 |
| 554 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 543 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
| OLD | NEW |