Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: content/browser/indexed_db/indexed_db_backing_store.h

Issue 2773823002: Use a two-part data format version in IndexedDB metadata. (Closed)
Patch Set: jsbell, cmumford Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 #include "base/strings/string_piece.h" 23 #include "base/strings/string_piece.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "base/timer/timer.h" 25 #include "base/timer/timer.h"
26 #include "content/browser/indexed_db/indexed_db.h" 26 #include "content/browser/indexed_db/indexed_db.h"
27 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" 27 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h"
28 #include "content/browser/indexed_db/indexed_db_blob_info.h" 28 #include "content/browser/indexed_db/indexed_db_blob_info.h"
29 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" 29 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
30 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" 30 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h"
31 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" 31 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
32 #include "content/common/content_export.h" 32 #include "content/common/content_export.h"
33 #include "content/common/indexed_db/indexed_db_data_format_version.h"
33 #include "content/common/indexed_db/indexed_db_key.h" 34 #include "content/common/indexed_db/indexed_db_key.h"
34 #include "content/common/indexed_db/indexed_db_key_path.h" 35 #include "content/common/indexed_db/indexed_db_key_path.h"
35 #include "content/common/indexed_db/indexed_db_key_range.h" 36 #include "content/common/indexed_db/indexed_db_key_range.h"
36 #include "content/common/indexed_db/indexed_db_metadata.h" 37 #include "content/common/indexed_db/indexed_db_metadata.h"
37 #include "storage/browser/blob/blob_data_handle.h" 38 #include "storage/browser/blob/blob_data_handle.h"
38 #include "third_party/leveldatabase/src/include/leveldb/status.h" 39 #include "third_party/leveldatabase/src/include/leveldb/status.h"
39 #include "url/gurl.h" 40 #include "url/gurl.h"
40 #include "url/origin.h" 41 #include "url/origin.h"
41 42
42 namespace base { 43 namespace base {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // NextNoDuplicate. 369 // NextNoDuplicate.
369 ContinueResult ContinuePrevious(const IndexedDBKey* key, 370 ContinueResult ContinuePrevious(const IndexedDBKey* key,
370 const IndexedDBKey* primary_key, 371 const IndexedDBKey* primary_key,
371 IteratorState state, 372 IteratorState state,
372 leveldb::Status*); 373 leveldb::Status*);
373 374
374 DISALLOW_COPY_AND_ASSIGN(Cursor); 375 DISALLOW_COPY_AND_ASSIGN(Cursor);
375 }; 376 };
376 377
377 const url::Origin& origin() const { return origin_; } 378 const url::Origin& origin() const { return origin_; }
379 const IndexedDBDataFormatVersion data_format_version() const {
dcheng 2017/04/04 19:59:21 Nit: no const and return by value, or const and re
380 return data_format_version_;
381 }
378 IndexedDBFactory* factory() const { return indexed_db_factory_; } 382 IndexedDBFactory* factory() const { return indexed_db_factory_; }
379 base::SequencedTaskRunner* task_runner() const { return task_runner_.get(); } 383 base::SequencedTaskRunner* task_runner() const { return task_runner_.get(); }
380 base::OneShotTimer* close_timer() { return &close_timer_; } 384 base::OneShotTimer* close_timer() { return &close_timer_; }
381 IndexedDBActiveBlobRegistry* active_blob_registry() { 385 IndexedDBActiveBlobRegistry* active_blob_registry() {
382 return &active_blob_registry_; 386 return &active_blob_registry_;
383 } 387 }
384 388
385 static scoped_refptr<IndexedDBBackingStore> Open( 389 static scoped_refptr<IndexedDBBackingStore> Open(
386 IndexedDBFactory* indexed_db_factory, 390 IndexedDBFactory* indexed_db_factory,
387 const url::Origin& origin, 391 const url::Origin& origin,
388 const base::FilePath& path_base, 392 const base::FilePath& path_base,
393 const IndexedDBDataFormatVersion& data_format_version,
389 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 394 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
390 IndexedDBDataLossInfo* data_loss_info, 395 IndexedDBDataLossInfo* data_loss_info,
391 bool* disk_full, 396 bool* disk_full,
392 base::SequencedTaskRunner* task_runner, 397 base::SequencedTaskRunner* task_runner,
393 bool clean_journal, 398 bool clean_journal,
394 leveldb::Status* status); 399 leveldb::Status* status);
395 static scoped_refptr<IndexedDBBackingStore> Open( 400 static scoped_refptr<IndexedDBBackingStore> Open(
396 IndexedDBFactory* indexed_db_factory, 401 IndexedDBFactory* indexed_db_factory,
397 const url::Origin& origin, 402 const url::Origin& origin,
398 const base::FilePath& path_base, 403 const base::FilePath& path_base,
404 const IndexedDBDataFormatVersion& data_format_version,
399 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 405 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
400 IndexedDBDataLossInfo* data_loss_info, 406 IndexedDBDataLossInfo* data_loss_info,
401 bool* disk_full, 407 bool* disk_full,
402 LevelDBFactory* leveldb_factory, 408 LevelDBFactory* leveldb_factory,
403 base::SequencedTaskRunner* task_runner, 409 base::SequencedTaskRunner* task_runner,
404 bool clean_journal, 410 bool clean_journal,
405 leveldb::Status* status); 411 leveldb::Status* status);
406 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( 412 static scoped_refptr<IndexedDBBackingStore> OpenInMemory(
407 const url::Origin& origin, 413 const url::Origin& origin,
414 const IndexedDBDataFormatVersion& data_format_version,
408 base::SequencedTaskRunner* task_runner, 415 base::SequencedTaskRunner* task_runner,
409 leveldb::Status* status); 416 leveldb::Status* status);
410 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( 417 static scoped_refptr<IndexedDBBackingStore> OpenInMemory(
411 const url::Origin& origin, 418 const url::Origin& origin,
419 const IndexedDBDataFormatVersion& data_format_version,
412 LevelDBFactory* leveldb_factory, 420 LevelDBFactory* leveldb_factory,
413 base::SequencedTaskRunner* task_runner, 421 base::SequencedTaskRunner* task_runner,
414 leveldb::Status* status); 422 leveldb::Status* status);
415 423
416 void GrantChildProcessPermissions(int child_process_id); 424 void GrantChildProcessPermissions(int child_process_id);
417 425
418 // Compact is public for testing. 426 // Compact is public for testing.
419 virtual void Compact(); 427 virtual void Compact();
420 virtual std::vector<base::string16> GetDatabaseNames(leveldb::Status*); 428 virtual std::vector<base::string16> GetDatabaseNames(leveldb::Status*);
421 virtual leveldb::Status GetIDBDatabaseMetaData( 429 virtual leveldb::Status GetIDBDatabaseMetaData(
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 blink::WebIDBCursorDirection, 591 blink::WebIDBCursorDirection,
584 leveldb::Status*); 592 leveldb::Status*);
585 593
586 protected: 594 protected:
587 friend class base::RefCounted<IndexedDBBackingStore>; 595 friend class base::RefCounted<IndexedDBBackingStore>;
588 596
589 IndexedDBBackingStore( 597 IndexedDBBackingStore(
590 IndexedDBFactory* indexed_db_factory, 598 IndexedDBFactory* indexed_db_factory,
591 const url::Origin& origin, 599 const url::Origin& origin,
592 const base::FilePath& blob_path, 600 const base::FilePath& blob_path,
601 const IndexedDBDataFormatVersion& data_format_version,
593 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 602 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
594 std::unique_ptr<LevelDBDatabase> db, 603 std::unique_ptr<LevelDBDatabase> db,
595 std::unique_ptr<LevelDBComparator> comparator, 604 std::unique_ptr<LevelDBComparator> comparator,
596 base::SequencedTaskRunner* task_runner); 605 base::SequencedTaskRunner* task_runner);
597 virtual ~IndexedDBBackingStore(); 606 virtual ~IndexedDBBackingStore();
598 607
599 bool is_incognito() const { return !indexed_db_factory_; } 608 bool is_incognito() const { return !indexed_db_factory_; }
600 609
601 leveldb::Status SetUpMetadata(); 610 leveldb::Status SetUpMetadata();
602 611
(...skipping 16 matching lines...) Expand all
619 // via StartJournalCleaningTimer(). 628 // via StartJournalCleaningTimer().
620 void CleanPrimaryJournalIgnoreReturn(); 629 void CleanPrimaryJournalIgnoreReturn();
621 630
622 private: 631 private:
623 FRIEND_TEST_ALL_PREFIXES(IndexedDBBackingStoreTest, ReadCorruptionInfo); 632 FRIEND_TEST_ALL_PREFIXES(IndexedDBBackingStoreTest, ReadCorruptionInfo);
624 633
625 static scoped_refptr<IndexedDBBackingStore> Create( 634 static scoped_refptr<IndexedDBBackingStore> Create(
626 IndexedDBFactory* indexed_db_factory, 635 IndexedDBFactory* indexed_db_factory,
627 const url::Origin& origin, 636 const url::Origin& origin,
628 const base::FilePath& blob_path, 637 const base::FilePath& blob_path,
638 const IndexedDBDataFormatVersion& data_format_version,
629 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 639 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
630 std::unique_ptr<LevelDBDatabase> db, 640 std::unique_ptr<LevelDBDatabase> db,
631 std::unique_ptr<LevelDBComparator> comparator, 641 std::unique_ptr<LevelDBComparator> comparator,
632 base::SequencedTaskRunner* task_runner, 642 base::SequencedTaskRunner* task_runner,
633 leveldb::Status* status); 643 leveldb::Status* status);
634 644
635 static bool ReadCorruptionInfo(const base::FilePath& path_base, 645 static bool ReadCorruptionInfo(const base::FilePath& path_base,
636 const url::Origin& origin, 646 const url::Origin& origin,
637 std::string* message); 647 std::string* message);
638 648
(...skipping 21 matching lines...) Expand all
660 leveldb::Status CleanUpBlobJournal(const std::string& level_db_key) const; 670 leveldb::Status CleanUpBlobJournal(const std::string& level_db_key) const;
661 671
662 // Synchronously delete the files and/or directories on disk referenced by 672 // Synchronously delete the files and/or directories on disk referenced by
663 // the blob journal. 673 // the blob journal.
664 leveldb::Status CleanUpBlobJournalEntries( 674 leveldb::Status CleanUpBlobJournalEntries(
665 const BlobJournalType& journal) const; 675 const BlobJournalType& journal) const;
666 676
667 IndexedDBFactory* indexed_db_factory_; 677 IndexedDBFactory* indexed_db_factory_;
668 const url::Origin origin_; 678 const url::Origin origin_;
669 base::FilePath blob_path_; 679 base::FilePath blob_path_;
680 const IndexedDBDataFormatVersion data_format_version_;
670 681
671 // The origin identifier is a key prefix unique to the origin used in the 682 // The origin identifier is a key prefix unique to the origin used in the
672 // leveldb backing store to partition data by origin. It is a normalized 683 // leveldb backing store to partition data by origin. It is a normalized
673 // version of the origin URL with a versioning suffix appended, e.g. 684 // version of the origin URL with a versioning suffix appended, e.g.
674 // "http_localhost_81@1" Since only one origin is stored per backing store 685 // "http_localhost_81@1" Since only one origin is stored per backing store
675 // this is redundant but necessary for backwards compatibility; the suffix 686 // this is redundant but necessary for backwards compatibility; the suffix
676 // provides for future flexibility. 687 // provides for future flexibility.
677 const std::string origin_identifier_; 688 const std::string origin_identifier_;
678 689
679 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 690 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
(...skipping 13 matching lines...) Expand all
693 // complete. While > 0, temporary journal entries may exist so out-of-band 704 // complete. While > 0, temporary journal entries may exist so out-of-band
694 // journal cleaning must be deferred. 705 // journal cleaning must be deferred.
695 size_t committing_transaction_count_; 706 size_t committing_transaction_count_;
696 707
697 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); 708 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore);
698 }; 709 };
699 710
700 } // namespace content 711 } // namespace content
701 712
702 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ 713 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698