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/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 ResponseAsFormData, | 42 ResponseAsFormData, |
43 ResponseAsJSON, | 43 ResponseAsJSON, |
44 ResponseAsText | 44 ResponseAsText |
45 }; | 45 }; |
46 enum LockBodyOption { | 46 enum LockBodyOption { |
47 LockBodyOptionNone, | 47 LockBodyOptionNone, |
48 // Setting "body passed" flag in addition to acquiring a lock. | 48 // Setting "body passed" flag in addition to acquiring a lock. |
49 PassBody, | 49 PassBody, |
50 }; | 50 }; |
51 explicit Body(ExecutionContext*); | 51 explicit Body(ExecutionContext*); |
52 virtual ~Body() { } | 52 ~Body() override { } |
53 | 53 |
54 ScriptPromise arrayBuffer(ScriptState*); | 54 ScriptPromise arrayBuffer(ScriptState*); |
55 ScriptPromise blob(ScriptState*); | 55 ScriptPromise blob(ScriptState*); |
56 ScriptPromise formData(ScriptState*); | 56 ScriptPromise formData(ScriptState*); |
57 ScriptPromise json(ScriptState*); | 57 ScriptPromise json(ScriptState*); |
58 ScriptPromise text(ScriptState*); | 58 ScriptPromise text(ScriptState*); |
59 ReadableByteStream* body(); | 59 ReadableByteStream* body(); |
60 | 60 |
61 bool bodyUsed() const; | 61 bool bodyUsed() const; |
62 void lockBody(LockBodyOption = LockBodyOptionNone); | 62 void lockBody(LockBodyOption = LockBodyOptionNone); |
63 | 63 |
64 // Creates a DrainingBodyStreamBuffer to access body data. | 64 // Creates a DrainingBodyStreamBuffer to access body data. |
65 // Returns nullptr if underlying BodyStreamBuffer is null. | 65 // Returns nullptr if underlying BodyStreamBuffer is null. |
66 PassOwnPtr<DrainingBodyStreamBuffer> createDrainingStream(); | 66 PassOwnPtr<DrainingBodyStreamBuffer> createDrainingStream(); |
67 | 67 |
68 // ActiveDOMObject override. | 68 // ActiveDOMObject override. |
69 virtual bool hasPendingActivity() const override; | 69 bool hasPendingActivity() const override; |
70 | 70 |
71 DECLARE_VIRTUAL_TRACE(); | 71 DECLARE_VIRTUAL_TRACE(); |
72 | 72 |
73 protected: | 73 protected: |
74 // Sets |m_stream| to a newly created stream from |buffer|. | 74 // Sets |m_stream| to a newly created stream from |buffer|. |
75 // |buffer| can be null. | 75 // |buffer| can be null. |
76 // This is called when the underlying buffer is set/modified. | 76 // This is called when the underlying buffer is set/modified. |
77 // TODO(hiroshige): Merge FetchRequest/ResponseData::buffer() and | 77 // TODO(hiroshige): Merge FetchRequest/ResponseData::buffer() and |
78 // integrate Body::setBody(), Request/Response::refreshBody(), | 78 // integrate Body::setBody(), Request/Response::refreshBody(), |
79 // FetchRequestData::setBuffer() and | 79 // FetchRequestData::setBuffer() and |
(...skipping 19 matching lines...) Expand all Loading... |
99 bool m_bodyUsed; | 99 bool m_bodyUsed; |
100 ResponseType m_responseType; | 100 ResponseType m_responseType; |
101 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; | 101 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; |
102 Member<ReadableStreamSource> m_streamSource; | 102 Member<ReadableStreamSource> m_streamSource; |
103 Member<ReadableByteStream> m_stream; | 103 Member<ReadableByteStream> m_stream; |
104 }; | 104 }; |
105 | 105 |
106 } // namespace blink | 106 } // namespace blink |
107 | 107 |
108 #endif // Body_h | 108 #endif // Body_h |
OLD | NEW |