1 /* 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2008 Google, Inc. 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 ResourceResponse_h 28 #define ResourceResponse_h 29 30 #include "NotImplemented.h" 31 #include "ResourceResponseBase.h" 32 #include <wtf/text/CString.h> 33 34 namespace WebCore { 35 36 class ResourceResponse : public ResourceResponseBase { 37 public: 38 ResourceResponse() 39 : m_appCacheID(0) 40 , m_isMultipartPayload(false) 41 , m_wasFetchedViaSPDY(false) 42 , m_wasNpnNegotiated(false) 43 , m_wasAlternateProtocolAvailable(false) 44 , m_wasFetchedViaProxy(false) 45 , m_responseTime(0) 46 , m_remotePort(0) 47 { 48 } 49 50 ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename) 51 : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename) 52 , m_appCacheID(0) 53 , m_isMultipartPayload(false) 54 , m_wasFetchedViaSPDY(false) 55 , m_wasNpnNegotiated(false) 56 , m_wasAlternateProtocolAvailable(false) 57 , m_wasFetchedViaProxy(false) 58 , m_responseTime(0) 59 , m_remotePort(0) 60 { 61 } 62 63 const CString& getSecurityInfo() const { return m_securityInfo; } 64 void setSecurityInfo(const CString& securityInfo) { m_securityInfo = securityInfo; } 65 66 long long appCacheID() const { return m_appCacheID; } 67 void setAppCacheID(long long id) { m_appCacheID = id; } 68 69 const KURL& appCacheManifestURL() const { return m_appCacheManifestURL; } 70 void setAppCacheManifestURL(const KURL& url) { m_appCacheManifestURL = url; } 71 72 bool wasFetchedViaSPDY() const { return m_wasFetchedViaSPDY; } 73 void setWasFetchedViaSPDY(bool value) { m_wasFetchedViaSPDY = value; } 74 75 bool wasNpnNegotiated() const { return m_wasNpnNegotiated; } 76 void setWasNpnNegotiated(bool value) { m_wasNpnNegotiated = value; } 77 78 bool wasAlternateProtocolAvailable() const 79 { 80 return m_wasAlternateProtocolAvailable; 81 } 82 void setWasAlternateProtocolAvailable(bool value) 83 { 84 m_wasAlternateProtocolAvailable = value; 85 } 86 87 bool wasFetchedViaProxy() const { return m_wasFetchedViaProxy; } 88 void setWasFetchedViaProxy(bool value) { m_wasFetchedViaProxy = value; } 89 90 bool isMultipartPayload() const { return m_isMultipartPayload; } 91 void setIsMultipartPayload(bool value) { m_isMultipartPayload = value; } 92 93 double responseTime() const { return m_responseTime; } 94 void setResponseTime(double responseTime) { m_responseTime = responseTime; } 95 96 const String& remoteIPAddress() const { return m_remoteIPAddress; } 97 void setRemoteIPAddress(const String& value) { m_remoteIPAddress = value; } 98 99 unsigned short remotePort() const { return m_remotePort; } 100 void setRemotePort(unsigned short value) { m_remotePort = value; } 101 102 const String& downloadFilePath() const { return m_downloadFilePath; } 103 void setDownloadFilePath(const String& downloadFilePath) { m_downloadFilePath = downloadFilePath; } 104 105 private: 106 friend class ResourceResponseBase; 107 108 // An opaque value that contains some information regarding the security of 109 // the connection for this request, such as SSL connection info (empty 110 // string if not over HTTPS). 111 CString m_securityInfo; 112 113 void doUpdateResourceResponse() 114 { 115 notImplemented(); 116 } 117 118 PassOwnPtr<CrossThreadResourceResponseData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceResponseData>) const; 119 void doPlatformAdopt(PassOwnPtr<CrossThreadResourceResponseData>); 120 121 // The id of the appcache this response was retrieved from, or zero if 122 // the response was not retrieved from an appcache. 123 long long m_appCacheID; 124 125 // The manifest url of the appcache this response was retrieved from, if any. 126 // Note: only valid for main resource responses. 127 KURL m_appCacheManifestURL; 128 129 // Set to true if this is part of a multipart response. 130 bool m_isMultipartPayload; 131 132 // Was the resource fetched over SPDY. See http://dev.chromium.org/spdy 133 bool m_wasFetchedViaSPDY; 134 135 // Was the resource fetched over a channel which used TLS/Next-Protocol-Negotiation (also SPDY related). 136 bool m_wasNpnNegotiated; 137 138 // Was the resource fetched over a channel which specified "Alternate-Protocol" 139 // (e.g.: Alternate-Protocol: 443:npn-spdy/1). 140 bool m_wasAlternateProtocolAvailable; 141 142 // Was the resource fetched over an explicit proxy (HTTP, SOCKS, etc). 143 bool m_wasFetchedViaProxy; 144 145 // The time at which the response headers were received. For cached 146 // responses, this time could be "far" in the past. 147 double m_responseTime; 148 149 // Remote IP address of the socket which fetched this resource. 150 String m_remoteIPAddress; 151 152 // Remote port number of the socket which fetched this resource. 153 unsigned short m_remotePort; 154 155 // The path to the downloaded file. 156 String m_downloadFilePath; 157 }; 158 159 struct CrossThreadResourceResponseData : public CrossThreadResourceResponseDataBase { 160 long long m_appCacheID; 161 KURL m_appCacheManifestURL; 162 bool m_isMultipartPayload; 163 bool m_wasFetchedViaSPDY; 164 bool m_wasNpnNegotiated; 165 bool m_wasAlternateProtocolAvailable; 166 bool m_wasFetchedViaProxy; 167 double m_responseTime; 168 String m_remoteIPAddress; 169 unsigned short m_remotePort; 170 String m_downloadFilePath; 171 }; 172 173 } // namespace WebCore 174 175 #endif 176