| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/fetch/Body.h" | 6 #include "modules/fetch/Body.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "bindings/core/v8/V8ArrayBuffer.h" | 11 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 12 #include "bindings/core/v8/V8ThrowException.h" | 12 #include "bindings/core/v8/V8ThrowException.h" |
| 13 #include "core/dom/DOMArrayBuffer.h" | 13 #include "core/dom/DOMArrayBuffer.h" |
| 14 #include "core/fileapi/Blob.h" | 14 #include "core/fileapi/Blob.h" |
| 15 #include "core/fileapi/FileReaderLoader.h" | 15 #include "core/fileapi/FileReaderLoader.h" |
| 16 #include "core/fileapi/FileReaderLoaderClient.h" | 16 #include "core/fileapi/FileReaderLoaderClient.h" |
| 17 #include "core/frame/UseCounter.h" |
| 17 #include "core/streams/UnderlyingSource.h" | 18 #include "core/streams/UnderlyingSource.h" |
| 18 #include "modules/fetch/BodyStreamBuffer.h" | 19 #include "modules/fetch/BodyStreamBuffer.h" |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 class Body::BlobHandleReceiver final : public BodyStreamBuffer::BlobHandleCreato
rClient { | 23 class Body::BlobHandleReceiver final : public BodyStreamBuffer::BlobHandleCreato
rClient { |
| 23 public: | 24 public: |
| 24 explicit BlobHandleReceiver(Body* body) | 25 explicit BlobHandleReceiver(Body* body) |
| 25 : m_body(body) | 26 : m_body(body) |
| 26 { | 27 { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return readAsync(scriptState, ResponseAsJSON); | 231 return readAsync(scriptState, ResponseAsJSON); |
| 231 } | 232 } |
| 232 | 233 |
| 233 ScriptPromise Body::text(ScriptState* scriptState) | 234 ScriptPromise Body::text(ScriptState* scriptState) |
| 234 { | 235 { |
| 235 return readAsync(scriptState, ResponseAsText); | 236 return readAsync(scriptState, ResponseAsText); |
| 236 } | 237 } |
| 237 | 238 |
| 238 ReadableStream* Body::body() | 239 ReadableStream* Body::body() |
| 239 { | 240 { |
| 241 UseCounter::count(executionContext(), UseCounter::FetchBodyStream); |
| 240 if (!m_streamAccessed) { | 242 if (!m_streamAccessed) { |
| 241 m_streamAccessed = true; | 243 m_streamAccessed = true; |
| 242 if (m_stream->isPulling()) { | 244 if (m_stream->isPulling()) { |
| 243 // The stream has been pulling, but the source ignored the | 245 // The stream has been pulling, but the source ignored the |
| 244 // instruction because it didn't know the user wanted to use the | 246 // instruction because it didn't know the user wanted to use the |
| 245 // ReadableStream interface. Now it knows the user does, so have | 247 // ReadableStream interface. Now it knows the user does, so have |
| 246 // the source start pulling. | 248 // the source start pulling. |
| 247 m_streamSource->pullSource(); | 249 m_streamSource->pullSource(); |
| 248 } | 250 } |
| 249 } | 251 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 432 |
| 431 void Body::didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException> except
ion) | 433 void Body::didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException> except
ion) |
| 432 { | 434 { |
| 433 if (!m_resolver) | 435 if (!m_resolver) |
| 434 return; | 436 return; |
| 435 m_resolver->reject(exception); | 437 m_resolver->reject(exception); |
| 436 m_resolver.clear(); | 438 m_resolver.clear(); |
| 437 } | 439 } |
| 438 | 440 |
| 439 } // namespace blink | 441 } // namespace blink |
| OLD | NEW |