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 #include "storage/browser/blob/blob_async_builder_host.h" | 5 #include "storage/browser/blob/blob_async_builder_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 return BlobTransportResult::DONE; | 89 return BlobTransportResult::DONE; |
90 } | 90 } |
91 | 91 |
92 BlobTransportResult BlobAsyncBuilderHost::StartBuildingBlob( | 92 BlobTransportResult BlobAsyncBuilderHost::StartBuildingBlob( |
93 const std::string& uuid, | 93 const std::string& uuid, |
94 const std::vector<DataElement>& elements, | 94 const std::vector<DataElement>& elements, |
95 size_t memory_available, | 95 size_t memory_available, |
96 BlobStorageContext* context, | 96 BlobStorageContext* context, |
97 const RequestMemoryCallback& request_memory) { | 97 const RequestMemoryCallback& request_memory) { |
98 DCHECK(context); | 98 DCHECK(context); |
99 if (async_blob_map_.find(uuid) == async_blob_map_.end()) { | 99 DCHECK(async_blob_map_.find(uuid) != async_blob_map_.end()); |
100 return BlobTransportResult::BAD_IPC; | |
101 } | |
102 | 100 |
103 // Step 1: Get the sizes. | 101 // Step 1: Get the sizes. |
104 size_t shortcut_memory_size_bytes = 0; | 102 size_t shortcut_memory_size_bytes = 0; |
105 uint64_t total_memory_size_bytes = 0; | 103 uint64_t total_memory_size_bytes = 0; |
106 if (!CalculateBlobMemorySize(elements, &shortcut_memory_size_bytes, | 104 if (!CalculateBlobMemorySize(elements, &shortcut_memory_size_bytes, |
107 &total_memory_size_bytes)) { | 105 &total_memory_size_bytes)) { |
108 CancelBuildingBlob(uuid, IPCBlobCreationCancelCode::UNKNOWN, context); | 106 CancelBuildingBlob(uuid, IPCBlobCreationCancelCode::UNKNOWN, context); |
109 return BlobTransportResult::BAD_IPC; | 107 return BlobTransportResult::BAD_IPC; |
110 } | 108 } |
111 | 109 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 if (state->num_referenced_blobs_building > 0) { | 429 if (state->num_referenced_blobs_building > 0) { |
432 // We wait until referenced blobs are done. | 430 // We wait until referenced blobs are done. |
433 return; | 431 return; |
434 } | 432 } |
435 } | 433 } |
436 context->CompletePendingBlob(state->data_builder); | 434 context->CompletePendingBlob(state->data_builder); |
437 async_blob_map_.erase(state->data_builder.uuid()); | 435 async_blob_map_.erase(state->data_builder.uuid()); |
438 } | 436 } |
439 | 437 |
440 } // namespace storage | 438 } // namespace storage |
OLD | NEW |