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

Side by Side Diff: content/browser/blob_storage/blob_dispatcher_host.h

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combined BlobSlice & BlobFlattener files, more comments, a little cleanup. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/shared_memory_handle.h" 16 #include "base/memory/shared_memory_handle.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/public/browser/browser_message_filter.h" 18 #include "content/public/browser/browser_message_filter.h"
19 #include "storage/browser/blob/blob_async_builder_host.h" 19 #include "storage/browser/blob/blob_async_builder_host.h"
20 #include "storage/browser/blob/blob_transport_result.h"
21 #include "storage/common/blob_storage/blob_storage_constants.h" 20 #include "storage/common/blob_storage/blob_storage_constants.h"
22 21
23 class GURL; 22 class GURL;
24 23
25 namespace IPC { 24 namespace IPC {
26 class Sender; 25 class Sender;
27 } 26 }
28 27
29 namespace storage { 28 namespace storage {
30 class DataElement; 29 class DataElement;
(...skipping 16 matching lines...) Expand all
47 public: 46 public:
48 explicit BlobDispatcherHost(ChromeBlobStorageContext* blob_storage_context); 47 explicit BlobDispatcherHost(ChromeBlobStorageContext* blob_storage_context);
49 48
50 // BrowserMessageFilter implementation. 49 // BrowserMessageFilter implementation.
51 void OnChannelClosing() override; 50 void OnChannelClosing() override;
52 bool OnMessageReceived(const IPC::Message& message) override; 51 bool OnMessageReceived(const IPC::Message& message) override;
53 52
54 protected: 53 protected:
55 ~BlobDispatcherHost() override; 54 ~BlobDispatcherHost() override;
56 55
57 // For testing use only.
58 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size,
59 size_t max_shared_memory_size,
60 uint64_t max_file_size) {
61 async_builder_.SetMemoryConstantsForTesting(
62 max_ipc_memory_size, max_shared_memory_size, max_file_size);
63 }
64
65 private: 56 private:
66 friend class base::RefCountedThreadSafe<BlobDispatcherHost>; 57 friend class base::RefCountedThreadSafe<BlobDispatcherHost>;
67 friend class BlobDispatcherHostTest; 58 friend class BlobDispatcherHostTest;
68 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, EmptyUUIDs); 59 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, EmptyUUIDs);
69 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, MultipleTransfers); 60 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, MultipleTransfers);
70 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, SharedMemoryTransfer); 61 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, SharedMemoryTransfer);
71 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, OnCancelBuildingBlob); 62 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, OnCancelBuildingBlob);
72 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, 63 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest,
73 BlobReferenceWhileConstructing); 64 BlobReferenceWhileConstructing);
74 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, 65 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest,
(...skipping 14 matching lines...) Expand all
89 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, 80 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest,
90 DeferenceBlobOnDifferentHost); 81 DeferenceBlobOnDifferentHost);
91 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, BuildingReferenceChain); 82 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, BuildingReferenceChain);
92 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, 83 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest,
93 BuildingReferenceChainWithCancel); 84 BuildingReferenceChainWithCancel);
94 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, 85 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest,
95 BuildingReferenceChainWithSourceDeath); 86 BuildingReferenceChainWithSourceDeath);
96 87
97 typedef std::map<std::string, int> BlobReferenceMap; 88 typedef std::map<std::string, int> BlobReferenceMap;
98 89
99 void OnRegisterBlobUUID(const std::string& uuid, 90 void OnRegisterBlob(const std::string& uuid,
100 const std::string& content_type, 91 const std::string& content_type,
101 const std::string& content_disposition, 92 const std::string& content_disposition,
102 const std::set<std::string>& referenced_blob_uuids); 93 const std::vector<storage::DataElement>& descriptions);
103 void OnStartBuildingBlob(
104 const std::string& uuid,
105 const std::vector<storage::DataElement>& descriptions);
106 void OnMemoryItemResponse( 94 void OnMemoryItemResponse(
107 const std::string& uuid, 95 const std::string& uuid,
108 const std::vector<storage::BlobItemBytesResponse>& response); 96 const std::vector<storage::BlobItemBytesResponse>& response);
109 void OnCancelBuildingBlob(const std::string& uuid, 97 void OnCancelBuildingBob(const std::string& uuid,
110 const storage::IPCBlobCreationCancelCode code); 98 const storage::BlobStatus code);
111 99
112 void OnIncrementBlobRefCount(const std::string& uuid); 100 void OnIncrementBlobRefCount(const std::string& uuid);
113 void OnDecrementBlobRefCount(const std::string& uuid); 101 void OnDecrementBlobRefCount(const std::string& uuid);
114 void OnRegisterPublicBlobURL(const GURL& public_url, const std::string& uuid); 102 void OnRegisterPublicBlobURL(const GURL& public_url, const std::string& uuid);
115 void OnRevokePublicBlobURL(const GURL& public_url); 103 void OnRevokePublicBlobURL(const GURL& public_url);
116 104
117 storage::BlobStorageContext* context(); 105 storage::BlobStorageContext* context();
118 106
119 void SendMemoryRequest( 107 void SendMemoryRequest(const std::string& uuid,
120 const std::string& uuid, 108 std::vector<storage::BlobItemBytesRequest> requests,
121 std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests, 109 std::vector<base::SharedMemoryHandle> memory_handles,
122 std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, 110 std::vector<base::File> files);
123 std::unique_ptr<std::vector<base::File>> files);
124 111
125 // Send the appropriate IPC response to the renderer for the given result. 112 // We send the status unless it's BlobStatus::PENDING.
126 void SendIPCResponse(const std::string& uuid, 113 void MaybeSendFinalBlobStatus(const std::string& uuid,
127 storage::BlobTransportResult result); 114 storage::BlobStatus status);
128 115
129 bool IsInUseInHost(const std::string& uuid); 116 bool IsInUseInHost(const std::string& uuid);
130 bool IsUrlRegisteredInHost(const GURL& blob_url); 117 bool IsUrlRegisteredInHost(const GURL& blob_url);
131 118
132 // Unregisters all blobs and urls that were registered in this host. 119 // Unregisters all blobs and urls that were registered in this host.
133 void ClearHostFromBlobStorageContext(); 120 void ClearHostFromBlobStorageContext();
134 121
135 // Collection of blob ids and a count of how many usages 122 // Collection of blob ids and a count of how many usages
136 // of that id are attributable to this consumer. 123 // of that id are attributable to this consumer.
137 BlobReferenceMap blobs_inuse_map_; 124 BlobReferenceMap blobs_inuse_map_;
138 125
139 // The set of public blob urls coined by this consumer. 126 // The set of public blob urls coined by this consumer.
140 std::set<GURL> public_blob_urls_; 127 std::set<GURL> public_blob_urls_;
141 128
142 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 129 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
143 storage::BlobAsyncBuilderHost async_builder_; 130 storage::BlobAsyncBuilderHost async_builder_;
144 131
145 DISALLOW_COPY_AND_ASSIGN(BlobDispatcherHost); 132 DISALLOW_COPY_AND_ASSIGN(BlobDispatcherHost);
146 }; 133 };
147 } // namespace content 134 } // namespace content
148 #endif // CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ 135 #endif // CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698