Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: Source/modules/fetch/FetchResponseData.h

Issue 1192913007: Change BodyStreamBuffer to be FetchDataConsumerHandle-based and enable backpressure in Fetch API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/fetch/FetchRequestData.cpp ('k') | Source/modules/fetch/FetchResponseData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
18 class BodyStreamBuffer; 17 class BodyStreamBuffer;
18 class ExecutionContext;
19 class FetchHeaderList; 19 class FetchHeaderList;
20 class WebServiceWorkerResponse; 20 class WebServiceWorkerResponse;
21 21
22 class MODULES_EXPORT FetchResponseData final : public GarbageCollectedFinalized< FetchResponseData> { 22 class MODULES_EXPORT FetchResponseData final : public GarbageCollectedFinalized< FetchResponseData> {
23 WTF_MAKE_NONCOPYABLE(FetchResponseData); 23 WTF_MAKE_NONCOPYABLE(FetchResponseData);
24 public: 24 public:
25 // "A response has an associated type which is one of basic, CORS, default, 25 // "A response has an associated type which is one of basic, CORS, default,
26 // error, and opaque. Unless stated otherwise, it is default." 26 // error, and opaque. Unless stated otherwise, it is default."
27 enum Type { BasicType, CORSType, DefaultType, ErrorType, OpaqueType }; 27 enum Type { BasicType, CORSType, DefaultType, ErrorType, OpaqueType };
28 // "A response can have an associated termination reason which is one of 28 // "A response can have an associated termination reason which is one of
29 // end-user abort, fatal, and timeout." 29 // end-user abort, fatal, and timeout."
30 enum TerminationReason { EndUserAbortTermination, FatalTermination, TimeoutT ermination }; 30 enum TerminationReason { EndUserAbortTermination, FatalTermination, TimeoutT ermination };
31 31
32 static FetchResponseData* create(); 32 static FetchResponseData* create();
33 static FetchResponseData* createNetworkErrorResponse(); 33 static FetchResponseData* createNetworkErrorResponse();
34 static FetchResponseData* createWithBuffer(BodyStreamBuffer*); 34 static FetchResponseData* createWithBuffer(BodyStreamBuffer*);
35 35
36 FetchResponseData* createBasicFilteredResponse(); 36 FetchResponseData* createBasicFilteredResponse();
37 FetchResponseData* createCORSFilteredResponse(); 37 FetchResponseData* createCORSFilteredResponse();
38 FetchResponseData* createOpaqueFilteredResponse(); 38 FetchResponseData* createOpaqueFilteredResponse();
39 39
40 FetchResponseData* clone(); 40 FetchResponseData* clone(ExecutionContext*);
41 41
42 Type type() const { return m_type; } 42 Type type() const { return m_type; }
43 const KURL& url() const { return m_url; } 43 const KURL& url() const { return m_url; }
44 unsigned short status() const { return m_status; } 44 unsigned short status() const { return m_status; }
45 AtomicString statusMessage() const { return m_statusMessage; } 45 AtomicString statusMessage() const { return m_statusMessage; }
46 FetchHeaderList* headerList() const { return m_headerList.get(); } 46 FetchHeaderList* headerList() const { return m_headerList.get(); }
47 PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle; }
48 BodyStreamBuffer* buffer() const { return m_buffer; } 47 BodyStreamBuffer* buffer() const { return m_buffer; }
49 String mimeType() const; 48 String mimeType() const;
50 PassRefPtr<BlobDataHandle> internalBlobDataHandle() const;
51 BodyStreamBuffer* internalBuffer() const; 49 BodyStreamBuffer* internalBuffer() const;
52 String internalMIMEType() const; 50 String internalMIMEType() const;
53 51
54 void setURL(const KURL& url) { m_url = url; } 52 void setURL(const KURL& url) { m_url = url; }
55 void setStatus(unsigned short status) { m_status = status; } 53 void setStatus(unsigned short status) { m_status = status; }
56 void setStatusMessage(AtomicString statusMessage) { m_statusMessage = status Message; } 54 void setStatusMessage(AtomicString statusMessage) { m_statusMessage = status Message; }
57 void setBlobDataHandle(PassRefPtr<BlobDataHandle>);
58 void setMIMEType(const String& type) { m_mimeType = type; } 55 void setMIMEType(const String& type) { m_mimeType = type; }
59 56
60 // If the type is Default, replaces |m_buffer| and sets |m_blobDataHandle| 57 // If the type is Default, replaces |m_buffer|.
61 // to nullptr. If the type is Basic or CORS, replaces |m_buffer| and sets 58 // If the type is Basic or CORS, replaces |m_buffer| and
62 // |m_blobDataHandle| to nullptr, and does the same operation to 59 // |m_internalResponse->m_buffer|.
63 // |m_internalResponse|. If the type is Error or Opaque, does nothing. 60 // If the type is Error or Opaque, does nothing.
64 void replaceBodyStreamBuffer(BodyStreamBuffer*); 61 void replaceBodyStreamBuffer(BodyStreamBuffer*);
65 62
66 void populateWebServiceWorkerResponse(WebServiceWorkerResponse&); 63 // Does not call response.setBlobDataHandle().
64 void populateWebServiceWorkerResponse(WebServiceWorkerResponse& /* response */);
67 65
68 DECLARE_TRACE(); 66 DECLARE_TRACE();
69 67
70 private: 68 private:
71 FetchResponseData(Type, unsigned short, AtomicString); 69 FetchResponseData(Type, unsigned short, AtomicString);
72 70
73 Type m_type; 71 Type m_type;
74 OwnPtr<TerminationReason> m_terminationReason; 72 OwnPtr<TerminationReason> m_terminationReason;
75 KURL m_url; 73 KURL m_url;
76 unsigned short m_status; 74 unsigned short m_status;
77 AtomicString m_statusMessage; 75 AtomicString m_statusMessage;
78 Member<FetchHeaderList> m_headerList; 76 Member<FetchHeaderList> m_headerList;
79 RefPtr<BlobDataHandle> m_blobDataHandle;
80 Member<FetchResponseData> m_internalResponse; 77 Member<FetchResponseData> m_internalResponse;
81 Member<BodyStreamBuffer> m_buffer; 78 Member<BodyStreamBuffer> m_buffer;
82 String m_mimeType; 79 String m_mimeType;
83 }; 80 };
84 81
85 } // namespace blink 82 } // namespace blink
86 83
87 #endif // FetchResponseData_h 84 #endif // FetchResponseData_h
OLDNEW
« no previous file with comments | « Source/modules/fetch/FetchRequestData.cpp ('k') | Source/modules/fetch/FetchResponseData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698