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

Side by Side Diff: sky/engine/platform/network/ResourceResponse.h

Issue 1239633002: Remove //sky/engine/platform/network (Closed) Base URL: git@github.com:domokit/mojo.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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #ifndef SKY_ENGINE_PLATFORM_NETWORK_RESOURCERESPONSE_H_
28 #define SKY_ENGINE_PLATFORM_NETWORK_RESOURCERESPONSE_H_
29
30 #include "sky/engine/platform/PlatformExport.h"
31 #include "sky/engine/platform/network/HTTPHeaderMap.h"
32 #include "sky/engine/platform/network/HTTPParsers.h"
33 #include "sky/engine/platform/network/ResourceLoadInfo.h"
34 #include "sky/engine/platform/network/ResourceLoadTiming.h"
35 #include "sky/engine/platform/weborigin/KURL.h"
36 #include "sky/engine/wtf/PassOwnPtr.h"
37 #include "sky/engine/wtf/RefPtr.h"
38 #include "sky/engine/wtf/text/CString.h"
39
40 namespace blink {
41
42 class PLATFORM_EXPORT ResourceResponse {
43 WTF_MAKE_FAST_ALLOCATED;
44 public:
45 enum HTTPVersion { Unknown, HTTP_0_9, HTTP_1_0, HTTP_1_1 };
46
47 class ExtraData : public RefCounted<ExtraData> {
48 public:
49 virtual ~ExtraData() { }
50 };
51
52 ResourceResponse();
53 ResourceResponse(const KURL&, const AtomicString& mimeType, long long expect edLength, const AtomicString& textEncodingName, const String& filename);
54
55 bool isNull() const { return m_isNull; }
56 bool isHTTP() const;
57
58 const KURL& url() const;
59 void setURL(const KURL&);
60
61 const AtomicString& mimeType() const;
62 void setMimeType(const AtomicString&);
63
64 long long expectedContentLength() const;
65 void setExpectedContentLength(long long);
66
67 const AtomicString& textEncodingName() const;
68 void setTextEncodingName(const AtomicString&);
69
70 // FIXME: Should compute this on the fly.
71 // There should not be a setter exposed, as suggested file name is determine d based on other headers in a manner that WebCore does not necessarily know abou t.
72 const String& suggestedFilename() const;
73 void setSuggestedFilename(const String&);
74
75 int httpStatusCode() const;
76 void setHTTPStatusCode(int);
77
78 const AtomicString& httpStatusText() const;
79 void setHTTPStatusText(const AtomicString&);
80
81 const AtomicString& httpHeaderField(const AtomicString& name) const;
82 const AtomicString& httpHeaderField(const char* name) const;
83 void setHTTPHeaderField(const AtomicString& name, const AtomicString& value) ;
84 void addHTTPHeaderField(const AtomicString& name, const AtomicString& value) ;
85 void clearHTTPHeaderField(const AtomicString& name);
86 const HTTPHeaderMap& httpHeaderFields() const;
87
88 bool isMultipart() const { return mimeType() == "multipart/x-mixed-replace"; }
89
90 bool isAttachment() const;
91
92 // FIXME: These are used by PluginStream on some platforms. Calculations may differ from just returning plain Last-Modified header.
93 // Leaving it for now but this should go away in favor of generic solution.
94 void setLastModifiedDate(time_t);
95 time_t lastModifiedDate() const;
96
97 // These functions return parsed values of the corresponding response header s.
98 // NaN means that the header was not present or had invalid value.
99 bool cacheControlContainsNoCache();
100 bool cacheControlContainsNoStore();
101 bool cacheControlContainsMustRevalidate();
102 bool hasCacheValidatorFields() const;
103 double cacheControlMaxAge();
104 double date() const;
105 double age() const;
106 double expires() const;
107 double lastModified() const;
108
109 unsigned connectionID() const;
110 void setConnectionID(unsigned);
111
112 bool connectionReused() const;
113 void setConnectionReused(bool);
114
115 bool wasCached() const;
116 void setWasCached(bool);
117
118 ResourceLoadTiming* resourceLoadTiming() const;
119 void setResourceLoadTiming(PassRefPtr<ResourceLoadTiming>);
120
121 PassRefPtr<ResourceLoadInfo> resourceLoadInfo() const;
122 void setResourceLoadInfo(PassRefPtr<ResourceLoadInfo>);
123
124 HTTPVersion httpVersion() const { return m_httpVersion; }
125 void setHTTPVersion(HTTPVersion version) { m_httpVersion = version; }
126
127 const CString& getSecurityInfo() const { return m_securityInfo; }
128 void setSecurityInfo(const CString& securityInfo) { m_securityInfo = securit yInfo; }
129
130 bool wasFetchedViaSPDY() const { return m_wasFetchedViaSPDY; }
131 void setWasFetchedViaSPDY(bool value) { m_wasFetchedViaSPDY = value; }
132
133 bool wasNpnNegotiated() const { return m_wasNpnNegotiated; }
134 void setWasNpnNegotiated(bool value) { m_wasNpnNegotiated = value; }
135
136 bool wasAlternateProtocolAvailable() const
137 {
138 return m_wasAlternateProtocolAvailable;
139 }
140 void setWasAlternateProtocolAvailable(bool value)
141 {
142 m_wasAlternateProtocolAvailable = value;
143 }
144
145 bool wasFetchedViaProxy() const { return m_wasFetchedViaProxy; }
146 void setWasFetchedViaProxy(bool value) { m_wasFetchedViaProxy = value; }
147
148 bool isMultipartPayload() const { return m_isMultipartPayload; }
149 void setIsMultipartPayload(bool value) { m_isMultipartPayload = value; }
150
151 double responseTime() const { return m_responseTime; }
152 void setResponseTime(double responseTime) { m_responseTime = responseTime; }
153
154 const AtomicString& remoteIPAddress() const { return m_remoteIPAddress; }
155 void setRemoteIPAddress(const AtomicString& value) { m_remoteIPAddress = val ue; }
156
157 unsigned short remotePort() const { return m_remotePort; }
158 void setRemotePort(unsigned short value) { m_remotePort = value; }
159
160 const String& downloadedFilePath() const { return m_downloadedFilePath; }
161 void setDownloadedFilePath(const String&);
162
163 // Extra data associated with this response.
164 ExtraData* extraData() const { return m_extraData.get(); }
165 void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData ; }
166
167 // The ResourceResponse subclass may "shadow" this method to provide platfor m-specific memory usage information
168 unsigned memoryUsage() const
169 {
170 // average size, mostly due to URL and Header Map strings
171 return 1280;
172 }
173
174 // This method doesn't compare the all members.
175 static bool compare(const ResourceResponse&, const ResourceResponse&);
176
177 private:
178 void updateHeaderParsedState(const AtomicString& name);
179
180 KURL m_url;
181 AtomicString m_mimeType;
182 long long m_expectedContentLength;
183 AtomicString m_textEncodingName;
184 String m_suggestedFilename;
185 int m_httpStatusCode;
186 AtomicString m_httpStatusText;
187 HTTPHeaderMap m_httpHeaderFields;
188 time_t m_lastModifiedDate;
189 bool m_wasCached : 1;
190 unsigned m_connectionID;
191 bool m_connectionReused : 1;
192 RefPtr<ResourceLoadTiming> m_resourceLoadTiming;
193 RefPtr<ResourceLoadInfo> m_resourceLoadInfo;
194
195 bool m_isNull : 1;
196
197 CacheControlHeader m_cacheControlHeader;
198
199 mutable bool m_haveParsedAgeHeader : 1;
200 mutable bool m_haveParsedDateHeader : 1;
201 mutable bool m_haveParsedExpiresHeader : 1;
202 mutable bool m_haveParsedLastModifiedHeader : 1;
203
204 mutable double m_age;
205 mutable double m_date;
206 mutable double m_expires;
207 mutable double m_lastModified;
208
209 // An opaque value that contains some information regarding the security of
210 // the connection for this request, such as SSL connection info (empty
211 // string if not over HTTPS).
212 CString m_securityInfo;
213
214 // HTTP version used in the response, if known.
215 HTTPVersion m_httpVersion;
216
217 // Set to true if this is part of a multipart response.
218 bool m_isMultipartPayload;
219
220 // Was the resource fetched over SPDY. See http://dev.chromium.org/spdy
221 bool m_wasFetchedViaSPDY;
222
223 // Was the resource fetched over a channel which used TLS/Next-Protocol-Nego tiation (also SPDY related).
224 bool m_wasNpnNegotiated;
225
226 // Was the resource fetched over a channel which specified "Alternate-Protoc ol"
227 // (e.g.: Alternate-Protocol: 443:npn-spdy/1).
228 bool m_wasAlternateProtocolAvailable;
229
230 // Was the resource fetched over an explicit proxy (HTTP, SOCKS, etc).
231 bool m_wasFetchedViaProxy;
232
233 // The time at which the response headers were received. For cached
234 // responses, this time could be "far" in the past.
235 double m_responseTime;
236
237 // Remote IP address of the socket which fetched this resource.
238 AtomicString m_remoteIPAddress;
239
240 // Remote port number of the socket which fetched this resource.
241 unsigned short m_remotePort;
242
243 // The downloaded file path if the load streamed to a file.
244 String m_downloadedFilePath;
245
246 // ExtraData associated with the response.
247 RefPtr<ExtraData> m_extraData;
248 };
249
250 inline bool operator==(const ResourceResponse& a, const ResourceResponse& b) { r eturn ResourceResponse::compare(a, b); }
251 inline bool operator!=(const ResourceResponse& a, const ResourceResponse& b) { r eturn !(a == b); }
252
253 } // namespace blink
254
255 #endif // SKY_ENGINE_PLATFORM_NETWORK_RESOURCERESPONSE_H_
OLDNEW
« no previous file with comments | « sky/engine/platform/network/ResourceRequest.cpp ('k') | sky/engine/platform/network/ResourceResponse.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698