| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/BodyStreamBuffer.h" | 5 #include "modules/fetch/BodyStreamBuffer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/dom/DOMArrayBuffer.h" | 9 #include "core/dom/DOMArrayBuffer.h" |
| 10 #include "core/dom/DOMTypedArray.h" | 10 #include "core/dom/DOMTypedArray.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if (IsStreamClosed() || IsStreamErrored()) | 142 if (IsStreamClosed() || IsStreamErrored()) |
| 143 return nullptr; | 143 return nullptr; |
| 144 | 144 |
| 145 if (made_from_readable_stream_) | 145 if (made_from_readable_stream_) |
| 146 return nullptr; | 146 return nullptr; |
| 147 | 147 |
| 148 RefPtr<BlobDataHandle> blob_data_handle = | 148 RefPtr<BlobDataHandle> blob_data_handle = |
| 149 consumer_->DrainAsBlobDataHandle(policy); | 149 consumer_->DrainAsBlobDataHandle(policy); |
| 150 if (blob_data_handle) { | 150 if (blob_data_handle) { |
| 151 CloseAndLockAndDisturb(); | 151 CloseAndLockAndDisturb(); |
| 152 return blob_data_handle.Release(); | 152 return blob_data_handle; |
| 153 } | 153 } |
| 154 return nullptr; | 154 return nullptr; |
| 155 } | 155 } |
| 156 | 156 |
| 157 PassRefPtr<EncodedFormData> BodyStreamBuffer::DrainAsFormData() { | 157 PassRefPtr<EncodedFormData> BodyStreamBuffer::DrainAsFormData() { |
| 158 DCHECK(!IsStreamLocked()); | 158 DCHECK(!IsStreamLocked()); |
| 159 DCHECK(!IsStreamDisturbed()); | 159 DCHECK(!IsStreamDisturbed()); |
| 160 if (IsStreamClosed() || IsStreamErrored()) | 160 if (IsStreamClosed() || IsStreamErrored()) |
| 161 return nullptr; | 161 return nullptr; |
| 162 | 162 |
| 163 if (made_from_readable_stream_) | 163 if (made_from_readable_stream_) |
| 164 return nullptr; | 164 return nullptr; |
| 165 | 165 |
| 166 RefPtr<EncodedFormData> form_data = consumer_->DrainAsFormData(); | 166 RefPtr<EncodedFormData> form_data = consumer_->DrainAsFormData(); |
| 167 if (form_data) { | 167 if (form_data) { |
| 168 CloseAndLockAndDisturb(); | 168 CloseAndLockAndDisturb(); |
| 169 return form_data.Release(); | 169 return form_data; |
| 170 } | 170 } |
| 171 return nullptr; | 171 return nullptr; |
| 172 } | 172 } |
| 173 | 173 |
| 174 void BodyStreamBuffer::StartLoading(FetchDataLoader* loader, | 174 void BodyStreamBuffer::StartLoading(FetchDataLoader* loader, |
| 175 FetchDataLoader::Client* client) { | 175 FetchDataLoader::Client* client) { |
| 176 DCHECK(!loader_); | 176 DCHECK(!loader_); |
| 177 DCHECK(script_state_->ContextIsValid()); | 177 DCHECK(script_state_->ContextIsValid()); |
| 178 loader_ = loader; | 178 loader_ = loader; |
| 179 loader->Start(ReleaseHandle(), | 179 loader->Start(ReleaseHandle(), |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 } | 394 } |
| 395 if (is_errored) | 395 if (is_errored) |
| 396 return BytesConsumer::CreateErrored(BytesConsumer::Error("error")); | 396 return BytesConsumer::CreateErrored(BytesConsumer::Error("error")); |
| 397 | 397 |
| 398 DCHECK(consumer); | 398 DCHECK(consumer); |
| 399 consumer->ClearClient(); | 399 consumer->ClearClient(); |
| 400 return consumer; | 400 return consumer; |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace blink | 403 } // namespace blink |
| OLD | NEW |