| 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 #include "modules/fetch/BlobBytesConsumer.h" | 5 #include "modules/fetch/BlobBytesConsumer.h" |
| 6 | 6 |
| 7 #include "core/loader/ThreadableLoader.h" | 7 #include "core/loader/ThreadableLoader.h" |
| 8 #include "modules/fetch/BytesConsumerForDataConsumerHandle.h" | 8 #include "modules/fetch/BytesConsumerForDataConsumerHandle.h" |
| 9 #include "platform/blob/BlobData.h" | 9 #include "platform/blob/BlobData.h" |
| 10 #include "platform/blob/BlobRegistry.h" | 10 #include "platform/blob/BlobRegistry.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 PassRefPtr<BlobDataHandle> BlobBytesConsumer::DrainAsBlobDataHandle( | 121 PassRefPtr<BlobDataHandle> BlobBytesConsumer::DrainAsBlobDataHandle( |
| 122 BlobSizePolicy policy) { | 122 BlobSizePolicy policy) { |
| 123 if (!IsClean()) | 123 if (!IsClean()) |
| 124 return nullptr; | 124 return nullptr; |
| 125 DCHECK(blob_data_handle_); | 125 DCHECK(blob_data_handle_); |
| 126 if (policy == BlobSizePolicy::kDisallowBlobWithInvalidSize && | 126 if (policy == BlobSizePolicy::kDisallowBlobWithInvalidSize && |
| 127 blob_data_handle_->size() == UINT64_MAX) | 127 blob_data_handle_->size() == UINT64_MAX) |
| 128 return nullptr; | 128 return nullptr; |
| 129 Close(); | 129 Close(); |
| 130 return blob_data_handle_.Release(); | 130 return std::move(blob_data_handle_); |
| 131 } | 131 } |
| 132 | 132 |
| 133 PassRefPtr<EncodedFormData> BlobBytesConsumer::DrainAsFormData() { | 133 PassRefPtr<EncodedFormData> BlobBytesConsumer::DrainAsFormData() { |
| 134 RefPtr<BlobDataHandle> handle = | 134 RefPtr<BlobDataHandle> handle = |
| 135 DrainAsBlobDataHandle(BlobSizePolicy::kAllowBlobWithInvalidSize); | 135 DrainAsBlobDataHandle(BlobSizePolicy::kAllowBlobWithInvalidSize); |
| 136 if (!handle) | 136 if (!handle) |
| 137 return nullptr; | 137 return nullptr; |
| 138 RefPtr<EncodedFormData> form_data = EncodedFormData::Create(); | 138 RefPtr<EncodedFormData> form_data = EncodedFormData::Create(); |
| 139 form_data->AppendBlob(handle->Uuid(), handle); | 139 form_data->AppendBlob(handle->Uuid(), handle); |
| 140 return form_data; | 140 return form_data; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 void BlobBytesConsumer::Clear() { | 309 void BlobBytesConsumer::Clear() { |
| 310 DCHECK_NE(state_, PublicState::kReadableOrWaiting); | 310 DCHECK_NE(state_, PublicState::kReadableOrWaiting); |
| 311 if (loader_) { | 311 if (loader_) { |
| 312 loader_->Cancel(); | 312 loader_->Cancel(); |
| 313 loader_ = nullptr; | 313 loader_ = nullptr; |
| 314 } | 314 } |
| 315 client_ = nullptr; | 315 client_ = nullptr; |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace blink | 318 } // namespace blink |
| OLD | NEW |