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

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

Issue 2448353002: [BlobAsync] Moving async handling into BlobStorageContext & quota out. (Closed)
Patch Set: comments Created 4 years, 1 month 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..2b2dbdd13f280ba6edd86cdcb05ce9e27495a557 100644
--- a/storage/browser/blob/blob_storage_registry.h
+++ b/storage/browser/blob/blob_storage_registry.h
@@ -15,73 +15,31 @@
#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 "storage/browser/storage_browser_export.h"
#include "storage/common/blob_storage/blob_storage_constants.h"
class GURL;
namespace storage {
+class BlobDataHandle;
+class BlobEntry;
+class ShareableBlobDataItem;
// This class stores the blob data in the various states of construction, as
// well as URL mappings to blob uuids.
// Implementation notes:
-// * There is no implicit refcounting in this class, except for setting the
-// refcount to 1 on registration.
// * When removing a uuid registration, we do not check for URL mappings to that
// 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);
+ BlobEntry* 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 +49,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;
+ BlobEntry* GetEntry(const std::string& uuid);
+ const BlobEntry* 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 +65,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);
+ BlobEntry* 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<BlobEntry>>;
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