| 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 Body_h | 5 #ifndef Body_h |
| 6 #define Body_h | 6 #define Body_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "core/dom/ActiveDOMObject.h" | 10 #include "core/dom/ActiveDOMObject.h" |
| 11 #include "modules/ModulesExport.h" | 11 #include "modules/ModulesExport.h" |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class BodyStreamBuffer; | 17 class BodyStreamBuffer; |
| 18 class ExecutionContext; | 18 class ExecutionContext; |
| 19 class ReadableByteStream; | 19 class ReadableByteStream; |
| 20 class ScriptState; | 20 class ScriptState; |
| 21 | 21 |
| 22 // This class represents Body mix-in defined in the fetch spec |
| 23 // https://fetch.spec.whatwg.org/#body-mixin. |
| 24 // |
| 25 // Note: This class has body stream and its predicate whereas in the current |
| 26 // spec only Response has it and Request has a byte stream defined in the |
| 27 // Encoding spec. The spec should be fixed shortly to be aligned with this |
| 28 // implementation. |
| 22 class MODULES_EXPORT Body | 29 class MODULES_EXPORT Body |
| 23 : public GarbageCollectedFinalized<Body> | 30 : public GarbageCollectedFinalized<Body> |
| 24 , public ScriptWrappable | 31 , public ScriptWrappable |
| 25 , public ActiveDOMObject { | 32 , public ActiveDOMObject { |
| 26 WTF_MAKE_NONCOPYABLE(Body); | 33 WTF_MAKE_NONCOPYABLE(Body); |
| 27 DEFINE_WRAPPERTYPEINFO(); | 34 DEFINE_WRAPPERTYPEINFO(); |
| 28 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Body); | 35 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Body); |
| 29 public: | 36 public: |
| 30 explicit Body(ExecutionContext*); | 37 explicit Body(ExecutionContext*); |
| 31 ~Body() override { } | 38 ~Body() override { } |
| 32 | 39 |
| 33 ScriptPromise arrayBuffer(ScriptState*); | 40 ScriptPromise arrayBuffer(ScriptState*); |
| 34 ScriptPromise blob(ScriptState*); | 41 ScriptPromise blob(ScriptState*); |
| 35 ScriptPromise formData(ScriptState*); | 42 ScriptPromise formData(ScriptState*); |
| 36 ScriptPromise json(ScriptState*); | 43 ScriptPromise json(ScriptState*); |
| 37 ScriptPromise text(ScriptState*); | 44 ScriptPromise text(ScriptState*); |
| 38 ReadableByteStream* body(); | 45 ReadableByteStream* bodyWithUseCounter(); |
| 39 virtual BodyStreamBuffer* bodyBuffer() = 0; | 46 virtual BodyStreamBuffer* bodyBuffer() = 0; |
| 40 virtual const BodyStreamBuffer* bodyBuffer() const = 0; | 47 virtual const BodyStreamBuffer* bodyBuffer() const = 0; |
| 41 | 48 |
| 42 bool bodyUsed(); | 49 virtual bool bodyUsed(); |
| 43 void setBodyPassed() { m_bodyPassed = true; } | 50 bool isBodyLocked(); |
| 44 | 51 |
| 45 // ActiveDOMObject override. | 52 // ActiveDOMObject override. |
| 46 bool hasPendingActivity() const override; | 53 bool hasPendingActivity() const override; |
| 47 | 54 |
| 48 DEFINE_INLINE_VIRTUAL_TRACE() | 55 DEFINE_INLINE_VIRTUAL_TRACE() |
| 49 { | 56 { |
| 50 ActiveDOMObject::trace(visitor); | 57 ActiveDOMObject::trace(visitor); |
| 51 } | 58 } |
| 52 | 59 |
| 53 private: | 60 private: |
| 61 ReadableByteStream* body(); |
| 54 virtual String mimeType() const = 0; | 62 virtual String mimeType() const = 0; |
| 55 | |
| 56 bool m_bodyPassed; | |
| 57 }; | 63 }; |
| 58 | 64 |
| 59 } // namespace blink | 65 } // namespace blink |
| 60 | 66 |
| 61 #endif // Body_h | 67 #endif // Body_h |
| OLD | NEW |