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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 // This is called when we have responses from the Renderer to our calls to | 93 // 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. | 94 // the request_memory callback above. See above for return value meaning. |
95 BlobTransportResult OnMemoryResponses( | 95 BlobTransportResult OnMemoryResponses( |
96 const std::string& uuid, | 96 const std::string& uuid, |
97 const std::vector<BlobItemBytesResponse>& responses, | 97 const std::vector<BlobItemBytesResponse>& responses, |
98 BlobStorageContext* context); | 98 BlobStorageContext* context); |
99 | 99 |
100 // This removes the BlobBuildingState from our map and flags the blob as | 100 // 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 | 101 // 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 | 102 // the blob, or from the DispatcherHost (Renderer). The blob MUST be being |
103 // built then we do nothing. | 103 // built in this builder. |
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. |
113 void CancelAll(BlobStorageContext* context); | 113 void CancelAll(BlobStorageContext* context); |
114 | 114 |
| 115 bool IsEmpty() const { return async_blob_map_.empty(); } |
| 116 |
115 size_t blob_building_count() const { return async_blob_map_.size(); } | 117 size_t blob_building_count() const { return async_blob_map_.size(); } |
116 | 118 |
117 bool IsBeingBuilt(const std::string& key) const { | 119 bool IsBeingBuilt(const std::string& key) const { |
118 return async_blob_map_.find(key) != async_blob_map_.end(); | 120 return async_blob_map_.find(key) != async_blob_map_.end(); |
119 } | 121 } |
120 | 122 |
121 // For testing use only. Must be called before StartBuildingBlob. | 123 // For testing use only. Must be called before StartBuildingBlob. |
122 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size, | 124 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size, |
123 size_t max_shared_memory_size, | 125 size_t max_shared_memory_size, |
124 uint64_t max_file_size) { | 126 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; | 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 |