initial import
[vuplus_webkit] / Source / WebCore / platform / network / chromium / ResourceResponse.h
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 "File.h"
31 #include "NotImplemented.h"
32 #include "ResourceResponseBase.h"
33 #include <wtf/text/CString.h>
34
35 namespace WebCore {
36
37     class ResourceResponse : public ResourceResponseBase {
38     public:
39         ResourceResponse()
40             : m_appCacheID(0)
41             , m_isMultipartPayload(false)
42             , m_wasFetchedViaSPDY(false)
43             , m_wasNpnNegotiated(false)
44             , m_wasAlternateProtocolAvailable(false)
45             , m_wasFetchedViaProxy(false)
46             , m_responseTime(0)
47             , m_remotePort(0)
48         {
49         }
50
51         ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
52             : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
53             , m_appCacheID(0)
54             , m_isMultipartPayload(false)
55             , m_wasFetchedViaSPDY(false)
56             , m_wasNpnNegotiated(false)
57             , m_wasAlternateProtocolAvailable(false)
58             , m_wasFetchedViaProxy(false)
59             , m_responseTime(0)
60             , m_remotePort(0)
61         {
62         }
63
64         const CString& getSecurityInfo() const { return m_securityInfo; }
65         void setSecurityInfo(const CString& securityInfo) { m_securityInfo = securityInfo; }
66
67         long long appCacheID() const { return m_appCacheID; }
68         void setAppCacheID(long long id) { m_appCacheID = id; }
69
70         const KURL& appCacheManifestURL() const { return m_appCacheManifestURL; }
71         void setAppCacheManifestURL(const KURL& url) { m_appCacheManifestURL = url; }
72
73         bool wasFetchedViaSPDY() const { return m_wasFetchedViaSPDY; }
74         void setWasFetchedViaSPDY(bool value) { m_wasFetchedViaSPDY = value; }
75
76         bool wasNpnNegotiated() const { return m_wasNpnNegotiated; }
77         void setWasNpnNegotiated(bool value) { m_wasNpnNegotiated = value; }
78
79         bool wasAlternateProtocolAvailable() const
80         {
81           return m_wasAlternateProtocolAvailable;
82         }
83         void setWasAlternateProtocolAvailable(bool value)
84         {
85           m_wasAlternateProtocolAvailable = value;
86         }
87
88         bool wasFetchedViaProxy() const { return m_wasFetchedViaProxy; }
89         void setWasFetchedViaProxy(bool value) { m_wasFetchedViaProxy = value; }
90
91         bool isMultipartPayload() const { return m_isMultipartPayload; }
92         void setIsMultipartPayload(bool value) { m_isMultipartPayload = value; }
93
94         double responseTime() const { return m_responseTime; }
95         void setResponseTime(double responseTime) { m_responseTime = responseTime; }
96
97         const String& remoteIPAddress() const { return m_remoteIPAddress; }
98         void setRemoteIPAddress(const String& value) { m_remoteIPAddress = value; }
99
100         unsigned short remotePort() const { return m_remotePort; }
101         void setRemotePort(unsigned short value) { m_remotePort = value; }
102
103         const File* downloadedFile() const { return m_downloadedFile.get(); }
104         void setDownloadedFile(PassRefPtr<File> downloadedFile) { m_downloadedFile = downloadedFile; }
105
106     private:
107         friend class ResourceResponseBase;
108
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;
113
114         void doUpdateResourceResponse()
115         {
116             notImplemented();
117         }
118
119         PassOwnPtr<CrossThreadResourceResponseData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceResponseData>) const;
120         void doPlatformAdopt(PassOwnPtr<CrossThreadResourceResponseData>);
121
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;
125
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;
129
130         // Set to true if this is part of a multipart response.
131         bool m_isMultipartPayload;
132
133         // Was the resource fetched over SPDY.  See http://dev.chromium.org/spdy
134         bool m_wasFetchedViaSPDY;
135
136         // Was the resource fetched over a channel which used TLS/Next-Protocol-Negotiation (also SPDY related).
137         bool m_wasNpnNegotiated;
138
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;
142
143         // Was the resource fetched over an explicit proxy (HTTP, SOCKS, etc).
144         bool m_wasFetchedViaProxy;
145
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;
149
150         // Remote IP address of the socket which fetched this resource.
151         String m_remoteIPAddress;
152
153         // Remote port number of the socket which fetched this resource.
154         unsigned short m_remotePort;
155
156         // The downloaded file if the load streamed to a file.
157         RefPtr<File> m_downloadedFile;
158     };
159
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;
172     };
173
174 } // namespace WebCore
175
176 #endif