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 FetchResponseData_h | 5 #ifndef FetchResponseData_h |
6 #define FetchResponseData_h | 6 #define FetchResponseData_h |
7 | 7 |
8 #include "modules/ModulesExport.h" | 8 #include "modules/ModulesExport.h" |
9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
10 #include "platform/weborigin/KURL.h" | 10 #include "platform/weborigin/KURL.h" |
11 #include "public/platform/WebServiceWorkerRequest.h" | 11 #include "public/platform/WebServiceWorkerRequest.h" |
12 #include "wtf/PassRefPtr.h" | 12 #include "wtf/PassRefPtr.h" |
13 #include "wtf/text/AtomicString.h" | 13 #include "wtf/text/AtomicString.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class BlobDataHandle; | 17 class BlobDataHandle; |
18 class BodyStreamBuffer; | 18 class BodyStreamBuffer2; |
| 19 class ExecutionContext; |
| 20 class FetchDataConsumerHandle; |
19 class FetchHeaderList; | 21 class FetchHeaderList; |
20 class WebServiceWorkerResponse; | 22 class WebServiceWorkerResponse; |
21 | 23 |
22 class MODULES_EXPORT FetchResponseData final : public GarbageCollectedFinalized<
FetchResponseData> { | 24 class MODULES_EXPORT FetchResponseData final : public GarbageCollectedFinalized<
FetchResponseData> { |
23 WTF_MAKE_NONCOPYABLE(FetchResponseData); | 25 WTF_MAKE_NONCOPYABLE(FetchResponseData); |
24 public: | 26 public: |
25 // "A response has an associated type which is one of basic, CORS, default, | 27 // "A response has an associated type which is one of basic, CORS, default, |
26 // error, and opaque. Unless stated otherwise, it is default." | 28 // error, and opaque. Unless stated otherwise, it is default." |
27 enum Type { BasicType, CORSType, DefaultType, ErrorType, OpaqueType }; | 29 enum Type { BasicType, CORSType, DefaultType, ErrorType, OpaqueType }; |
28 // "A response can have an associated termination reason which is one of | 30 // "A response can have an associated termination reason which is one of |
29 // end-user abort, fatal, and timeout." | 31 // end-user abort, fatal, and timeout." |
30 enum TerminationReason { EndUserAbortTermination, FatalTermination, TimeoutT
ermination }; | 32 enum TerminationReason { EndUserAbortTermination, FatalTermination, TimeoutT
ermination }; |
31 | 33 |
32 static FetchResponseData* create(); | 34 static FetchResponseData* create(); |
33 static FetchResponseData* createNetworkErrorResponse(); | 35 static FetchResponseData* createNetworkErrorResponse(); |
34 static FetchResponseData* createWithBuffer(BodyStreamBuffer*); | 36 static FetchResponseData* createWithBuffer(BodyStreamBuffer2*); |
35 | 37 |
36 FetchResponseData* createBasicFilteredResponse(); | 38 FetchResponseData* createBasicFilteredResponse(); |
37 FetchResponseData* createCORSFilteredResponse(); | 39 FetchResponseData* createCORSFilteredResponse(); |
38 FetchResponseData* createOpaqueFilteredResponse(); | 40 FetchResponseData* createOpaqueFilteredResponse(); |
39 | 41 |
40 FetchResponseData* clone(); | 42 FetchResponseData* clone(ExecutionContext*); |
41 | 43 |
42 Type type() const { return m_type; } | 44 Type type() const { return m_type; } |
43 const KURL& url() const { return m_url; } | 45 const KURL& url() const { return m_url; } |
44 unsigned short status() const { return m_status; } | 46 unsigned short status() const { return m_status; } |
45 AtomicString statusMessage() const { return m_statusMessage; } | 47 AtomicString statusMessage() const { return m_statusMessage; } |
46 FetchHeaderList* headerList() const { return m_headerList.get(); } | 48 FetchHeaderList* headerList() const { return m_headerList.get(); } |
47 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} | 49 BodyStreamBuffer2* buffer() const { return m_buffer; } |
48 BodyStreamBuffer* buffer() const { return m_buffer; } | |
49 String mimeType() const; | 50 String mimeType() const; |
50 PassRefPtr<BlobDataHandle> internalBlobDataHandle() const; | 51 BodyStreamBuffer2* internalBuffer() const; |
51 BodyStreamBuffer* internalBuffer() const; | |
52 String internalMIMEType() const; | 52 String internalMIMEType() const; |
53 | 53 |
54 void setURL(const KURL& url) { m_url = url; } | 54 void setURL(const KURL& url) { m_url = url; } |
55 void setStatus(unsigned short status) { m_status = status; } | 55 void setStatus(unsigned short status) { m_status = status; } |
56 void setStatusMessage(AtomicString statusMessage) { m_statusMessage = status
Message; } | 56 void setStatusMessage(AtomicString statusMessage) { m_statusMessage = status
Message; } |
57 void setBlobDataHandle(PassRefPtr<BlobDataHandle>); | |
58 void setMIMEType(const String& type) { m_mimeType = type; } | 57 void setMIMEType(const String& type) { m_mimeType = type; } |
59 | 58 |
60 // If the type is Default, replaces |m_buffer| and sets |m_blobDataHandle| | 59 // If the type is Default, replaces |m_buffer|. |
61 // to nullptr. If the type is Basic or CORS, replaces |m_buffer| and sets | 60 // If the type is Basic or CORS, replaces |m_buffer| and |
62 // |m_blobDataHandle| to nullptr, and does the same operation to | 61 // |m_internalResponse->m_buffer|. |
63 // |m_internalResponse|. If the type is Error or Opaque, does nothing. | 62 // If the type is Error or Opaque, does nothing. |
64 void replaceBodyStreamBuffer(BodyStreamBuffer*); | 63 void replaceBodyStreamBuffer(BodyStreamBuffer2*); |
65 | 64 |
66 void populateWebServiceWorkerResponse(WebServiceWorkerResponse&); | 65 // Does not call response.setBlobDataHandle(). |
| 66 void populateWebServiceWorkerResponse(WebServiceWorkerResponse& /* response
*/); |
67 | 67 |
68 DECLARE_TRACE(); | 68 DECLARE_TRACE(); |
69 | 69 |
70 private: | 70 private: |
71 FetchResponseData(Type, unsigned short, AtomicString); | 71 FetchResponseData(Type, unsigned short, AtomicString); |
72 | 72 |
73 Type m_type; | 73 Type m_type; |
74 OwnPtr<TerminationReason> m_terminationReason; | 74 OwnPtr<TerminationReason> m_terminationReason; |
75 KURL m_url; | 75 KURL m_url; |
76 unsigned short m_status; | 76 unsigned short m_status; |
77 AtomicString m_statusMessage; | 77 AtomicString m_statusMessage; |
78 Member<FetchHeaderList> m_headerList; | 78 Member<FetchHeaderList> m_headerList; |
79 RefPtr<BlobDataHandle> m_blobDataHandle; | 79 RefPtr<BlobDataHandle> m_blobDataHandle; |
80 Member<FetchResponseData> m_internalResponse; | 80 Member<FetchResponseData> m_internalResponse; |
81 Member<BodyStreamBuffer> m_buffer; | 81 Member<BodyStreamBuffer2> m_buffer; |
82 String m_mimeType; | 82 String m_mimeType; |
83 }; | 83 }; |
84 | 84 |
85 } // namespace blink | 85 } // namespace blink |
86 | 86 |
87 #endif // FetchResponseData_h | 87 #endif // FetchResponseData_h |
OLD | NEW |