OLD | NEW |
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> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 public: | 47 public: |
48 explicit BlobDispatcherHost(ChromeBlobStorageContext* blob_storage_context); | 48 explicit BlobDispatcherHost(ChromeBlobStorageContext* blob_storage_context); |
49 | 49 |
50 // BrowserMessageFilter implementation. | 50 // BrowserMessageFilter implementation. |
51 void OnChannelClosing() override; | 51 void OnChannelClosing() override; |
52 bool OnMessageReceived(const IPC::Message& message) override; | 52 bool OnMessageReceived(const IPC::Message& message) override; |
53 | 53 |
54 protected: | 54 protected: |
55 ~BlobDispatcherHost() override; | 55 ~BlobDispatcherHost() override; |
56 | 56 |
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: | 57 private: |
66 friend class base::RefCountedThreadSafe<BlobDispatcherHost>; | 58 friend class base::RefCountedThreadSafe<BlobDispatcherHost>; |
67 friend class BlobDispatcherHostTest; | 59 friend class BlobDispatcherHostTest; |
68 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, EmptyUUIDs); | 60 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, EmptyUUIDs); |
69 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, MultipleTransfers); | 61 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, MultipleTransfers); |
70 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, SharedMemoryTransfer); | 62 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, SharedMemoryTransfer); |
71 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, OnCancelBuildingBlob); | 63 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, OnCancelBuildingBlob); |
72 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, | 64 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, |
73 BlobReferenceWhileConstructing); | 65 BlobReferenceWhileConstructing); |
74 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, | 66 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, |
(...skipping 14 matching lines...) Expand all Loading... |
89 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, | 81 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, |
90 DeferenceBlobOnDifferentHost); | 82 DeferenceBlobOnDifferentHost); |
91 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, BuildingReferenceChain); | 83 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, BuildingReferenceChain); |
92 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, | 84 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, |
93 BuildingReferenceChainWithCancel); | 85 BuildingReferenceChainWithCancel); |
94 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, | 86 FRIEND_TEST_ALL_PREFIXES(BlobDispatcherHostTest, |
95 BuildingReferenceChainWithSourceDeath); | 87 BuildingReferenceChainWithSourceDeath); |
96 | 88 |
97 typedef std::map<std::string, int> BlobReferenceMap; | 89 typedef std::map<std::string, int> BlobReferenceMap; |
98 | 90 |
99 void OnRegisterBlobUUID(const std::string& uuid, | 91 void OnRegisterBlob(const std::string& uuid, |
100 const std::string& content_type, | 92 const std::string& content_type, |
101 const std::string& content_disposition, | 93 const std::string& content_disposition, |
102 const std::set<std::string>& referenced_blob_uuids); | 94 const std::vector<storage::DataElement>& descriptions); |
103 void OnStartBuildingBlob( | |
104 const std::string& uuid, | |
105 const std::vector<storage::DataElement>& descriptions); | |
106 void OnMemoryItemResponse( | 95 void OnMemoryItemResponse( |
107 const std::string& uuid, | 96 const std::string& uuid, |
108 const std::vector<storage::BlobItemBytesResponse>& response); | 97 const std::vector<storage::BlobItemBytesResponse>& response); |
109 void OnCancelBuildingBlob(const std::string& uuid, | 98 void OnCancelBuildingBlob(const std::string& uuid, |
110 const storage::IPCBlobCreationCancelCode code); | 99 const storage::IPCBlobCreationCancelCode code); |
111 | 100 |
112 void OnIncrementBlobRefCount(const std::string& uuid); | 101 void OnIncrementBlobRefCount(const std::string& uuid); |
113 void OnDecrementBlobRefCount(const std::string& uuid); | 102 void OnDecrementBlobRefCount(const std::string& uuid); |
114 void OnRegisterPublicBlobURL(const GURL& public_url, const std::string& uuid); | 103 void OnRegisterPublicBlobURL(const GURL& public_url, const std::string& uuid); |
115 void OnRevokePublicBlobURL(const GURL& public_url); | 104 void OnRevokePublicBlobURL(const GURL& public_url); |
116 | 105 |
117 storage::BlobStorageContext* context(); | 106 storage::BlobStorageContext* context(); |
118 | 107 |
119 void SendMemoryRequest( | 108 void SendMemoryRequest( |
120 const std::string& uuid, | 109 const std::string& uuid, |
121 std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests, | 110 std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests, |
122 std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, | 111 std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, |
123 std::unique_ptr<std::vector<base::File>> files); | 112 std::unique_ptr<std::vector<base::File>> files); |
124 | 113 |
125 // Send the appropriate IPC response to the renderer for the given result. | 114 // Send the appropriate IPC response to the renderer for the given result. |
126 void SendIPCResponse(const std::string& uuid, | 115 void SendIPCResponse(const std::string& uuid, |
127 storage::BlobTransportResult result); | 116 storage::BlobTransportResult result); |
128 | 117 |
| 118 void CancelBlob(const std::string& uuid, |
| 119 storage::IPCBlobCreationCancelCode reason); |
| 120 |
129 bool IsInUseInHost(const std::string& uuid); | 121 bool IsInUseInHost(const std::string& uuid); |
130 bool IsUrlRegisteredInHost(const GURL& blob_url); | 122 bool IsUrlRegisteredInHost(const GURL& blob_url); |
131 | 123 |
132 // Unregisters all blobs and urls that were registered in this host. | 124 // Unregisters all blobs and urls that were registered in this host. |
133 void ClearHostFromBlobStorageContext(); | 125 void ClearHostFromBlobStorageContext(); |
134 | 126 |
135 // Collection of blob ids and a count of how many usages | 127 // Collection of blob ids and a count of how many usages |
136 // of that id are attributable to this consumer. | 128 // of that id are attributable to this consumer. |
137 BlobReferenceMap blobs_inuse_map_; | 129 BlobReferenceMap blobs_inuse_map_; |
138 | 130 |
139 // The set of public blob urls coined by this consumer. | 131 // The set of public blob urls coined by this consumer. |
140 std::set<GURL> public_blob_urls_; | 132 std::set<GURL> public_blob_urls_; |
141 | 133 |
142 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; | 134 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
143 storage::BlobAsyncBuilderHost async_builder_; | 135 storage::BlobAsyncBuilderHost async_builder_; |
144 | 136 |
145 DISALLOW_COPY_AND_ASSIGN(BlobDispatcherHost); | 137 DISALLOW_COPY_AND_ASSIGN(BlobDispatcherHost); |
146 }; | 138 }; |
147 } // namespace content | 139 } // namespace content |
148 #endif // CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ | 140 #endif // CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ |
OLD | NEW |