| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // doesn't exist. We store the blob in the context as broken with code | 65 // doesn't exist. We store the blob in the context as broken with code |
| 66 // REFERENCED_BLOB_BROKEN. | 66 // REFERENCED_BLOB_BROKEN. |
| 67 // * DONE if we successfully registered the blob. | 67 // * DONE if we successfully registered the blob. |
| 68 BlobTransportResult RegisterBlobUUID( | 68 BlobTransportResult RegisterBlobUUID( |
| 69 const std::string& uuid, | 69 const std::string& uuid, |
| 70 const std::string& content_type, | 70 const std::string& content_type, |
| 71 const std::string& content_disposition, | 71 const std::string& content_disposition, |
| 72 const std::set<std::string>& referenced_blob_uuids, | 72 const std::set<std::string>& referenced_blob_uuids, |
| 73 BlobStorageContext* context); | 73 BlobStorageContext* context); |
| 74 | 74 |
| 75 // This method begins the construction of the blob given the descriptions. | 75 // This method begins the construction of the blob given the descriptions. The |
| 76 // blob uuid MUST be building in this object. |
| 76 // When we return: | 77 // When we return: |
| 77 // * DONE: The blob is finished transfering right away, and is now | 78 // * DONE: The blob is finished transfering right away, and is now |
| 78 // successfully saved in the context. | 79 // successfully saved in the context. |
| 79 // * PENDING_RESPONSES: The async builder host is waiting for responses from | 80 // * PENDING_RESPONSES: The async builder host is waiting for responses from |
| 80 // the renderer. It has called |request_memory| for these responses. | 81 // the renderer. It has called |request_memory| for these responses. |
| 81 // * CANCEL_*: We have to cancel the blob construction. This function clears | 82 // * CANCEL_*: We have to cancel the blob construction. This function clears |
| 82 // the blob's internal state and marks the blob as broken in the context | 83 // the blob's internal state and marks the blob as broken in the context |
| 83 // before returning. | 84 // before returning. |
| 84 // * BAD_IPC: The arguments were invalid/bad. This marks the blob as broken in | 85 // * BAD_IPC: The arguments were invalid/bad. This marks the blob as broken in |
| 85 // the context before returning. | 86 // the context before returning. |
| 86 BlobTransportResult StartBuildingBlob( | 87 BlobTransportResult StartBuildingBlob( |
| 87 const std::string& uuid, | 88 const std::string& uuid, |
| 88 const std::vector<DataElement>& elements, | 89 const std::vector<DataElement>& elements, |
| 89 size_t memory_available, | 90 size_t memory_available, |
| 90 BlobStorageContext* context, | 91 BlobStorageContext* context, |
| 91 const RequestMemoryCallback& request_memory); | 92 const RequestMemoryCallback& request_memory); |
| 92 | 93 |
| 93 // This is called when we have responses from the Renderer to our calls to | 94 // This is called when we have responses from the Renderer to our calls to |
| 94 // the request_memory callback above. See above for return value meaning. | 95 // the request_memory callback above. See above for return value meaning. |
| 95 BlobTransportResult OnMemoryResponses( | 96 BlobTransportResult OnMemoryResponses( |
| 96 const std::string& uuid, | 97 const std::string& uuid, |
| 97 const std::vector<BlobItemBytesResponse>& responses, | 98 const std::vector<BlobItemBytesResponse>& responses, |
| 98 BlobStorageContext* context); | 99 BlobStorageContext* context); |
| 99 | 100 |
| 100 // This removes the BlobBuildingState from our map and flags the blob as | 101 // This removes the BlobBuildingState from our map and flags the blob as |
| 101 // broken in the context. This can be called both from our own logic to cancel | 102 // broken in the context. This can be called both from our own logic to cancel |
| 102 // the blob, or from the DispatcherHost (Renderer). If the blob isn't being | 103 // the blob, or from the DispatcherHost (Renderer). The blob MUST be being |
| 103 // built then we do nothing. | 104 // built in this builder. |
| 104 // Note: if the blob isn't in the context (renderer dereferenced it before we | 105 // 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. | 106 // finished constructing), then we don't bother touching the context. |
| 106 void CancelBuildingBlob(const std::string& uuid, | 107 void CancelBuildingBlob(const std::string& uuid, |
| 107 IPCBlobCreationCancelCode code, | 108 IPCBlobCreationCancelCode code, |
| 108 BlobStorageContext* context); | 109 BlobStorageContext* context); |
| 109 | 110 |
| 110 // This clears this object of pending construction. It also handles marking | 111 // 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 | 112 // blobs that haven't been fully constructed as broken in the context if there |
| 112 // are any references being held by anyone. | 113 // are any references being held by anyone. |
| 113 void CancelAll(BlobStorageContext* context); | 114 void CancelAll(BlobStorageContext* context); |
| 114 | 115 |
| 116 bool IsEmpty() const { return async_blob_map_.empty(); } |
| 117 |
| 115 size_t blob_building_count() const { return async_blob_map_.size(); } | 118 size_t blob_building_count() const { return async_blob_map_.size(); } |
| 116 | 119 |
| 117 bool IsBeingBuilt(const std::string& key) const { | 120 bool IsBeingBuilt(const std::string& key) const { |
| 118 return async_blob_map_.find(key) != async_blob_map_.end(); | 121 return async_blob_map_.find(key) != async_blob_map_.end(); |
| 119 } | 122 } |
| 120 | 123 |
| 121 // For testing use only. Must be called before StartBuildingBlob. | 124 // For testing use only. Must be called before StartBuildingBlob. |
| 122 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size, | 125 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size, |
| 123 size_t max_shared_memory_size, | 126 size_t max_shared_memory_size, |
| 124 uint64_t max_file_size) { | 127 uint64_t max_file_size) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 size_t max_shared_memory_size_ = kBlobStorageMaxSharedMemoryBytes; | 195 size_t max_shared_memory_size_ = kBlobStorageMaxSharedMemoryBytes; |
| 193 uint64_t max_file_size_ = kBlobStorageMaxFileSizeBytes; | 196 uint64_t max_file_size_ = kBlobStorageMaxFileSizeBytes; |
| 194 | 197 |
| 195 base::WeakPtrFactory<BlobAsyncBuilderHost> ptr_factory_; | 198 base::WeakPtrFactory<BlobAsyncBuilderHost> ptr_factory_; |
| 196 | 199 |
| 197 DISALLOW_COPY_AND_ASSIGN(BlobAsyncBuilderHost); | 200 DISALLOW_COPY_AND_ASSIGN(BlobAsyncBuilderHost); |
| 198 }; | 201 }; |
| 199 | 202 |
| 200 } // namespace storage | 203 } // namespace storage |
| 201 #endif // STORAGE_BROWSER_BLOB_BLOB_ASYNC_BUILDER_HOST_H_ | 204 #endif // STORAGE_BROWSER_BLOB_BLOB_ASYNC_BUILDER_HOST_H_ |
| OLD | NEW |