Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
|
jsbell
2014/03/20 18:04:33
2014 - here and in other new files
ericu
2014/03/25 01:22:14
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ | |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <set> | |
| 10 #include <utility> | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/files/file_path.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "content/common/content_export.h" | |
| 15 #include "webkit/common/blob/shareable_file_reference.h" | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 class IndexedDBBackingStore; | |
| 20 | |
| 21 class CONTENT_EXPORT IndexedDBActiveBlobRegistry { | |
| 22 public: | |
| 23 IndexedDBActiveBlobRegistry(IndexedDBBackingStore* backing_store); | |
| 24 ~IndexedDBActiveBlobRegistry(); | |
| 25 | |
| 26 // Most methods of this class, and the closure returned by | |
| 27 // GetAddBlobRefCallback, should only be called on the backing_store's task | |
| 28 // runner. The exception is the closure returned by GetFinalReleaseCallback, | |
| 29 // which just calls ReleaseBlobRefThreadSafe. | |
| 30 | |
| 31 // Use DatabaseMetaDataKey::AllBlobsKey for "the whole database". | |
| 32 bool MarkDeletedCheckIfUsed(int64 database_id, int64 blob_key); | |
| 33 | |
| 34 webkit_blob::ShareableFileReference::FinalReleaseCallback | |
| 35 GetFinalReleaseCallback(int64 database_id, int64 blob_key); | |
|
cmumford
2014/03/24 23:14:35
These two functions have the word "get" in their n
ericu
2014/03/25 01:22:14
No, they grab weak pointers from a WeakPointerFact
| |
| 36 // This closure holds a raw pointer to the IndexedDBActiveBlobRegistry, | |
| 37 // and may not be called after it is deleted. | |
| 38 base::Closure GetAddBlobRefCallback(int64 database_id, int64 blob_key); | |
| 39 // Call this to force the registry to drop its reference to the backing store. | |
| 40 // This will also turn any outstanding callbacks into no-ops. | |
| 41 void ForceShutdown(); | |
| 42 | |
| 43 private: | |
| 44 void AddBlobRef(int64 database_id, int64 blob_key); | |
| 45 void ReleaseBlobRef(int64 database_id, int64 blob_key); | |
| 46 static void ReleaseBlobRefThreadSafe( | |
| 47 scoped_refptr<base::TaskRunner> task_runner, | |
| 48 base::WeakPtr<IndexedDBActiveBlobRegistry> weak_ptr, | |
| 49 int64 database_id, | |
| 50 int64 blob_key, | |
| 51 const base::FilePath& unused); | |
| 52 | |
| 53 // Maps blob_key -> IsDeleted; if the record's absent, it's not in active use | |
| 54 // and we don't care if it's deleted. | |
| 55 typedef std::map<int64, bool> SingleDBMap; | |
| 56 // Maps DB ID -> SingleDBMap | |
| 57 typedef std::map<int64, SingleDBMap> AllDBsMap; | |
| 58 typedef std::set<int64> DeletedDBSet; | |
| 59 | |
| 60 AllDBsMap use_tracker_; | |
| 61 DeletedDBSet deleted_dbs_; | |
| 62 // As long as we've got blobs registered in use_tracker_, | |
| 63 // backing_store_->factory() will keep backing_store_ alive for us. And | |
| 64 // backing_store_ owns us, so we'll stay alive as long as we're needed. | |
| 65 IndexedDBBackingStore* backing_store_; | |
| 66 base::WeakPtrFactory<IndexedDBActiveBlobRegistry> weak_factory_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(IndexedDBActiveBlobRegistry); | |
| 69 }; | |
| 70 | |
| 71 } // namespace content | |
| 72 | |
| 73 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ | |
| OLD | NEW |