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

Unified Diff: content/browser/blob_storage/blob_dispatcher_host.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
Index: content/browser/blob_storage/blob_dispatcher_host.h
diff --git a/content/browser/blob_storage/blob_dispatcher_host.h b/content/browser/blob_storage/blob_dispatcher_host.h
index 105292ae0aab348037b847346733dc01aaeb28ba..e1bfbe50411cf27437f81a3fa10c98ffbfbebeb1 100644
--- a/content/browser/blob_storage/blob_dispatcher_host.h
+++ b/content/browser/blob_storage/blob_dispatcher_host.h
@@ -5,6 +5,7 @@
#ifndef CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_
#define CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_
+#include <memory>
#include <set>
#include <string>
#include <vector>
@@ -16,14 +17,14 @@
#include "base/memory/shared_memory_handle.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_message_filter.h"
-#include "storage/browser/blob/blob_async_builder_host.h"
-#include "storage/browser/blob/blob_transport_result.h"
+#include "storage/browser/blob/blob_transport_host.h"
#include "storage/common/blob_storage/blob_storage_constants.h"
class GURL;
namespace storage {
class DataElement;
+class BlobDataHandle;
struct BlobItemBytesRequest;
struct BlobItemBytesResponse;
class BlobStorageContext;
@@ -53,14 +54,6 @@ class CONTENT_EXPORT BlobDispatcherHost : public BrowserMessageFilter {
protected:
~BlobDispatcherHost() override;
- // For testing use only.
- void SetMemoryConstantsForTesting(size_t max_ipc_memory_size,
- size_t max_shared_memory_size,
- uint64_t max_file_size) {
- async_builder_.SetMemoryConstantsForTesting(
- max_ipc_memory_size, max_shared_memory_size, max_file_size);
- }
-
private:
friend class base::RefCountedThreadSafe<BlobDispatcherHost>;
friend class BlobDispatcherHostTest;
@@ -93,20 +86,15 @@ class CONTENT_EXPORT BlobDispatcherHost : public BrowserMessageFilter {
FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest,
BuildingReferenceChainWithSourceDeath);
- typedef std::map<std::string, int> BlobReferenceMap;
-
- void OnRegisterBlobUUID(const std::string& uuid,
- const std::string& content_type,
- const std::string& content_disposition,
- const std::set<std::string>& referenced_blob_uuids);
- void OnStartBuildingBlob(
- const std::string& uuid,
- const std::vector<storage::DataElement>& descriptions);
+ void OnRegisterBlob(const std::string& uuid,
+ const std::string& content_type,
+ const std::string& content_disposition,
+ const std::vector<storage::DataElement>& descriptions);
void OnMemoryItemResponse(
const std::string& uuid,
const std::vector<storage::BlobItemBytesResponse>& response);
void OnCancelBuildingBlob(const std::string& uuid,
- const storage::IPCBlobCreationCancelCode code);
+ const storage::BlobStatus code);
void OnIncrementBlobRefCount(const std::string& uuid);
void OnDecrementBlobRefCount(const std::string& uuid);
@@ -115,15 +103,14 @@ class CONTENT_EXPORT BlobDispatcherHost : public BrowserMessageFilter {
storage::BlobStorageContext* context();
- void SendMemoryRequest(
- const std::string& uuid,
- std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests,
- std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles,
- std::unique_ptr<std::vector<base::File>> files);
+ void SendMemoryRequest(const std::string& uuid,
+ std::vector<storage::BlobItemBytesRequest> requests,
+ std::vector<base::SharedMemoryHandle> memory_handles,
+ std::vector<base::File> files);
- // Send the appropriate IPC response to the renderer for the given result.
- void SendIPCResponse(const std::string& uuid,
- storage::BlobTransportResult result);
+ // The status should never be a pending status (see BlobStatusIsPending), and
+ // we ignore calls for |uuid|s that aren't in use in this host.
+ void SendFinalBlobStatus(const std::string& uuid, storage::BlobStatus status);
bool IsInUseInHost(const std::string& uuid);
bool IsUrlRegisteredInHost(const GURL& blob_url);
@@ -131,18 +118,29 @@ class CONTENT_EXPORT BlobDispatcherHost : public BrowserMessageFilter {
// Unregisters all blobs and urls that were registered in this host.
void ClearHostFromBlobStorageContext();
+ struct HostedBlobState {
+ explicit HostedBlobState(std::unique_ptr<storage::BlobDataHandle> handle);
+ ~HostedBlobState();
+ HostedBlobState(HostedBlobState&&);
+ HostedBlobState& operator=(HostedBlobState&&);
+ DISALLOW_COPY_AND_ASSIGN(HostedBlobState);
+
+ int refcount = 1;
+ std::unique_ptr<storage::BlobDataHandle> handle;
+ };
+
const int process_id_;
scoped_refptr<storage::FileSystemContext> file_system_context_;
// Collection of blob ids and a count of how many usages
// of that id are attributable to this consumer.
- BlobReferenceMap blobs_inuse_map_;
+ std::unordered_map<std::string, HostedBlobState> blobs_inuse_map_;
// The set of public blob urls coined by this consumer.
std::set<GURL> public_blob_urls_;
scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
- storage::BlobAsyncBuilderHost async_builder_;
+ storage::BlobTransportHost transport_host_;
DISALLOW_COPY_AND_ASSIGN(BlobDispatcherHost);
};

Powered by Google App Engine
This is Rietveld 408576698