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 |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 namespace base { | 41 namespace base { |
42 class SequencedTaskRunner; | 42 class SequencedTaskRunner; |
43 } | 43 } |
44 | 44 |
45 namespace storage { | 45 namespace storage { |
46 class FileWriterDelegate; | 46 class FileWriterDelegate; |
47 } | 47 } |
48 | 48 |
49 namespace net { | 49 namespace net { |
50 class URLRequestContext; | 50 class URLRequestContextGetter; |
51 } | 51 } |
52 | 52 |
53 namespace content { | 53 namespace content { |
54 | 54 |
55 class IndexedDBFactory; | 55 class IndexedDBFactory; |
56 class LevelDBComparator; | 56 class LevelDBComparator; |
57 class LevelDBDatabase; | 57 class LevelDBDatabase; |
58 class LevelDBFactory; | 58 class LevelDBFactory; |
59 struct IndexedDBDataLossInfo; | 59 struct IndexedDBDataLossInfo; |
60 struct IndexedDBValue; | 60 struct IndexedDBValue; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 base::SequencedTaskRunner* task_runner() const { return task_runner_.get(); } | 368 base::SequencedTaskRunner* task_runner() const { return task_runner_.get(); } |
369 base::OneShotTimer* close_timer() { return &close_timer_; } | 369 base::OneShotTimer* close_timer() { return &close_timer_; } |
370 IndexedDBActiveBlobRegistry* active_blob_registry() { | 370 IndexedDBActiveBlobRegistry* active_blob_registry() { |
371 return &active_blob_registry_; | 371 return &active_blob_registry_; |
372 } | 372 } |
373 | 373 |
374 static scoped_refptr<IndexedDBBackingStore> Open( | 374 static scoped_refptr<IndexedDBBackingStore> Open( |
375 IndexedDBFactory* indexed_db_factory, | 375 IndexedDBFactory* indexed_db_factory, |
376 const url::Origin& origin, | 376 const url::Origin& origin, |
377 const base::FilePath& path_base, | 377 const base::FilePath& path_base, |
378 net::URLRequestContext* request_context, | 378 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
379 IndexedDBDataLossInfo* data_loss_info, | 379 IndexedDBDataLossInfo* data_loss_info, |
380 bool* disk_full, | 380 bool* disk_full, |
381 base::SequencedTaskRunner* task_runner, | 381 base::SequencedTaskRunner* task_runner, |
382 bool clean_journal, | 382 bool clean_journal, |
383 leveldb::Status* status); | 383 leveldb::Status* status); |
384 static scoped_refptr<IndexedDBBackingStore> Open( | 384 static scoped_refptr<IndexedDBBackingStore> Open( |
385 IndexedDBFactory* indexed_db_factory, | 385 IndexedDBFactory* indexed_db_factory, |
386 const url::Origin& origin, | 386 const url::Origin& origin, |
387 const base::FilePath& path_base, | 387 const base::FilePath& path_base, |
388 net::URLRequestContext* request_context, | 388 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
389 IndexedDBDataLossInfo* data_loss_info, | 389 IndexedDBDataLossInfo* data_loss_info, |
390 bool* disk_full, | 390 bool* disk_full, |
391 LevelDBFactory* leveldb_factory, | 391 LevelDBFactory* leveldb_factory, |
392 base::SequencedTaskRunner* task_runner, | 392 base::SequencedTaskRunner* task_runner, |
393 bool clean_journal, | 393 bool clean_journal, |
394 leveldb::Status* status); | 394 leveldb::Status* status); |
395 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( | 395 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( |
396 const url::Origin& origin, | 396 const url::Origin& origin, |
397 base::SequencedTaskRunner* task_runner, | 397 base::SequencedTaskRunner* task_runner, |
398 leveldb::Status* status); | 398 leveldb::Status* status); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 int64_t database_id, | 558 int64_t database_id, |
559 int64_t object_store_id, | 559 int64_t object_store_id, |
560 int64_t index_id, | 560 int64_t index_id, |
561 const IndexedDBKeyRange& key_range, | 561 const IndexedDBKeyRange& key_range, |
562 blink::WebIDBCursorDirection, | 562 blink::WebIDBCursorDirection, |
563 leveldb::Status*); | 563 leveldb::Status*); |
564 | 564 |
565 protected: | 565 protected: |
566 friend class base::RefCounted<IndexedDBBackingStore>; | 566 friend class base::RefCounted<IndexedDBBackingStore>; |
567 | 567 |
568 IndexedDBBackingStore(IndexedDBFactory* indexed_db_factory, | 568 IndexedDBBackingStore( |
569 const url::Origin& origin, | 569 IndexedDBFactory* indexed_db_factory, |
570 const base::FilePath& blob_path, | 570 const url::Origin& origin, |
571 net::URLRequestContext* request_context, | 571 const base::FilePath& blob_path, |
572 std::unique_ptr<LevelDBDatabase> db, | 572 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
573 std::unique_ptr<LevelDBComparator> comparator, | 573 std::unique_ptr<LevelDBDatabase> db, |
574 base::SequencedTaskRunner* task_runner); | 574 std::unique_ptr<LevelDBComparator> comparator, |
| 575 base::SequencedTaskRunner* task_runner); |
575 virtual ~IndexedDBBackingStore(); | 576 virtual ~IndexedDBBackingStore(); |
576 | 577 |
577 bool is_incognito() const { return !indexed_db_factory_; } | 578 bool is_incognito() const { return !indexed_db_factory_; } |
578 | 579 |
579 leveldb::Status SetUpMetadata(); | 580 leveldb::Status SetUpMetadata(); |
580 | 581 |
581 virtual bool WriteBlobFile( | 582 virtual bool WriteBlobFile( |
582 int64_t database_id, | 583 int64_t database_id, |
583 const Transaction::WriteDescriptor& descriptor, | 584 const Transaction::WriteDescriptor& descriptor, |
584 Transaction::ChainedBlobWriter* chained_blob_writer); | 585 Transaction::ChainedBlobWriter* chained_blob_writer); |
(...skipping 10 matching lines...) Expand all Loading... |
595 // any referenced files and delete the journal entry. If any | 596 // any referenced files and delete the journal entry. If any |
596 // transaction is currently committing this will be deferred | 597 // transaction is currently committing this will be deferred |
597 // via StartJournalCleaningTimer(). | 598 // via StartJournalCleaningTimer(). |
598 void CleanPrimaryJournalIgnoreReturn(); | 599 void CleanPrimaryJournalIgnoreReturn(); |
599 | 600 |
600 private: | 601 private: |
601 static scoped_refptr<IndexedDBBackingStore> Create( | 602 static scoped_refptr<IndexedDBBackingStore> Create( |
602 IndexedDBFactory* indexed_db_factory, | 603 IndexedDBFactory* indexed_db_factory, |
603 const url::Origin& origin, | 604 const url::Origin& origin, |
604 const base::FilePath& blob_path, | 605 const base::FilePath& blob_path, |
605 net::URLRequestContext* request_context, | 606 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
606 std::unique_ptr<LevelDBDatabase> db, | 607 std::unique_ptr<LevelDBDatabase> db, |
607 std::unique_ptr<LevelDBComparator> comparator, | 608 std::unique_ptr<LevelDBComparator> comparator, |
608 base::SequencedTaskRunner* task_runner, | 609 base::SequencedTaskRunner* task_runner, |
609 leveldb::Status* status); | 610 leveldb::Status* status); |
610 | 611 |
611 static bool ReadCorruptionInfo(const base::FilePath& path_base, | 612 static bool ReadCorruptionInfo(const base::FilePath& path_base, |
612 const url::Origin& origin, | 613 const url::Origin& origin, |
613 std::string* message); | 614 std::string* message); |
614 | 615 |
615 leveldb::Status FindKeyInIndex( | 616 leveldb::Status FindKeyInIndex( |
(...skipping 29 matching lines...) Expand all Loading... |
645 base::FilePath blob_path_; | 646 base::FilePath blob_path_; |
646 | 647 |
647 // The origin identifier is a key prefix unique to the origin used in the | 648 // The origin identifier is a key prefix unique to the origin used in the |
648 // leveldb backing store to partition data by origin. It is a normalized | 649 // leveldb backing store to partition data by origin. It is a normalized |
649 // version of the origin URL with a versioning suffix appended, e.g. | 650 // version of the origin URL with a versioning suffix appended, e.g. |
650 // "http_localhost_81@1" Since only one origin is stored per backing store | 651 // "http_localhost_81@1" Since only one origin is stored per backing store |
651 // this is redundant but necessary for backwards compatibility; the suffix | 652 // this is redundant but necessary for backwards compatibility; the suffix |
652 // provides for future flexibility. | 653 // provides for future flexibility. |
653 const std::string origin_identifier_; | 654 const std::string origin_identifier_; |
654 | 655 |
655 net::URLRequestContext* request_context_; | 656 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
656 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 657 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
657 std::set<int> child_process_ids_granted_; | 658 std::set<int> child_process_ids_granted_; |
658 std::map<std::string, std::unique_ptr<BlobChangeRecord>> incognito_blob_map_; | 659 std::map<std::string, std::unique_ptr<BlobChangeRecord>> incognito_blob_map_; |
659 base::OneShotTimer journal_cleaning_timer_; | 660 base::OneShotTimer journal_cleaning_timer_; |
660 | 661 |
661 std::unique_ptr<LevelDBDatabase> db_; | 662 std::unique_ptr<LevelDBDatabase> db_; |
662 std::unique_ptr<LevelDBComparator> comparator_; | 663 std::unique_ptr<LevelDBComparator> comparator_; |
663 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ | 664 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ |
664 // will hold a reference to this backing store. | 665 // will hold a reference to this backing store. |
665 IndexedDBActiveBlobRegistry active_blob_registry_; | 666 IndexedDBActiveBlobRegistry active_blob_registry_; |
666 base::OneShotTimer close_timer_; | 667 base::OneShotTimer close_timer_; |
667 | 668 |
668 // Incremented whenever a transaction starts committing, decremented when | 669 // Incremented whenever a transaction starts committing, decremented when |
669 // complete. While > 0, temporary journal entries may exist so out-of-band | 670 // complete. While > 0, temporary journal entries may exist so out-of-band |
670 // journal cleaning must be deferred. | 671 // journal cleaning must be deferred. |
671 size_t committing_transaction_count_; | 672 size_t committing_transaction_count_; |
672 | 673 |
673 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); | 674 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); |
674 }; | 675 }; |
675 | 676 |
676 } // namespace content | 677 } // namespace content |
677 | 678 |
678 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 679 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
OLD | NEW |