2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2008 Google, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
27 #ifndef ResourceResponse_h
28 #define ResourceResponse_h
31 #include "NotImplemented.h"
32 #include "ResourceResponseBase.h"
33 #include <wtf/text/CString.h>
37 class ResourceResponse : public ResourceResponseBase {
41 , m_isMultipartPayload(false)
42 , m_wasFetchedViaSPDY(false)
43 , m_wasNpnNegotiated(false)
44 , m_wasAlternateProtocolAvailable(false)
45 , m_wasFetchedViaProxy(false)
51 ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
52 : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
54 , m_isMultipartPayload(false)
55 , m_wasFetchedViaSPDY(false)
56 , m_wasNpnNegotiated(false)
57 , m_wasAlternateProtocolAvailable(false)
58 , m_wasFetchedViaProxy(false)
64 const CString& getSecurityInfo() const { return m_securityInfo; }
65 void setSecurityInfo(const CString& securityInfo) { m_securityInfo = securityInfo; }
67 long long appCacheID() const { return m_appCacheID; }
68 void setAppCacheID(long long id) { m_appCacheID = id; }
70 const KURL& appCacheManifestURL() const { return m_appCacheManifestURL; }
71 void setAppCacheManifestURL(const KURL& url) { m_appCacheManifestURL = url; }
73 bool wasFetchedViaSPDY() const { return m_wasFetchedViaSPDY; }
74 void setWasFetchedViaSPDY(bool value) { m_wasFetchedViaSPDY = value; }
76 bool wasNpnNegotiated() const { return m_wasNpnNegotiated; }
77 void setWasNpnNegotiated(bool value) { m_wasNpnNegotiated = value; }
79 bool wasAlternateProtocolAvailable() const
81 return m_wasAlternateProtocolAvailable;
83 void setWasAlternateProtocolAvailable(bool value)
85 m_wasAlternateProtocolAvailable = value;
88 bool wasFetchedViaProxy() const { return m_wasFetchedViaProxy; }
89 void setWasFetchedViaProxy(bool value) { m_wasFetchedViaProxy = value; }
91 bool isMultipartPayload() const { return m_isMultipartPayload; }
92 void setIsMultipartPayload(bool value) { m_isMultipartPayload = value; }
94 double responseTime() const { return m_responseTime; }
95 void setResponseTime(double responseTime) { m_responseTime = responseTime; }
97 const String& remoteIPAddress() const { return m_remoteIPAddress; }
98 void setRemoteIPAddress(const String& value) { m_remoteIPAddress = value; }
100 unsigned short remotePort() const { return m_remotePort; }
101 void setRemotePort(unsigned short value) { m_remotePort = value; }
103 const File* downloadedFile() const { return m_downloadedFile.get(); }
104 void setDownloadedFile(PassRefPtr<File> downloadedFile) { m_downloadedFile = downloadedFile; }
107 friend class ResourceResponseBase;
109 // An opaque value that contains some information regarding the security of
110 // the connection for this request, such as SSL connection info (empty
111 // string if not over HTTPS).
112 CString m_securityInfo;
114 void doUpdateResourceResponse()
119 PassOwnPtr<CrossThreadResourceResponseData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceResponseData>) const;
120 void doPlatformAdopt(PassOwnPtr<CrossThreadResourceResponseData>);
122 // The id of the appcache this response was retrieved from, or zero if
123 // the response was not retrieved from an appcache.
124 long long m_appCacheID;
126 // The manifest url of the appcache this response was retrieved from, if any.
127 // Note: only valid for main resource responses.
128 KURL m_appCacheManifestURL;
130 // Set to true if this is part of a multipart response.
131 bool m_isMultipartPayload;
133 // Was the resource fetched over SPDY. See http://dev.chromium.org/spdy
134 bool m_wasFetchedViaSPDY;
136 // Was the resource fetched over a channel which used TLS/Next-Protocol-Negotiation (also SPDY related).
137 bool m_wasNpnNegotiated;
139 // Was the resource fetched over a channel which specified "Alternate-Protocol"
140 // (e.g.: Alternate-Protocol: 443:npn-spdy/1).
141 bool m_wasAlternateProtocolAvailable;
143 // Was the resource fetched over an explicit proxy (HTTP, SOCKS, etc).
144 bool m_wasFetchedViaProxy;
146 // The time at which the response headers were received. For cached
147 // responses, this time could be "far" in the past.
148 double m_responseTime;
150 // Remote IP address of the socket which fetched this resource.
151 String m_remoteIPAddress;
153 // Remote port number of the socket which fetched this resource.
154 unsigned short m_remotePort;
156 // The downloaded file if the load streamed to a file.
157 RefPtr<File> m_downloadedFile;
160 struct CrossThreadResourceResponseData : public CrossThreadResourceResponseDataBase {
161 long long m_appCacheID;
162 KURL m_appCacheManifestURL;
163 bool m_isMultipartPayload;
164 bool m_wasFetchedViaSPDY;
165 bool m_wasNpnNegotiated;
166 bool m_wasAlternateProtocolAvailable;
167 bool m_wasFetchedViaProxy;
168 double m_responseTime;
169 String m_remoteIPAddress;
170 unsigned short m_remotePort;
171 String m_downloadFilePath;
174 } // namespace WebCore