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

Unified Diff: storage/browser/blob/blob_storage_registry.h

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « storage/browser/blob/blob_storage_context.cc ('k') | storage/browser/blob/blob_storage_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/blob/blob_storage_registry.h
diff --git a/storage/browser/blob/blob_storage_registry.h b/storage/browser/blob/blob_storage_registry.h
index 5211094b61a2bba35c6085525f865e4c2c27d96d..dbeb2f0094eff01fa231b7b1833a97895be2038e 100644
--- a/storage/browser/blob/blob_storage_registry.h
+++ b/storage/browser/blob/blob_storage_registry.h
@@ -15,13 +15,16 @@
#include "base/callback_forward.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
-#include "storage/browser/blob/internal_blob_data.h"
+#include "base/optional.h"
#include "storage/browser/storage_browser_export.h"
#include "storage/common/blob_storage/blob_storage_constants.h"
class GURL;
namespace storage {
+class BlobDataHandle;
+class InternalBlobData;
+class ShareableBlobDataItem;
// This class stores the blob data in the various states of construction, as
// well as URL mappings to blob uuids.
@@ -32,56 +35,14 @@ namespace storage {
// uuid. The user must keep track of these.
class STORAGE_EXPORT BlobStorageRegistry {
public:
- // True means the blob was constructed successfully, and false means that
- // there was an error, which is reported in the second argument.
- using BlobConstructedCallback =
- base::Callback<void(bool, IPCBlobCreationCancelCode)>;
-
- enum class BlobState {
- // The blob is pending transportation from the renderer. This is the default
- // state on entry construction.
- PENDING,
- // The blob is complete and can be read from.
- COMPLETE,
- // The blob is broken and no longer holds data. This happens when there was
- // a problem constructing the blob, or we've run out of memory.
- BROKEN
- };
-
- struct STORAGE_EXPORT Entry {
- size_t refcount;
- BlobState state;
- std::vector<BlobConstructedCallback> build_completion_callbacks;
-
- // Only applicable if the state == BROKEN.
- IPCBlobCreationCancelCode broken_reason =
- IPCBlobCreationCancelCode::UNKNOWN;
-
- // data and data_builder are mutually exclusive.
- std::unique_ptr<InternalBlobData> data;
- std::unique_ptr<InternalBlobData::Builder> data_builder;
-
- std::string content_type;
- std::string content_disposition;
-
- Entry() = delete;
- Entry(int refcount, BlobState state);
- ~Entry();
-
- // Performs a test-and-set on the state of the given blob. If the state
- // isn't as expected, we return false. Otherwise we set the new state and
- // return true.
- bool TestAndSetState(BlobState expected, BlobState set);
- };
-
BlobStorageRegistry();
~BlobStorageRegistry();
// Creates the blob entry with a refcount of 1 and a state of PENDING. If
// the blob is already in use, we return null.
- Entry* CreateEntry(const std::string& uuid,
- const std::string& content_type,
- const std::string& content_disposition);
+ InternalBlobData* CreateEntry(const std::string& uuid,
+ const std::string& content_type,
+ const std::string& content_disposition);
// Removes the blob entry with the given uuid. This does not unmap any
// URLs that are pointing to this uuid. Returns if the entry existed.
@@ -91,8 +52,8 @@ class STORAGE_EXPORT BlobStorageRegistry {
// Gets the blob entry for the given uuid. Returns nullptr if the entry
// does not exist.
- Entry* GetEntry(const std::string& uuid);
- const Entry* GetEntry(const std::string& uuid) const;
+ InternalBlobData* GetEntry(const std::string& uuid);
+ const InternalBlobData* GetEntry(const std::string& uuid) const;
// Creates a url mapping from blob uuid to the given url. Returns false if
// the uuid isn't mapped to an entry or if there already is a map for the URL.
@@ -107,14 +68,15 @@ class STORAGE_EXPORT BlobStorageRegistry {
// Returns the entry from the given url, and optionally populates the uuid for
// that entry. Returns a nullptr if the mapping or entry doesn't exist.
- Entry* GetEntryFromURL(const GURL& url, std::string* uuid);
+ InternalBlobData* GetEntryFromURL(const GURL& url, std::string* uuid);
size_t blob_count() const { return blob_map_.size(); }
size_t url_count() const { return url_to_uuid_.size(); }
private:
friend class ViewBlobInternalsJob;
- using BlobMap = base::ScopedPtrHashMap<std::string, std::unique_ptr<Entry>>;
+ using BlobMap =
+ base::ScopedPtrHashMap<std::string, std::unique_ptr<InternalBlobData>>;
using URLMap = std::map<GURL, std::string>;
BlobMap blob_map_;
« no previous file with comments | « storage/browser/blob/blob_storage_context.cc ('k') | storage/browser/blob/blob_storage_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698