| 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 "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 9 #include "platform/weborigin/KURL.h" | 9 #include "platform/weborigin/KURL.h" |
| 10 #include "wtf/PassRefPtr.h" | 10 #include "wtf/PassRefPtr.h" |
| 11 #include "wtf/text/AtomicString.h" | 11 #include "wtf/text/AtomicString.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class BlobDataHandle; | 15 class BlobDataHandle; |
| 16 class BodyStreamBuffer; |
| 16 class FetchHeaderList; | 17 class FetchHeaderList; |
| 17 class WebServiceWorkerResponse; | 18 class WebServiceWorkerResponse; |
| 18 | 19 |
| 19 class FetchResponseData final : public GarbageCollectedFinalized<FetchResponseDa
ta> { | 20 class FetchResponseData final : public GarbageCollectedFinalized<FetchResponseDa
ta> { |
| 20 WTF_MAKE_NONCOPYABLE(FetchResponseData); | 21 WTF_MAKE_NONCOPYABLE(FetchResponseData); |
| 21 public: | 22 public: |
| 22 // "A response has an associated type which is one of basic, CORS, default, | 23 // "A response has an associated type which is one of basic, CORS, default, |
| 23 // error, and opaque. Unless stated otherwise, it is default." | 24 // error, and opaque. Unless stated otherwise, it is default." |
| 24 enum Type { BasicType, CORSType, DefaultType, ErrorType, OpaqueType }; | 25 enum Type { BasicType, CORSType, DefaultType, ErrorType, OpaqueType }; |
| 25 // "A response can have an associated termination reason which is one of | 26 // "A response can have an associated termination reason which is one of |
| 26 // end-user abort, fatal, and timeout." | 27 // end-user abort, fatal, and timeout." |
| 27 enum TerminationReason { EndUserAbortTermination, FatalTermination, TimeoutT
ermination }; | 28 enum TerminationReason { EndUserAbortTermination, FatalTermination, TimeoutT
ermination }; |
| 28 | 29 |
| 29 static FetchResponseData* create(); | 30 static FetchResponseData* create(); |
| 30 static FetchResponseData* createNetworkErrorResponse(); | 31 static FetchResponseData* createNetworkErrorResponse(); |
| 32 static FetchResponseData* createWithBuffer(BodyStreamBuffer*); |
| 31 | 33 |
| 32 FetchResponseData* createBasicFilteredResponse(); | 34 FetchResponseData* createBasicFilteredResponse(); |
| 33 FetchResponseData* createCORSFilteredResponse(); | 35 FetchResponseData* createCORSFilteredResponse(); |
| 34 FetchResponseData* createOpaqueFilteredResponse(); | 36 FetchResponseData* createOpaqueFilteredResponse(); |
| 35 | 37 |
| 38 FetchResponseData* clone(); |
| 39 |
| 36 Type type() const { return m_type; } | 40 Type type() const { return m_type; } |
| 37 const KURL& url() const { return m_url; } | 41 const KURL& url() const { return m_url; } |
| 38 unsigned short status() const { return m_status; } | 42 unsigned short status() const { return m_status; } |
| 39 AtomicString statusMessage() const { return m_statusMessage; } | 43 AtomicString statusMessage() const { return m_statusMessage; } |
| 40 FetchHeaderList* headerList() const { return m_headerList.get(); } | 44 FetchHeaderList* headerList() const { return m_headerList.get(); } |
| 41 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} | 45 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle;
} |
| 46 BodyStreamBuffer* buffer() const { return m_buffer; } |
| 47 String contentType() const; |
| 48 PassRefPtr<BlobDataHandle> internalBlobDataHandle() const; |
| 49 BodyStreamBuffer* internalBuffer() const; |
| 50 String internalContentType() const; |
| 42 | 51 |
| 43 void setURL(const KURL& url) { m_url = url; } | 52 void setURL(const KURL& url) { m_url = url; } |
| 44 void setStatus(unsigned short status) { m_status = status; } | 53 void setStatus(unsigned short status) { m_status = status; } |
| 45 void setStatusMessage(AtomicString statusMessage) { m_statusMessage = status
Message; } | 54 void setStatusMessage(AtomicString statusMessage) { m_statusMessage = status
Message; } |
| 46 void setBlobDataHandle(PassRefPtr<BlobDataHandle> blobDataHandle) { m_blobDa
taHandle = blobDataHandle; } | 55 void setBlobDataHandle(PassRefPtr<BlobDataHandle>); |
| 56 void setContentTypeForBuffer(const String& contentType) { m_contentTypeForBu
ffer = contentType; } |
| 47 | 57 |
| 48 void populateWebServiceWorkerResponse(blink::WebServiceWorkerResponse&); | 58 void populateWebServiceWorkerResponse(blink::WebServiceWorkerResponse&); |
| 49 | 59 |
| 50 void trace(Visitor*); | 60 void trace(Visitor*); |
| 51 | 61 |
| 52 private: | 62 private: |
| 53 FetchResponseData(Type, unsigned short, AtomicString); | 63 FetchResponseData(Type, unsigned short, AtomicString); |
| 54 | 64 |
| 55 Type m_type; | 65 Type m_type; |
| 56 OwnPtr<TerminationReason> m_terminationReason; | 66 OwnPtr<TerminationReason> m_terminationReason; |
| 57 KURL m_url; | 67 KURL m_url; |
| 58 unsigned short m_status; | 68 unsigned short m_status; |
| 59 AtomicString m_statusMessage; | 69 AtomicString m_statusMessage; |
| 60 Member<FetchHeaderList> m_headerList; | 70 Member<FetchHeaderList> m_headerList; |
| 61 RefPtr<BlobDataHandle> m_blobDataHandle; | 71 RefPtr<BlobDataHandle> m_blobDataHandle; |
| 62 Member<FetchResponseData> m_internalResponse; | 72 Member<FetchResponseData> m_internalResponse; |
| 73 Member<BodyStreamBuffer> m_buffer; |
| 74 String m_contentTypeForBuffer; |
| 63 }; | 75 }; |
| 64 | 76 |
| 65 } // namespace blink | 77 } // namespace blink |
| 66 | 78 |
| 67 #endif // FetchResponseData_h | 79 #endif // FetchResponseData_h |
| OLD | NEW |