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