| 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 #ifndef BodyStreamBuffer_h | 5 #ifndef BodyStreamBuffer_h |
| 6 #define BodyStreamBuffer_h | 6 #define BodyStreamBuffer_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class ScriptState; | 22 class ScriptState; |
| 23 | 23 |
| 24 class MODULES_EXPORT BodyStreamBuffer final : public UnderlyingSourceBase, | 24 class MODULES_EXPORT BodyStreamBuffer final : public UnderlyingSourceBase, |
| 25 public BytesConsumer::Client { | 25 public BytesConsumer::Client { |
| 26 WTF_MAKE_NONCOPYABLE(BodyStreamBuffer); | 26 WTF_MAKE_NONCOPYABLE(BodyStreamBuffer); |
| 27 USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer); | 27 USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer); |
| 28 | 28 |
| 29 public: | 29 public: |
| 30 // |consumer| must not have a client. | 30 // |consumer| must not have a client. |
| 31 // This function must be called with entering an appropriate V8 context. | 31 // This function must be called with entering an appropriate V8 context. |
| 32 BodyStreamBuffer(ScriptState*, BytesConsumer* /* consumer */); | 32 static BodyStreamBuffer* create(ScriptState*, BytesConsumer* /* consumer */); |
| 33 // |ReadableStreamOperations::isReadableStream(stream)| must hold. | 33 // |ReadableStreamOperations::isReadableStream(stream)| must hold. |
| 34 // This function must be called with entering an appropriate V8 context. | 34 // This function must be called with entering an appropriate V8 context. |
| 35 BodyStreamBuffer(ScriptState*, ScriptValue stream); | 35 static BodyStreamBuffer* create(ScriptState*, ScriptValue stream); |
| 36 | 36 |
| 37 ScriptValue stream(); | 37 ScriptValue stream(); |
| 38 | 38 |
| 39 // Callable only when neither locked nor disturbed. | 39 // Callable only when neither locked nor disturbed. |
| 40 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle( | 40 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle( |
| 41 BytesConsumer::BlobSizePolicy); | 41 BytesConsumer::BlobSizePolicy); |
| 42 PassRefPtr<EncodedFormData> drainAsFormData(); | 42 PassRefPtr<EncodedFormData> drainAsFormData(); |
| 43 void startLoading(FetchDataLoader*, FetchDataLoader::Client* /* client */); | 43 void startLoading(FetchDataLoader*, FetchDataLoader::Client* /* client */); |
| 44 void tee(BodyStreamBuffer**, BodyStreamBuffer**); | 44 void tee(BodyStreamBuffer**, BodyStreamBuffer**); |
| 45 | 45 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 | 62 |
| 63 DEFINE_INLINE_TRACE() { | 63 DEFINE_INLINE_TRACE() { |
| 64 visitor->trace(m_consumer); | 64 visitor->trace(m_consumer); |
| 65 visitor->trace(m_loader); | 65 visitor->trace(m_loader); |
| 66 UnderlyingSourceBase::trace(visitor); | 66 UnderlyingSourceBase::trace(visitor); |
| 67 } | 67 } |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 class LoaderClient; | 70 class LoaderClient; |
| 71 | 71 |
| 72 BodyStreamBuffer(ScriptState*, BytesConsumer* /* consumer */); |
| 73 BodyStreamBuffer(ScriptState*, ScriptValue stream); |
| 74 |
| 75 void announceClientToConsumer(); |
| 76 |
| 72 BytesConsumer* releaseHandle(); | 77 BytesConsumer* releaseHandle(); |
| 73 void close(); | 78 void close(); |
| 74 void error(); | 79 void error(); |
| 75 void cancelConsumer(); | 80 void cancelConsumer(); |
| 76 void processData(); | 81 void processData(); |
| 77 void endLoading(); | 82 void endLoading(); |
| 78 void stopLoading(); | 83 void stopLoading(); |
| 79 | 84 |
| 80 RefPtr<ScriptState> m_scriptState; | 85 RefPtr<ScriptState> m_scriptState; |
| 81 Member<BytesConsumer> m_consumer; | 86 Member<BytesConsumer> m_consumer; |
| 82 // We need this member to keep it alive while loading. | 87 // We need this member to keep it alive while loading. |
| 83 Member<FetchDataLoader> m_loader; | 88 Member<FetchDataLoader> m_loader; |
| 84 bool m_streamNeedsMore = false; | 89 bool m_streamNeedsMore = false; |
| 85 bool m_madeFromReadableStream; | 90 bool m_madeFromReadableStream; |
| 86 }; | 91 }; |
| 87 | 92 |
| 88 } // namespace blink | 93 } // namespace blink |
| 89 | 94 |
| 90 #endif // BodyStreamBuffer_h | 95 #endif // BodyStreamBuffer_h |
| OLD | NEW |