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

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

Issue 266333002: Add most of the metadata-handling code for blobs. It's not quite all there, but (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Coalesced fake calls Created 6 years, 7 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 | Annotate | Revision Log
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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 int64 index_id, 257 int64 index_id,
258 const IndexedDBKey& key, 258 const IndexedDBKey& key,
259 scoped_ptr<IndexedDBKey>* found_primary_key, 259 scoped_ptr<IndexedDBKey>* found_primary_key,
260 bool* exists) WARN_UNUSED_RESULT; 260 bool* exists) WARN_UNUSED_RESULT;
261 261
262 // Public for IndexedDBActiveBlobRegistry::ReleaseBlobRef. 262 // Public for IndexedDBActiveBlobRegistry::ReleaseBlobRef.
263 virtual void ReportBlobUnused(int64 database_id, int64 blob_key); 263 virtual void ReportBlobUnused(int64 database_id, int64 blob_key);
264 264
265 base::FilePath GetBlobFileName(int64 database_id, int64 key); 265 base::FilePath GetBlobFileName(int64 database_id, int64 key);
266 266
267 class Transaction;
268
267 class Cursor { 269 class Cursor {
268 public: 270 public:
269 virtual ~Cursor(); 271 virtual ~Cursor();
270 272
271 enum IteratorState { 273 enum IteratorState {
272 READY = 0, 274 READY = 0,
273 SEEK 275 SEEK
274 }; 276 };
275 277
276 struct CursorOptions { 278 struct CursorOptions {
(...skipping 24 matching lines...) Expand all
301 bool Advance(uint32 count, leveldb::Status*); 303 bool Advance(uint32 count, leveldb::Status*);
302 bool FirstSeek(leveldb::Status*); 304 bool FirstSeek(leveldb::Status*);
303 305
304 virtual Cursor* Clone() = 0; 306 virtual Cursor* Clone() = 0;
305 virtual const IndexedDBKey& primary_key() const; 307 virtual const IndexedDBKey& primary_key() const;
306 virtual IndexedDBValue* value() = 0; 308 virtual IndexedDBValue* value() = 0;
307 virtual const RecordIdentifier& record_identifier() const; 309 virtual const RecordIdentifier& record_identifier() const;
308 virtual bool LoadCurrentRow() = 0; 310 virtual bool LoadCurrentRow() = 0;
309 311
310 protected: 312 protected:
311 Cursor(LevelDBTransaction* transaction, 313 Cursor(scoped_refptr<IndexedDBBackingStore> backing_store,
314 Transaction* transaction,
315 int64 database_id,
312 const CursorOptions& cursor_options); 316 const CursorOptions& cursor_options);
313 explicit Cursor(const IndexedDBBackingStore::Cursor* other); 317 explicit Cursor(const IndexedDBBackingStore::Cursor* other);
314 318
315 virtual std::string EncodeKey(const IndexedDBKey& key) = 0; 319 virtual std::string EncodeKey(const IndexedDBKey& key) = 0;
316 virtual std::string EncodeKey(const IndexedDBKey& key, 320 virtual std::string EncodeKey(const IndexedDBKey& key,
317 const IndexedDBKey& primary_key) = 0; 321 const IndexedDBKey& primary_key) = 0;
318 322
319 bool IsPastBounds() const; 323 bool IsPastBounds() const;
320 bool HaveEnteredRange() const; 324 bool HaveEnteredRange() const;
321 325
322 LevelDBTransaction* transaction_; 326 IndexedDBBackingStore* backing_store_;
jsbell 2014/05/06 00:24:16 We should probably update the ownership graph soon
ericu 2014/05/06 17:26:20 Updated. There's nothing in the key about what co
327 Transaction* transaction_;
328 int64 database_id_;
323 const CursorOptions cursor_options_; 329 const CursorOptions cursor_options_;
324 scoped_ptr<LevelDBIterator> iterator_; 330 scoped_ptr<LevelDBIterator> iterator_;
325 scoped_ptr<IndexedDBKey> current_key_; 331 scoped_ptr<IndexedDBKey> current_key_;
326 IndexedDBBackingStore::RecordIdentifier record_identifier_; 332 IndexedDBBackingStore::RecordIdentifier record_identifier_;
327 }; 333 };
328 334
329 virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor( 335 virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor(
330 IndexedDBBackingStore::Transaction* transaction, 336 IndexedDBBackingStore::Transaction* transaction,
331 int64 database_id, 337 int64 database_id,
332 int64 object_store_id, 338 int64 object_store_id,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 transaction_ = NULL; 398 transaction_ = NULL;
393 } 399 }
394 void PutBlobInfo(int64 database_id, 400 void PutBlobInfo(int64 database_id,
395 int64 object_store_id, 401 int64 object_store_id,
396 const std::string& object_store_data_key, 402 const std::string& object_store_data_key,
397 std::vector<IndexedDBBlobInfo>*, 403 std::vector<IndexedDBBlobInfo>*,
398 ScopedVector<webkit_blob::BlobDataHandle>* handles); 404 ScopedVector<webkit_blob::BlobDataHandle>* handles);
399 405
400 LevelDBTransaction* transaction() { return transaction_; } 406 LevelDBTransaction* transaction() { return transaction_; }
401 407
408 leveldb::Status GetBlobInfoForRecord(
409 int64 database_id,
410 const std::string& object_store_data_key,
411 IndexedDBValue* value);
412
402 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored 413 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored
403 // under that key. 414 // under that key.
404 typedef std::vector<std::pair<BlobEntryKey, std::string> > 415 typedef std::vector<std::pair<BlobEntryKey, std::string> >
405 BlobEntryKeyValuePairVec; 416 BlobEntryKeyValuePairVec;
406 417
407 class WriteDescriptor { 418 class WriteDescriptor {
408 public: 419 public:
409 WriteDescriptor(const GURL& url, int64_t key); 420 WriteDescriptor(const GURL& url, int64_t key);
410 WriteDescriptor(const base::FilePath& path, int64_t key); 421 WriteDescriptor(const base::FilePath& path, int64_t key);
411 422
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 const base::FilePath& blob_path, 479 const base::FilePath& blob_path,
469 net::URLRequestContext* request_context, 480 net::URLRequestContext* request_context,
470 scoped_ptr<LevelDBDatabase> db, 481 scoped_ptr<LevelDBDatabase> db,
471 scoped_ptr<LevelDBComparator> comparator, 482 scoped_ptr<LevelDBComparator> comparator,
472 base::TaskRunner* task_runner); 483 base::TaskRunner* task_runner);
473 virtual ~IndexedDBBackingStore(); 484 virtual ~IndexedDBBackingStore();
474 friend class base::RefCounted<IndexedDBBackingStore>; 485 friend class base::RefCounted<IndexedDBBackingStore>;
475 486
476 bool is_incognito() const { return !indexed_db_factory_; } 487 bool is_incognito() const { return !indexed_db_factory_; }
477 488
489 bool SetUpMetadata();
490
478 virtual bool WriteBlobFile( 491 virtual bool WriteBlobFile(
479 int64 database_id, 492 int64 database_id,
480 const Transaction::WriteDescriptor& descriptor, 493 const Transaction::WriteDescriptor& descriptor,
481 Transaction::ChainedBlobWriter* chained_blob_writer); 494 Transaction::ChainedBlobWriter* chained_blob_writer);
482 virtual bool RemoveBlobFile(int64 database_id, int64 key); 495 virtual bool RemoveBlobFile(int64 database_id, int64 key);
483 virtual void StartJournalCleaningTimer(); 496 virtual void StartJournalCleaningTimer();
484 void CleanPrimaryJournalIgnoreReturn(); 497 void CleanPrimaryJournalIgnoreReturn();
485 498
486 private: 499 private:
487 static scoped_refptr<IndexedDBBackingStore> Create( 500 static scoped_refptr<IndexedDBBackingStore> Create(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 scoped_ptr<LevelDBComparator> comparator_; 547 scoped_ptr<LevelDBComparator> comparator_;
535 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ 548 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_
536 // will hold a reference to this backing store. 549 // will hold a reference to this backing store.
537 IndexedDBActiveBlobRegistry active_blob_registry_; 550 IndexedDBActiveBlobRegistry active_blob_registry_;
538 base::OneShotTimer<IndexedDBBackingStore> close_timer_; 551 base::OneShotTimer<IndexedDBBackingStore> close_timer_;
539 }; 552 };
540 553
541 } // namespace content 554 } // namespace content
542 555
543 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ 556 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698