| 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/Body.h" | 5 #include "modules/fetch/Body.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/V8ArrayBuffer.h" | 9 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 10 #include "bindings/core/v8/V8ThrowException.h" | 10 #include "bindings/core/v8/V8ThrowException.h" |
| 11 #include "core/dom/DOMArrayBuffer.h" | 11 #include "core/dom/DOMArrayBuffer.h" |
| 12 #include "core/dom/DOMTypedArray.h" | 12 #include "core/dom/DOMTypedArray.h" |
| 13 #include "core/dom/TaskRunnerHelper.h" |
| 13 #include "core/fileapi/Blob.h" | 14 #include "core/fileapi/Blob.h" |
| 14 #include "core/frame/UseCounter.h" | 15 #include "core/frame/UseCounter.h" |
| 15 #include "modules/fetch/BodyStreamBuffer.h" | 16 #include "modules/fetch/BodyStreamBuffer.h" |
| 16 #include "modules/fetch/FetchDataLoader.h" | 17 #include "modules/fetch/FetchDataLoader.h" |
| 17 #include "public/platform/WebDataConsumerHandle.h" | 18 #include "public/platform/WebDataConsumerHandle.h" |
| 18 #include "wtf/PassRefPtr.h" | 19 #include "wtf/PassRefPtr.h" |
| 19 #include "wtf/RefPtr.h" | 20 #include "wtf/RefPtr.h" |
| 20 #include <memory> | 21 #include <memory> |
| 21 | 22 |
| 22 namespace blink { | 23 namespace blink { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 class BodyConsumerBase : public GarbageCollectedFinalized<BodyConsumerBase>, pub
lic FetchDataLoader::Client { | 27 class BodyConsumerBase : public GarbageCollectedFinalized<BodyConsumerBase>, pub
lic FetchDataLoader::Client { |
| 27 WTF_MAKE_NONCOPYABLE(BodyConsumerBase); | 28 WTF_MAKE_NONCOPYABLE(BodyConsumerBase); |
| 28 USING_GARBAGE_COLLECTED_MIXIN(BodyConsumerBase); | 29 USING_GARBAGE_COLLECTED_MIXIN(BodyConsumerBase); |
| 29 public: | 30 public: |
| 30 explicit BodyConsumerBase(ScriptPromiseResolver* resolver) : m_resolver(reso
lver) {} | 31 explicit BodyConsumerBase(ScriptPromiseResolver* resolver) : m_resolver(reso
lver) {} |
| 31 ScriptPromiseResolver* resolver() { return m_resolver; } | 32 ScriptPromiseResolver* resolver() { return m_resolver; } |
| 32 void didFetchDataLoadFailed() override | 33 void didFetchDataLoadFailed() override |
| 33 { | 34 { |
| 34 ScriptState::Scope scope(resolver()->getScriptState()); | 35 ScriptState::Scope scope(resolver()->getScriptState()); |
| 35 m_resolver->reject(V8ThrowException::createTypeError(resolver()->getScri
ptState()->isolate(), "Failed to fetch")); | 36 m_resolver->reject(V8ThrowException::createTypeError(resolver()->getScri
ptState()->isolate(), "Failed to fetch")); |
| 36 } | 37 } |
| 37 | 38 |
| 39 WebTaskRunner* getTaskRunner() override |
| 40 { |
| 41 return TaskRunnerHelper::getUnthrottledTaskRunner(resolver()->getScriptS
tate()); |
| 42 } |
| 43 |
| 38 DEFINE_INLINE_TRACE() | 44 DEFINE_INLINE_TRACE() |
| 39 { | 45 { |
| 40 visitor->trace(m_resolver); | 46 visitor->trace(m_resolver); |
| 41 FetchDataLoader::Client::trace(visitor); | 47 FetchDataLoader::Client::trace(visitor); |
| 42 } | 48 } |
| 43 | 49 |
| 44 private: | 50 private: |
| 45 Member<ScriptPromiseResolver> m_resolver; | 51 Member<ScriptPromiseResolver> m_resolver; |
| 46 }; | 52 }; |
| 47 | 53 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 Body::Body(ExecutionContext* context) : ActiveScriptWrappable(this) , ContextLif
ecycleObserver(context) {} | 227 Body::Body(ExecutionContext* context) : ActiveScriptWrappable(this) , ContextLif
ecycleObserver(context) {} |
| 222 | 228 |
| 223 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) | 229 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) |
| 224 { | 230 { |
| 225 if (isBodyLocked() || bodyUsed()) | 231 if (isBodyLocked() || bodyUsed()) |
| 226 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Already read")); | 232 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Already read")); |
| 227 return ScriptPromise(); | 233 return ScriptPromise(); |
| 228 } | 234 } |
| 229 | 235 |
| 230 } // namespace blink | 236 } // namespace blink |
| OLD | NEW |