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

Unified Diff: content/browser/indexed_db/indexed_db_active_blob_registry.h

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge fixes [builds, untested] Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_active_blob_registry.h
diff --git a/content/browser/indexed_db/indexed_db_active_blob_registry.h b/content/browser/indexed_db/indexed_db_active_blob_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..b4f1fc6deffbd29a4608e1656f073eb0b461ab5c
--- /dev/null
+++ b/content/browser/indexed_db/indexed_db_active_blob_registry.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_
+#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_
+
+#include <map>
+#include <set>
+#include <utility>
+#include "base/basictypes.h"
+#include "base/files/file_path.h"
+#include "webkit/common/blob/shareable_file_reference.h"
+
+namespace content {
+
+class IndexedDBBackingStore;
+
+class IndexedDBActiveBlobRegistry {
+public:
+ IndexedDBActiveBlobRegistry(IndexedDBBackingStore* backing_store);
+ ~IndexedDBActiveBlobRegistry();
+
+ // These functions should be run on backing_store_->task_runner().
+ void MarkUsed(int64 database_id, int64 blob_key);
+ void MarkUnused(int64 database_id, int64 blob_key);
+ // Use DatabaseMetaDataKey::AllBlobsKey for "the whole database".
+ bool MarkDeletedCheckIfUsed(int64 database_id, int64 blob_key);
+
+ // These functions can be called from any thread, but GetMarkUsedCallback's
+ // return value should be called on the TaskRunner for backing_store_.
+ void MarkUnusedThreadSafe(int64 database_id, int64 blob_key,
+ const base::FilePath& unused);
+ webkit_blob::ShareableFileReference::FinalReleaseCallback
+ GetReleaseCallback(int64 database_id, int64 blob_key);
+ 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
+
+private:
+ // Maps blob_key -> IsDeleted; if the record's absent, it's not in active use
+ // and we don't care if it's deleted.
+ typedef std::map<int64, bool> SingleDBMap;
+ // Maps DB ID -> SingleDBMap
+ typedef std::map<int64, SingleDBMap> AllDBsMap;
+ typedef std::set<int64> DeletedDBSet;
+
+ AllDBsMap use_counts_;
+ DeletedDBSet deleted_dbs_;
+ // 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.
+ // reference as long as there's a blob registered in use_counts_, but not
+ // otherwise. Ideally the blobs would hold the references themselves, but
+ // they live on the wrong thread.
+ IndexedDBBackingStore* backing_store_;
+ DISALLOW_COPY_AND_ASSIGN(IndexedDBActiveBlobRegistry);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_ACTIVE_BLOB_REGISTRY_H_

Powered by Google App Engine
This is Rietveld 408576698