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 Response_h | 5 #ifndef Response_h |
6 #define Response_h | 6 #define Response_h |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "bindings/modules/v8/UnionTypesModules.h" | 11 #include "bindings/modules/v8/UnionTypesModules.h" |
11 #include "modules/ModulesExport.h" | 12 #include "modules/ModulesExport.h" |
12 #include "modules/fetch/Body.h" | 13 #include "modules/fetch/Body.h" |
13 #include "modules/fetch/BodyStreamBuffer.h" | 14 #include "modules/fetch/BodyStreamBuffer.h" |
14 #include "modules/fetch/FetchResponseData.h" | 15 #include "modules/fetch/FetchResponseData.h" |
15 #include "modules/fetch/Headers.h" | 16 #include "modules/fetch/Headers.h" |
16 #include "platform/blob/BlobData.h" | 17 #include "platform/blob/BlobData.h" |
17 #include "platform/heap/Handle.h" | 18 #include "platform/heap/Handle.h" |
18 #include "wtf/PassOwnPtr.h" | 19 #include "wtf/PassOwnPtr.h" |
19 | 20 |
20 namespace blink { | 21 namespace blink { |
21 | 22 |
22 class Blob; | 23 class Blob; |
23 class DOMArrayBuffer; | 24 class DOMArrayBuffer; |
24 class ExceptionState; | 25 class ExceptionState; |
25 class FetchDataConsumerHandle; | 26 class FetchDataConsumerHandle; |
26 class ResponseInit; | 27 class ResponseInit; |
| 28 class ScriptState; |
27 class WebServiceWorkerResponse; | 29 class WebServiceWorkerResponse; |
28 | 30 |
29 typedef BlobOrArrayBufferOrArrayBufferViewOrFormDataOrUSVString BodyInit; | |
30 | |
31 class MODULES_EXPORT Response final : public Body { | 31 class MODULES_EXPORT Response final : public Body { |
32 DEFINE_WRAPPERTYPEINFO(); | 32 DEFINE_WRAPPERTYPEINFO(); |
33 WTF_MAKE_NONCOPYABLE(Response); | 33 WTF_MAKE_NONCOPYABLE(Response); |
34 public: | 34 public: |
35 ~Response() override { } | 35 ~Response() override { } |
36 | 36 |
37 // From Response.idl: | 37 // From Response.idl: |
38 static Response* create(ExecutionContext*, ExceptionState&); | 38 static Response* create(ScriptState*, ExceptionState&); |
39 static Response* create(ExecutionContext*, const BodyInit&, const Dictionary
&, ExceptionState&); | 39 static Response* create(ScriptState*, ScriptValue body, const Dictionary&, E
xceptionState&); |
40 | 40 |
41 static Response* create(ExecutionContext*, PassOwnPtr<FetchDataConsumerHandl
e> bodyHandle, const String& contentType, const ResponseInit&, ExceptionState&); | 41 static Response* create(ExecutionContext*, PassOwnPtr<FetchDataConsumerHandl
e> bodyHandle, const String& contentType, const ResponseInit&, ExceptionState&); |
42 static Response* create(ExecutionContext*, FetchResponseData*); | 42 static Response* create(ExecutionContext*, FetchResponseData*); |
43 static Response* create(ExecutionContext*, const WebServiceWorkerResponse&); | 43 static Response* create(ExecutionContext*, const WebServiceWorkerResponse&); |
44 | 44 |
45 static Response* createClone(const Response&); | 45 static Response* createClone(const Response&); |
46 | 46 |
47 static Response* error(ExecutionContext*); | 47 static Response* error(ExecutionContext*); |
48 static Response* redirect(ExecutionContext*, const String& url, unsigned sho
rt status, ExceptionState&); | 48 static Response* redirect(ExecutionContext*, const String& url, unsigned sho
rt status, ExceptionState&); |
49 | 49 |
50 const FetchResponseData* response() const { return m_response; } | 50 const FetchResponseData* response() const { return m_response; } |
51 | 51 |
52 // From Response.idl: | 52 // From Response.idl: |
53 String type() const; | 53 String type() const; |
54 String url() const; | 54 String url() const; |
55 unsigned short status() const; | 55 unsigned short status() const; |
56 bool ok() const; | 56 bool ok() const; |
57 String statusText() const; | 57 String statusText() const; |
58 Headers* headers() const; | 58 Headers* headers() const; |
59 | 59 |
60 // From Response.idl: | 60 // From Response.idl: |
61 Response* clone(ExceptionState&); | 61 Response* clone(ExceptionState&); |
62 | 62 |
63 // ActiveDOMObject | 63 // ActiveDOMObject |
64 bool hasPendingActivity() const override; | 64 bool hasPendingActivity() const override; |
| 65 void stop() override; |
65 | 66 |
66 // Does not call response.setBlobDataHandle(). | 67 // Does not call response.setBlobDataHandle(). |
67 void populateWebServiceWorkerResponse(WebServiceWorkerResponse& /* response
*/); | 68 void populateWebServiceWorkerResponse(WebServiceWorkerResponse& /* response
*/); |
68 | 69 |
69 bool hasBody() const; | 70 bool hasBody() const; |
70 BodyStreamBuffer* bodyBuffer() override { return m_response->buffer(); } | 71 BodyStreamBuffer* bodyBuffer() override { return m_response->buffer(); } |
71 const BodyStreamBuffer* bodyBuffer() const override { return m_response->buf
fer(); } | 72 const BodyStreamBuffer* bodyBuffer() const override { return m_response->buf
fer(); } |
72 BodyStreamBuffer* internalBodyBuffer() { return m_response->internalBuffer()
; } | 73 BodyStreamBuffer* internalBodyBuffer() { return m_response->internalBuffer()
; } |
73 const BodyStreamBuffer* internalBodyBuffer() const { return m_response->inte
rnalBuffer(); } | 74 const BodyStreamBuffer* internalBodyBuffer() const { return m_response->inte
rnalBuffer(); } |
74 bool bodyUsed() override; | 75 bool bodyUsed() override; |
75 | 76 |
76 String mimeType() const override; | 77 String mimeType() const override; |
77 String internalMIMEType() const; | 78 String internalMIMEType() const; |
78 | 79 |
79 DECLARE_VIRTUAL_TRACE(); | 80 DECLARE_VIRTUAL_TRACE(); |
80 | 81 |
81 private: | 82 private: |
82 explicit Response(ExecutionContext*); | 83 explicit Response(ExecutionContext*); |
83 Response(ExecutionContext*, FetchResponseData*); | 84 Response(ExecutionContext*, FetchResponseData*); |
84 Response(ExecutionContext*, FetchResponseData*, Headers*); | 85 Response(ExecutionContext*, FetchResponseData*, Headers*); |
85 | 86 |
86 const Member<FetchResponseData> m_response; | 87 const Member<FetchResponseData> m_response; |
87 const Member<Headers> m_headers; | 88 const Member<Headers> m_headers; |
88 }; | 89 }; |
89 | 90 |
90 } // namespace blink | 91 } // namespace blink |
91 | 92 |
92 #endif // Response_h | 93 #endif // Response_h |
OLD | NEW |