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