Chromium Code Reviews| Index: storage/browser/blob/blob_storage_context.h |
| diff --git a/storage/browser/blob/blob_storage_context.h b/storage/browser/blob/blob_storage_context.h |
| index 8553d0266d2d8b6338a176f4e9d9ce9d7675fa85..d1531d65b2db897ec95f0185c543829bbb88924e 100644 |
| --- a/storage/browser/blob/blob_storage_context.h |
| +++ b/storage/browser/blob/blob_storage_context.h |
| @@ -18,7 +18,9 @@ |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/single_thread_task_runner.h" |
| #include "storage/browser/blob/blob_data_handle.h" |
| +#include "storage/browser/blob/blob_memory_controller.h" |
| #include "storage/browser/blob/blob_storage_registry.h" |
| #include "storage/browser/blob/internal_blob_data.h" |
| #include "storage/browser/storage_browser_export.h" |
| @@ -75,14 +77,51 @@ class STORAGE_EXPORT BlobStorageContext |
| bool RegisterPublicBlobURL(const GURL& url, const std::string& uuid); |
| void RevokePublicBlobURL(const GURL& url); |
| - size_t memory_usage() const { return memory_usage_; } |
| size_t blob_count() const { return registry_.blob_count(); } |
|
michaeln
2016/07/07 20:05:21
terminology things...
finished vs complete vs br
|
| - size_t memory_available() const { |
| - return kBlobStorageMaxMemoryUsage - memory_usage_; |
| - } |
| const BlobStorageRegistry& registry() { return registry_; } |
| + void EnableDisk(const base::FilePath storage_directory, |
|
michaeln
2016/07/07 20:05:21
const ref
|
| + scoped_refptr<base::SingleThreadTaskRunner> file_runner); |
| + |
| + std::unique_ptr<BlobDataHandle> BuildBrokenBlob( |
| + const std::string& uuid, |
| + const std::string& content_type, |
| + const std::string& content_disposition, |
| + IPCBlobCreationCancelCode reason); |
| + |
| + |
| + std::unique_ptr<BlobDataHandle> BuildCompleteBlob(const BlobDataBuilder& content, |
|
michaeln
2016/07/07 20:05:22
|builder| for consistency here and below. in pre-e
|
| + bool content_pending); |
| + |
| + // We assume that any populated data can fit into our quota, where the called |
| + // called BlobMemoryController::MaybeFitInMemoryNow and/or |
| + // BlobMemoryController::NotifyWhenMemoryCanPopulated. |
| + std::unique_ptr<BlobDataHandle> BuildBlob(const BlobDataBuilder& content, |
| + bool content_pending); |
| + |
| + void BreakAndFinishBlob(const std::string& uuid, |
| + IPCBlobCreationCancelCode code); |
| + |
| + // This notifies the construction system that the unpopulated data in the |
| + // given blob has been populated. |
| + void FinishedPopulatingBlob(const std::string& uuid); |
|
michaeln
2016/07/07 20:05:21
terminology nits:
populating vs transporting
comp
|
| + |
| + protected: |
| + friend class BlobSlice; |
| + friend class BlobFlattener; |
| + |
| + friend class content::BlobDispatcherHostTest; |
| + |
| + // Not thread safe. |
| + static uint64_t GetAndIncrementItemId(); |
| + |
| + BlobMemoryController* mutable_memory_controller() { |
| + return &memory_controller_; |
| + } |
| + |
| + const BlobMemoryController& memory_controller() { return memory_controller_; } |
| + |
| private: |
| using BlobRegistryEntry = BlobStorageRegistry::Entry; |
| using BlobConstructedCallback = BlobStorageRegistry::BlobConstructedCallback; |
| @@ -102,18 +141,20 @@ class STORAGE_EXPORT BlobStorageContext |
| TestUnknownBrokenAndBuildingBlobReference); |
| friend class ViewBlobInternalsJob; |
| - // CompletePendingBlob or CancelPendingBlob should be called after this. |
| - void CreatePendingBlob(const std::string& uuid, |
| - const std::string& content_type, |
| - const std::string& content_disposition); |
| + std::unique_ptr<BlobDataHandle> CreateHandle(const std::string& uuid, |
| + BlobRegistryEntry* entry); |
| + |
| + bool CanFinishBuilding(BlobRegistryEntry* entry); |
| - // This includes resolving blob references in the builder. This will run the |
| - // callbacks given in RunOnConstructionComplete. |
| - void CompletePendingBlob(const BlobDataBuilder& external_builder); |
| + void FinishBuilding(BlobRegistryEntry* entry); |
| - // This will run the callbacks given in RunOnConstructionComplete. |
| - void CancelPendingBlob(const std::string& uuid, |
| - IPCBlobCreationCancelCode reason); |
| + void OnEnoughSizeForDependentCopies(const std::string& uuid, bool can_fit); |
| + |
| + void OnDependentBlobFinished(const std::string& owning_blob_uuid, |
| + bool construction_success, |
| + IPCBlobCreationCancelCode reason); |
| + |
| + void ClearAndFreeMemory(const std::string& uuid, BlobRegistryEntry* entry); |
| void IncrementBlobRefCount(const std::string& uuid); |
| void DecrementBlobRefCount(const std::string& uuid); |
| @@ -131,37 +172,14 @@ class STORAGE_EXPORT BlobStorageContext |
| void RunOnConstructionComplete(const std::string& uuid, |
| const BlobConstructedCallback& done); |
| - // Appends the given blob item to the blob builder. The new blob |
| - // retains ownership of data_item if applicable, and returns false if there |
| - // was an error and pouplates the error_code. We can either have an error of: |
| - // OUT_OF_MEMORY: We are out of memory to store this blob. |
| - // REFERENCED_BLOB_BROKEN: One of the referenced blobs is broken. |
| - bool AppendAllocatedBlobItem(const std::string& target_blob_uuid, |
| - scoped_refptr<BlobDataItem> data_item, |
| - InternalBlobData::Builder* target_blob_data, |
| - IPCBlobCreationCancelCode* error_code); |
| - |
| - // Allocates a shareable blob data item, with blob references resolved. If |
| - // there isn't enough memory, then a nullptr is returned. |
| - scoped_refptr<ShareableBlobDataItem> AllocateShareableBlobDataItem( |
| - const std::string& target_blob_uuid, |
| - scoped_refptr<BlobDataItem> data_item); |
| - |
| - // Deconstructs the blob and appends it's contents to the target blob. Items |
| - // are shared if possible, and copied if the given offset and length |
| - // have to split an item. |
| - bool AppendBlob(const std::string& target_blob_uuid, |
| - const InternalBlobData& blob, |
| - uint64_t offset, |
| - uint64_t length, |
| - InternalBlobData::Builder* target_blob_data); |
| + void UpdateItemsInRecents(BlobRegistryEntry* entry); |
| - BlobStorageRegistry registry_; |
| + void PerformCopy(const BlobStorageRegistry::ItemCopyEntry& copy, |
| + InternalBlobData* source, |
| + InternalBlobData* destination); |
| - // Used to keep track of how much memory is being utilized for blob data, |
| - // we count only the items of TYPE_DATA which are held in memory and not |
| - // items of TYPE_FILE. |
| - size_t memory_usage_; |
| + BlobStorageRegistry registry_; |
| + BlobMemoryController memory_controller_; |
| DISALLOW_COPY_AND_ASSIGN(BlobStorageContext); |
| }; |