OLD | NEW |
---|---|
(Empty) | |
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 | |
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 "webkit/common/blob/shareable_file_reference.h" | |
14 | |
15 namespace content { | |
16 | |
17 class IndexedDBBackingStore; | |
18 | |
19 class IndexedDBActiveBlobRegistry { | |
20 public: | |
21 IndexedDBActiveBlobRegistry(IndexedDBBackingStore* backing_store); | |
22 ~IndexedDBActiveBlobRegistry(); | |
23 | |
24 // These functions should be run on backing_store_->task_runner(). | |
25 void MarkUsed(int64 database_id, int64 blob_key); | |
26 void MarkUnused(int64 database_id, int64 blob_key); | |
27 // Use DatabaseMetaDataKey::AllBlobsKey for "the whole database". | |
28 bool MarkDeletedCheckIfUsed(int64 database_id, int64 blob_key); | |
29 | |
30 // These functions can be called from any thread, but GetMarkUsedCallback's | |
31 // return value should be called on the TaskRunner for backing_store_. | |
32 void MarkUnusedThreadSafe(int64 database_id, int64 blob_key, | |
33 const base::FilePath& unused); | |
34 webkit_blob::ShareableFileReference::FinalReleaseCallback | |
35 GetReleaseCallback(int64 database_id, int64 blob_key); | |
36 base::Closure GetMarkUsedCallback(int64 database_id, int64 blob_key); | |
jsbell
2013/09/13 00:12:21
Add comment about the lifetime rules for this clos
ericu
2013/11/20 23:05:39
Added a comment. The reason it's safe is beyond t
| |
37 | |
38 private: | |
39 // Maps blob_key -> IsDeleted; if the record's absent, it's not in active use | |
40 // and we don't care if it's deleted. | |
41 typedef std::map<int64, bool> SingleDBMap; | |
42 // Maps DB ID -> SingleDBMap | |
43 typedef std::map<int64, SingleDBMap> AllDBsMap; | |
44 typedef std::set<int64> DeletedDBSet; | |
45 | |
46 AllDBsMap use_counts_; | |
47 DeletedDBSet deleted_dbs_; | |
48 // Think of this as a scoped_refptr, but it's manually managed. We'll hold a | |
jsbell
2013/09/13 00:12:21
Reword - not clear what "this" refers to.
ericu
2013/11/20 23:05:39
Done.
| |
49 // reference as long as there's a blob registered in use_counts_, but not | |
50 // otherwise. Ideally the blobs would hold the references themselves, but | |
51 // they live on the wrong thread. | |
52 IndexedDBBackingStore* backing_store_; | |
53 DISALLOW_COPY_AND_ASSIGN(IndexedDBActiveBlobRegistry); | |
54 }; | |
55 | |
56 } // namespace content | |
57 | |
58 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_ | |
OLD | NEW |