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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 virtual ~Transaction(); | 363 virtual ~Transaction(); |
364 virtual void Begin(); | 364 virtual void Begin(); |
365 virtual leveldb::Status Commit(); | 365 virtual leveldb::Status Commit(); |
366 virtual void Rollback(); | 366 virtual void Rollback(); |
367 void Reset() { | 367 void Reset() { |
368 backing_store_ = NULL; | 368 backing_store_ = NULL; |
369 transaction_ = NULL; | 369 transaction_ = NULL; |
370 } | 370 } |
371 void PutBlobInfo(int64 database_id, | 371 void PutBlobInfo(int64 database_id, |
372 int64 object_store_id, | 372 int64 object_store_id, |
373 const std::string& key, | 373 const std::string& object_store_data_key, |
374 std::vector<IndexedDBBlobInfo>*, | 374 std::vector<IndexedDBBlobInfo>*, |
375 ScopedVector<webkit_blob::BlobDataHandle>* handles); | 375 ScopedVector<webkit_blob::BlobDataHandle>* handles); |
376 | 376 |
377 LevelDBTransaction* transaction() { return transaction_; } | 377 LevelDBTransaction* transaction() { return transaction_; } |
378 | 378 |
379 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored | 379 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored |
380 // under that key. | 380 // under that key. |
381 typedef std::vector<std::pair<BlobEntryKey, std::string> > | 381 typedef std::vector<std::pair<BlobEntryKey, std::string> > |
382 BlobEntryKeyValuePairVec; | 382 BlobEntryKeyValuePairVec; |
383 | 383 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 scoped_ptr<LevelDBComparator> comparator, | 464 scoped_ptr<LevelDBComparator> comparator, |
465 base::TaskRunner* task_runner); | 465 base::TaskRunner* task_runner); |
466 virtual ~IndexedDBBackingStore(); | 466 virtual ~IndexedDBBackingStore(); |
467 friend class base::RefCounted<IndexedDBBackingStore>; | 467 friend class base::RefCounted<IndexedDBBackingStore>; |
468 | 468 |
469 virtual bool WriteBlobFile( | 469 virtual bool WriteBlobFile( |
470 int64 database_id, | 470 int64 database_id, |
471 const Transaction::WriteDescriptor& descriptor, | 471 const Transaction::WriteDescriptor& descriptor, |
472 Transaction::ChainedBlobWriter* chained_blob_writer); | 472 Transaction::ChainedBlobWriter* chained_blob_writer); |
473 virtual bool RemoveBlobFile(int64 database_id, int64 key); | 473 virtual bool RemoveBlobFile(int64 database_id, int64 key); |
| 474 virtual void StartJournalCleaningTimer(); |
| 475 void CleanPrimaryJournalIgnoreReturn(); |
474 | 476 |
475 private: | 477 private: |
476 static scoped_refptr<IndexedDBBackingStore> Create( | 478 static scoped_refptr<IndexedDBBackingStore> Create( |
477 IndexedDBFactory* indexed_db_factory, | 479 IndexedDBFactory* indexed_db_factory, |
478 const GURL& origin_url, | 480 const GURL& origin_url, |
479 const base::FilePath& blob_path, | 481 const base::FilePath& blob_path, |
480 net::URLRequestContext* request_context, | 482 net::URLRequestContext* request_context, |
481 scoped_ptr<LevelDBDatabase> db, | 483 scoped_ptr<LevelDBDatabase> db, |
482 scoped_ptr<LevelDBComparator> comparator, | 484 scoped_ptr<LevelDBComparator> comparator, |
483 base::TaskRunner* task_runner); | 485 base::TaskRunner* task_runner); |
484 | 486 |
485 static bool ReadCorruptionInfo(const base::FilePath& path_base, | 487 static bool ReadCorruptionInfo(const base::FilePath& path_base, |
486 const GURL& origin_url, | 488 const GURL& origin_url, |
487 std::string& message); | 489 std::string& message); |
488 | 490 |
489 leveldb::Status FindKeyInIndex( | 491 leveldb::Status FindKeyInIndex( |
490 IndexedDBBackingStore::Transaction* transaction, | 492 IndexedDBBackingStore::Transaction* transaction, |
491 int64 database_id, | 493 int64 database_id, |
492 int64 object_store_id, | 494 int64 object_store_id, |
493 int64 index_id, | 495 int64 index_id, |
494 const IndexedDBKey& key, | 496 const IndexedDBKey& key, |
495 std::string* found_encoded_primary_key, | 497 std::string* found_encoded_primary_key, |
496 bool* found); | 498 bool* found); |
497 leveldb::Status GetIndexes(int64 database_id, | 499 leveldb::Status GetIndexes(int64 database_id, |
498 int64 object_store_id, | 500 int64 object_store_id, |
499 IndexedDBObjectStoreMetadata::IndexMap* map) | 501 IndexedDBObjectStoreMetadata::IndexMap* map) |
500 WARN_UNUSED_RESULT; | 502 WARN_UNUSED_RESULT; |
501 bool RemoveBlobDirectory(int64 database_id); | 503 bool RemoveBlobDirectory(int64 database_id); |
| 504 leveldb::Status CleanUpBlobJournal(const std::string& level_db_key); |
502 | 505 |
503 IndexedDBFactory* indexed_db_factory_; | 506 IndexedDBFactory* indexed_db_factory_; |
504 const GURL origin_url_; | 507 const GURL origin_url_; |
505 base::FilePath blob_path_; | 508 base::FilePath blob_path_; |
506 | 509 |
507 // The origin identifier is a key prefix unique to the origin used in the | 510 // The origin identifier is a key prefix unique to the origin used in the |
508 // leveldb backing store to partition data by origin. It is a normalized | 511 // leveldb backing store to partition data by origin. It is a normalized |
509 // version of the origin URL with a versioning suffix appended, e.g. | 512 // version of the origin URL with a versioning suffix appended, e.g. |
510 // "http_localhost_81@1" Since only one origin is stored per backing store | 513 // "http_localhost_81@1" Since only one origin is stored per backing store |
511 // this is redundant but necessary for backwards compatibility; the suffix | 514 // this is redundant but necessary for backwards compatibility; the suffix |
512 // provides for future flexibility. | 515 // provides for future flexibility. |
513 const std::string origin_identifier_; | 516 const std::string origin_identifier_; |
514 | 517 |
515 net::URLRequestContext* request_context_; | 518 net::URLRequestContext* request_context_; |
516 base::TaskRunner* task_runner_; | 519 base::TaskRunner* task_runner_; |
517 std::set<int> child_process_ids_granted_; | 520 std::set<int> child_process_ids_granted_; |
| 521 base::OneShotTimer<IndexedDBBackingStore> journal_cleaning_timer_; |
518 | 522 |
519 scoped_ptr<LevelDBDatabase> db_; | 523 scoped_ptr<LevelDBDatabase> db_; |
520 scoped_ptr<LevelDBComparator> comparator_; | 524 scoped_ptr<LevelDBComparator> comparator_; |
521 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ | 525 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ |
522 // will hold a reference to this backing store. | 526 // will hold a reference to this backing store. |
523 IndexedDBActiveBlobRegistry active_blob_registry_; | 527 IndexedDBActiveBlobRegistry active_blob_registry_; |
524 base::OneShotTimer<IndexedDBBackingStore> close_timer_; | 528 base::OneShotTimer<IndexedDBBackingStore> close_timer_; |
525 }; | 529 }; |
526 | 530 |
527 } // namespace content | 531 } // namespace content |
528 | 532 |
529 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 533 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
OLD | NEW |