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" |
11 #include "core/dom/ActiveDOMObject.h" | 11 #include "core/dom/ActiveDOMObject.h" |
12 #include "core/dom/DOMArrayBuffer.h" | 12 #include "core/dom/DOMArrayBuffer.h" |
13 #include "core/fileapi/FileReaderLoader.h" | 13 #include "core/fileapi/FileReaderLoader.h" |
14 #include "core/fileapi/FileReaderLoaderClient.h" | 14 #include "core/fileapi/FileReaderLoaderClient.h" |
15 #include "modules/ModulesExport.h" | 15 #include "modules/ModulesExport.h" |
16 #include "platform/blob/BlobData.h" | 16 #include "platform/blob/BlobData.h" |
17 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
18 #include "wtf/RefPtr.h" | 18 #include "wtf/RefPtr.h" |
19 | 19 |
20 namespace blink { | 20 namespace blink { |
21 | 21 |
22 class BodyStreamBuffer; | 22 class BodyStreamBuffer; |
23 class BodyStreamSource; | 23 class BodyStreamSource; |
| 24 class DOMException; |
24 class ReadableByteStream; | 25 class ReadableByteStream; |
25 class ScriptState; | 26 class ScriptState; |
26 | 27 |
27 class MODULES_EXPORT Body | 28 class MODULES_EXPORT Body |
28 : public GarbageCollectedFinalized<Body> | 29 : public GarbageCollectedFinalized<Body> |
29 , public ScriptWrappable | 30 , public ScriptWrappable |
30 , public ActiveDOMObject | 31 , public ActiveDOMObject |
31 , public FileReaderLoaderClient { | 32 , public FileReaderLoaderClient { |
32 DEFINE_WRAPPERTYPEINFO(); | 33 DEFINE_WRAPPERTYPEINFO(); |
33 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Body); | 34 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Body); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 ScriptPromise readAsync(ScriptState*, ResponseType); | 96 ScriptPromise readAsync(ScriptState*, ResponseType); |
96 void readAsyncFromBlob(PassRefPtr<BlobDataHandle>); | 97 void readAsyncFromBlob(PassRefPtr<BlobDataHandle>); |
97 void resolveJSON(const String&); | 98 void resolveJSON(const String&); |
98 | 99 |
99 // FileReaderLoaderClient functions. | 100 // FileReaderLoaderClient functions. |
100 virtual void didStartLoading() override; | 101 virtual void didStartLoading() override; |
101 virtual void didReceiveData() override; | 102 virtual void didReceiveData() override; |
102 virtual void didFinishLoading() override; | 103 virtual void didFinishLoading() override; |
103 virtual void didFail(FileError::ErrorCode) override; | 104 virtual void didFail(FileError::ErrorCode) override; |
104 | 105 |
105 void didBlobHandleReceiveError(PassRefPtrWillBeRawPtr<DOMException>); | 106 void didBlobHandleReceiveError(DOMException*); |
106 | 107 |
107 // We use BlobDataHandle or BodyStreamBuffer as data container of the Body. | 108 // We use BlobDataHandle or BodyStreamBuffer as data container of the Body. |
108 // BodyStreamBuffer is used only when the Response object is created by | 109 // BodyStreamBuffer is used only when the Response object is created by |
109 // fetch() API. | 110 // fetch() API. |
110 // FIXME: We should seek a cleaner way to handle the data. | 111 // FIXME: We should seek a cleaner way to handle the data. |
111 virtual PassRefPtr<BlobDataHandle> blobDataHandle() const = 0; | 112 virtual PassRefPtr<BlobDataHandle> blobDataHandle() const = 0; |
112 virtual BodyStreamBuffer* buffer() const = 0; | 113 virtual BodyStreamBuffer* buffer() const = 0; |
113 virtual String mimeType() const = 0; | 114 virtual String mimeType() const = 0; |
114 | 115 |
115 void didFinishLoadingViaStream(PassRefPtr<DOMArrayBuffer>); | 116 void didFinishLoadingViaStream(PassRefPtr<DOMArrayBuffer>); |
116 | 117 |
117 OwnPtr<FileReaderLoader> m_loader; | 118 OwnPtr<FileReaderLoader> m_loader; |
118 bool m_bodyUsed; | 119 bool m_bodyUsed; |
119 ResponseType m_responseType; | 120 ResponseType m_responseType; |
120 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; | 121 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; |
121 Member<ReadableStreamSource> m_streamSource; | 122 Member<ReadableStreamSource> m_streamSource; |
122 Member<ReadableByteStream> m_stream; | 123 Member<ReadableByteStream> m_stream; |
123 }; | 124 }; |
124 | 125 |
125 } // namespace blink | 126 } // namespace blink |
126 | 127 |
127 #endif // Body_h | 128 #endif // Body_h |
OLD | NEW |