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 "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "bindings/core/v8/V8HiddenValue.h" | 8 #include "bindings/core/v8/V8HiddenValue.h" |
| 9 #include "bindings/core/v8/V8ThrowException.h" |
9 #include "core/dom/DOMArrayBuffer.h" | 10 #include "core/dom/DOMArrayBuffer.h" |
10 #include "core/dom/DOMTypedArray.h" | 11 #include "core/dom/DOMTypedArray.h" |
11 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
12 #include "core/streams/ReadableStreamController.h" | 13 #include "core/streams/ReadableStreamController.h" |
13 #include "core/streams/ReadableStreamOperations.h" | 14 #include "core/streams/ReadableStreamOperations.h" |
14 #include "modules/fetch/Body.h" | 15 #include "modules/fetch/Body.h" |
15 #include "modules/fetch/ReadableStreamBytesConsumer.h" | 16 #include "modules/fetch/ReadableStreamBytesConsumer.h" |
16 #include "platform/blob/BlobData.h" | 17 #include "platform/blob/BlobData.h" |
17 #include "platform/network/EncodedFormData.h" | 18 #include "platform/network/EncodedFormData.h" |
18 #include <memory> | 19 #include <memory> |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 m_scriptState.get(), stream(), exceptionState); | 279 m_scriptState.get(), stream(), exceptionState); |
279 ReadableStreamOperations::defaultReaderRead(m_scriptState.get(), reader); | 280 ReadableStreamOperations::defaultReaderRead(m_scriptState.get(), reader); |
280 } | 281 } |
281 | 282 |
282 void BodyStreamBuffer::close() { | 283 void BodyStreamBuffer::close() { |
283 controller()->close(); | 284 controller()->close(); |
284 cancelConsumer(); | 285 cancelConsumer(); |
285 } | 286 } |
286 | 287 |
287 void BodyStreamBuffer::error() { | 288 void BodyStreamBuffer::error() { |
288 controller()->error(DOMException::create(NetworkError, "network error")); | 289 { |
| 290 ScriptState::Scope scope(m_scriptState.get()); |
| 291 controller()->error(V8ThrowException::createTypeError( |
| 292 m_scriptState->isolate(), "network error")); |
| 293 } |
289 cancelConsumer(); | 294 cancelConsumer(); |
290 } | 295 } |
291 | 296 |
292 void BodyStreamBuffer::cancelConsumer() { | 297 void BodyStreamBuffer::cancelConsumer() { |
293 if (m_consumer) { | 298 if (m_consumer) { |
294 m_consumer->cancel(); | 299 m_consumer->cancel(); |
295 m_consumer = nullptr; | 300 m_consumer = nullptr; |
296 } | 301 } |
297 } | 302 } |
298 | 303 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 } | 384 } |
380 if (isErrored) | 385 if (isErrored) |
381 return BytesConsumer::createErrored(BytesConsumer::Error("error")); | 386 return BytesConsumer::createErrored(BytesConsumer::Error("error")); |
382 | 387 |
383 DCHECK(consumer); | 388 DCHECK(consumer); |
384 consumer->clearClient(); | 389 consumer->clearClient(); |
385 return consumer; | 390 return consumer; |
386 } | 391 } |
387 | 392 |
388 } // namespace blink | 393 } // namespace blink |
OLD | NEW |