| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 STORAGE_BROWSER_BLOB_BLOB_ASYNC_BUILDER_HOST_H_ | 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_ASYNC_BUILDER_HOST_H_ |
| 6 #define STORAGE_BROWSER_BLOB_BLOB_ASYNC_BUILDER_HOST_H_ | 6 #define STORAGE_BROWSER_BLOB_BLOB_ASYNC_BUILDER_HOST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // the blob, or from the DispatcherHost (Renderer). If the blob isn't being | 102 // the blob, or from the DispatcherHost (Renderer). If the blob isn't being |
| 103 // built then we do nothing. | 103 // built then we do nothing. |
| 104 // Note: if the blob isn't in the context (renderer dereferenced it before we | 104 // Note: if the blob isn't in the context (renderer dereferenced it before we |
| 105 // finished constructing), then we don't bother touching the context. | 105 // finished constructing), then we don't bother touching the context. |
| 106 void CancelBuildingBlob(const std::string& uuid, | 106 void CancelBuildingBlob(const std::string& uuid, |
| 107 IPCBlobCreationCancelCode code, | 107 IPCBlobCreationCancelCode code, |
| 108 BlobStorageContext* context); | 108 BlobStorageContext* context); |
| 109 | 109 |
| 110 // This clears this object of pending construction. It also handles marking | 110 // This clears this object of pending construction. It also handles marking |
| 111 // blobs that haven't been fully constructed as broken in the context if there | 111 // blobs that haven't been fully constructed as broken in the context if there |
| 112 // are any references being held by anyone. | 112 // are any references being held by anyone. We know that they're being used |
| 113 // by someone else if they still exist in the context. |
| 113 void CancelAll(BlobStorageContext* context); | 114 void CancelAll(BlobStorageContext* context); |
| 114 | 115 |
| 115 size_t blob_building_count() const { return async_blob_map_.size(); } | 116 size_t blob_building_count() const { return async_blob_map_.size(); } |
| 116 | 117 |
| 117 bool IsBeingBuilt(const std::string& key) const { | 118 bool IsBeingBuilt(const std::string& key) const { |
| 118 return async_blob_map_.find(key) != async_blob_map_.end(); | 119 return async_blob_map_.find(key) != async_blob_map_.end(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 // For testing use only. Must be called before StartBuildingBlob. | 122 // For testing use only. Must be called before StartBuildingBlob. |
| 122 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size, | 123 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 172 |
| 172 // This is the 'main loop' of our memory requests to the renderer. | 173 // This is the 'main loop' of our memory requests to the renderer. |
| 173 BlobTransportResult ContinueBlobMemoryRequests(const std::string& uuid, | 174 BlobTransportResult ContinueBlobMemoryRequests(const std::string& uuid, |
| 174 BlobStorageContext* context); | 175 BlobStorageContext* context); |
| 175 | 176 |
| 176 // This is our callback for when we want to finish the blob and we're waiting | 177 // This is our callback for when we want to finish the blob and we're waiting |
| 177 // for blobs we reference to be built. When the last callback occurs, we | 178 // for blobs we reference to be built. When the last callback occurs, we |
| 178 // complete the blob and erase our internal state. | 179 // complete the blob and erase our internal state. |
| 179 void ReferencedBlobFinished(const std::string& uuid, | 180 void ReferencedBlobFinished(const std::string& uuid, |
| 180 base::WeakPtr<BlobStorageContext> context, | 181 base::WeakPtr<BlobStorageContext> context, |
| 181 bool construction_success); | 182 bool construction_success, |
| 183 IPCBlobCreationCancelCode reason); |
| 182 | 184 |
| 183 // This finishes creating the blob in the context, decrements blob references | 185 // This finishes creating the blob in the context, decrements blob references |
| 184 // that we were holding during construction, and erases our state. | 186 // that we were holding during construction, and erases our state. |
| 185 void FinishBuildingBlob(BlobBuildingState* state, | 187 void FinishBuildingBlob(BlobBuildingState* state, |
| 186 BlobStorageContext* context); | 188 BlobStorageContext* context); |
| 187 | 189 |
| 188 AsyncBlobMap async_blob_map_; | 190 AsyncBlobMap async_blob_map_; |
| 189 | 191 |
| 190 // Here for testing. | 192 // Here for testing. |
| 191 size_t max_ipc_memory_size_ = kBlobStorageIPCThresholdBytes; | 193 size_t max_ipc_memory_size_ = kBlobStorageIPCThresholdBytes; |
| 192 size_t max_shared_memory_size_ = kBlobStorageMaxSharedMemoryBytes; | 194 size_t max_shared_memory_size_ = kBlobStorageMaxSharedMemoryBytes; |
| 193 uint64_t max_file_size_ = kBlobStorageMaxFileSizeBytes; | 195 uint64_t max_file_size_ = kBlobStorageMaxFileSizeBytes; |
| 194 | 196 |
| 195 base::WeakPtrFactory<BlobAsyncBuilderHost> ptr_factory_; | 197 base::WeakPtrFactory<BlobAsyncBuilderHost> ptr_factory_; |
| 196 | 198 |
| 197 DISALLOW_COPY_AND_ASSIGN(BlobAsyncBuilderHost); | 199 DISALLOW_COPY_AND_ASSIGN(BlobAsyncBuilderHost); |
| 198 }; | 200 }; |
| 199 | 201 |
| 200 } // namespace storage | 202 } // namespace storage |
| 201 #endif // STORAGE_BROWSER_BLOB_BLOB_ASYNC_BUILDER_HOST_H_ | 203 #endif // STORAGE_BROWSER_BLOB_BLOB_ASYNC_BUILDER_HOST_H_ |
| OLD | NEW |