OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ACTIVE_BLOB_REGISTRY_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 24 matching lines...) Expand all Loading... |
35 GetFinalReleaseCallback(int64 database_id, int64 blob_key); | 35 GetFinalReleaseCallback(int64 database_id, int64 blob_key); |
36 // This closure holds a raw pointer to the IndexedDBActiveBlobRegistry, | 36 // This closure holds a raw pointer to the IndexedDBActiveBlobRegistry, |
37 // and may not be called after it is deleted. | 37 // and may not be called after it is deleted. |
38 base::Closure GetAddBlobRefCallback(int64 database_id, int64 blob_key); | 38 base::Closure GetAddBlobRefCallback(int64 database_id, int64 blob_key); |
39 // Call this to force the registry to drop its use counts, permitting the | 39 // Call this to force the registry to drop its use counts, permitting the |
40 // factory to drop any blob-related refcount for the backing store. | 40 // factory to drop any blob-related refcount for the backing store. |
41 // This will also turn any outstanding callbacks into no-ops. | 41 // This will also turn any outstanding callbacks into no-ops. |
42 void ForceShutdown(); | 42 void ForceShutdown(); |
43 | 43 |
44 private: | 44 private: |
| 45 // Maps blob_key -> IsDeleted; if the record's absent, it's not in active use |
| 46 // and we don't care if it's deleted. |
| 47 typedef std::map<int64, bool> SingleDBMap; |
| 48 // Maps DB ID -> SingleDBMap |
| 49 typedef std::map<int64, SingleDBMap> AllDBsMap; |
| 50 typedef std::set<int64> DeletedDBSet; |
| 51 |
45 void AddBlobRef(int64 database_id, int64 blob_key); | 52 void AddBlobRef(int64 database_id, int64 blob_key); |
46 void ReleaseBlobRef(int64 database_id, int64 blob_key); | 53 void ReleaseBlobRef(int64 database_id, int64 blob_key); |
47 static void ReleaseBlobRefThreadSafe( | 54 static void ReleaseBlobRefThreadSafe( |
48 scoped_refptr<base::TaskRunner> task_runner, | 55 scoped_refptr<base::TaskRunner> task_runner, |
49 base::WeakPtr<IndexedDBActiveBlobRegistry> weak_ptr, | 56 base::WeakPtr<IndexedDBActiveBlobRegistry> weak_ptr, |
50 int64 database_id, | 57 int64 database_id, |
51 int64 blob_key, | 58 int64 blob_key, |
52 const base::FilePath& unused); | 59 const base::FilePath& unused); |
53 | 60 |
54 // Maps blob_key -> IsDeleted; if the record's absent, it's not in active use | |
55 // and we don't care if it's deleted. | |
56 typedef std::map<int64, bool> SingleDBMap; | |
57 // Maps DB ID -> SingleDBMap | |
58 typedef std::map<int64, SingleDBMap> AllDBsMap; | |
59 typedef std::set<int64> DeletedDBSet; | |
60 | |
61 AllDBsMap use_tracker_; | 61 AllDBsMap use_tracker_; |
62 DeletedDBSet deleted_dbs_; | 62 DeletedDBSet deleted_dbs_; |
63 // As long as we've got blobs registered in use_tracker_, | 63 // As long as we've got blobs registered in use_tracker_, |
64 // backing_store_->factory() will keep backing_store_ alive for us. And | 64 // backing_store_->factory() will keep backing_store_ alive for us. And |
65 // backing_store_ owns us, so we'll stay alive as long as we're needed. | 65 // backing_store_ owns us, so we'll stay alive as long as we're needed. |
66 IndexedDBBackingStore* backing_store_; | 66 IndexedDBBackingStore* backing_store_; |
67 base::WeakPtrFactory<IndexedDBActiveBlobRegistry> weak_factory_; | 67 base::WeakPtrFactory<IndexedDBActiveBlobRegistry> weak_factory_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(IndexedDBActiveBlobRegistry); | 69 DISALLOW_COPY_AND_ASSIGN(IndexedDBActiveBlobRegistry); |
70 }; | 70 }; |
71 | 71 |
72 } // namespace content | 72 } // namespace content |
73 | 73 |
74 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ | 74 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ |
OLD | NEW |