Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / public / platform / WebURLResponse.h
1 /*
2  * Copyright (C) 2009 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef WebURLResponse_h
32 #define WebURLResponse_h
33
34 #include "WebCommon.h"
35 #include "WebPrivateOwnPtr.h"
36
37 namespace blink {
38
39 class ResourceResponse;
40 class WebCString;
41 class WebHTTPHeaderVisitor;
42 class WebHTTPLoadInfo;
43 class WebString;
44 class WebURL;
45 class WebURLLoadTiming;
46 class WebURLResponsePrivate;
47
48 class WebURLResponse {
49 public:
50     enum HTTPVersion { Unknown, HTTP_0_9, HTTP_1_0, HTTP_1_1 };
51
52     class ExtraData {
53     public:
54         virtual ~ExtraData() { }
55     };
56
57     ~WebURLResponse() { reset(); }
58
59     WebURLResponse() : m_private(0) { }
60     WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); }
61     WebURLResponse& operator=(const WebURLResponse& r)
62     {
63         assign(r);
64         return *this;
65     }
66
67     explicit WebURLResponse(const WebURL& url) : m_private(0)
68     {
69         initialize();
70         setURL(url);
71     }
72
73     BLINK_PLATFORM_EXPORT void initialize();
74     BLINK_PLATFORM_EXPORT void reset();
75     BLINK_PLATFORM_EXPORT void assign(const WebURLResponse&);
76
77     BLINK_PLATFORM_EXPORT bool isNull() const;
78
79     BLINK_PLATFORM_EXPORT WebURL url() const;
80     BLINK_PLATFORM_EXPORT void setURL(const WebURL&);
81
82     BLINK_PLATFORM_EXPORT unsigned connectionID() const;
83     BLINK_PLATFORM_EXPORT void setConnectionID(unsigned);
84
85     BLINK_PLATFORM_EXPORT bool connectionReused() const;
86     BLINK_PLATFORM_EXPORT void setConnectionReused(bool);
87
88     BLINK_PLATFORM_EXPORT WebURLLoadTiming loadTiming();
89     BLINK_PLATFORM_EXPORT void setLoadTiming(const WebURLLoadTiming&);
90
91     BLINK_PLATFORM_EXPORT WebHTTPLoadInfo httpLoadInfo();
92     BLINK_PLATFORM_EXPORT void setHTTPLoadInfo(const WebHTTPLoadInfo&);
93
94     BLINK_PLATFORM_EXPORT double responseTime() const;
95     BLINK_PLATFORM_EXPORT void setResponseTime(double);
96
97     BLINK_PLATFORM_EXPORT WebString mimeType() const;
98     BLINK_PLATFORM_EXPORT void setMIMEType(const WebString&);
99
100     BLINK_PLATFORM_EXPORT long long expectedContentLength() const;
101     BLINK_PLATFORM_EXPORT void setExpectedContentLength(long long);
102
103     BLINK_PLATFORM_EXPORT WebString textEncodingName() const;
104     BLINK_PLATFORM_EXPORT void setTextEncodingName(const WebString&);
105
106     BLINK_PLATFORM_EXPORT WebString suggestedFileName() const;
107     BLINK_PLATFORM_EXPORT void setSuggestedFileName(const WebString&);
108
109     BLINK_PLATFORM_EXPORT HTTPVersion httpVersion() const;
110     BLINK_PLATFORM_EXPORT void setHTTPVersion(HTTPVersion);
111
112     BLINK_PLATFORM_EXPORT int httpStatusCode() const;
113     BLINK_PLATFORM_EXPORT void setHTTPStatusCode(int);
114
115     BLINK_PLATFORM_EXPORT WebString httpStatusText() const;
116     BLINK_PLATFORM_EXPORT void setHTTPStatusText(const WebString&);
117
118     BLINK_PLATFORM_EXPORT WebString httpHeaderField(const WebString& name) const;
119     BLINK_PLATFORM_EXPORT void setHTTPHeaderField(const WebString& name, const WebString& value);
120     BLINK_PLATFORM_EXPORT void addHTTPHeaderField(const WebString& name, const WebString& value);
121     BLINK_PLATFORM_EXPORT void clearHTTPHeaderField(const WebString& name);
122     BLINK_PLATFORM_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
123
124     BLINK_PLATFORM_EXPORT double lastModifiedDate() const;
125     BLINK_PLATFORM_EXPORT void setLastModifiedDate(double);
126
127     BLINK_PLATFORM_EXPORT long long appCacheID() const;
128     BLINK_PLATFORM_EXPORT void setAppCacheID(long long);
129
130     BLINK_PLATFORM_EXPORT WebURL appCacheManifestURL() const;
131     BLINK_PLATFORM_EXPORT void setAppCacheManifestURL(const WebURL&);
132
133     // A consumer controlled value intended to be used to record opaque
134     // security info related to this request.
135     BLINK_PLATFORM_EXPORT WebCString securityInfo() const;
136     BLINK_PLATFORM_EXPORT void setSecurityInfo(const WebCString&);
137
138 #if INSIDE_BLINK
139     BLINK_PLATFORM_EXPORT ResourceResponse& toMutableResourceResponse();
140     BLINK_PLATFORM_EXPORT const ResourceResponse& toResourceResponse() const;
141 #endif
142
143     // Flag whether this request was served from the disk cache entry.
144     BLINK_PLATFORM_EXPORT bool wasCached() const;
145     BLINK_PLATFORM_EXPORT void setWasCached(bool);
146
147     // Flag whether this request was loaded via the SPDY protocol or not.
148     // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy
149     BLINK_PLATFORM_EXPORT bool wasFetchedViaSPDY() const;
150     BLINK_PLATFORM_EXPORT void setWasFetchedViaSPDY(bool);
151
152     // Flag whether this request was loaded after the TLS/Next-Protocol-Negotiation was used.
153     // This is related to SPDY.
154     BLINK_PLATFORM_EXPORT bool wasNpnNegotiated() const;
155     BLINK_PLATFORM_EXPORT void setWasNpnNegotiated(bool);
156
157     // Flag whether this request was made when "Alternate-Protocol: xxx"
158     // is present in server's response.
159     BLINK_PLATFORM_EXPORT bool wasAlternateProtocolAvailable() const;
160     BLINK_PLATFORM_EXPORT void setWasAlternateProtocolAvailable(bool);
161
162     // Flag whether this request was loaded via an explicit proxy (HTTP, SOCKS, etc).
163     BLINK_PLATFORM_EXPORT bool wasFetchedViaProxy() const;
164     BLINK_PLATFORM_EXPORT void setWasFetchedViaProxy(bool);
165
166     // Flag whether this request was loaded via a ServiceWorker.
167     BLINK_PLATFORM_EXPORT bool wasFetchedViaServiceWorker() const;
168     BLINK_PLATFORM_EXPORT void setWasFetchedViaServiceWorker(bool);
169
170     // Flag whether this request is part of a multipart response.
171     BLINK_PLATFORM_EXPORT bool isMultipartPayload() const;
172     BLINK_PLATFORM_EXPORT void setIsMultipartPayload(bool);
173
174     // This indicates the location of a downloaded response if the
175     // WebURLRequest had the downloadToFile flag set to true. This file path
176     // remains valid for the lifetime of the WebURLLoader used to create it.
177     BLINK_PLATFORM_EXPORT WebString downloadFilePath() const;
178     BLINK_PLATFORM_EXPORT void setDownloadFilePath(const WebString&);
179
180     // Remote IP address of the socket which fetched this resource.
181     BLINK_PLATFORM_EXPORT WebString remoteIPAddress() const;
182     BLINK_PLATFORM_EXPORT void setRemoteIPAddress(const WebString&);
183
184     // Remote port number of the socket which fetched this resource.
185     BLINK_PLATFORM_EXPORT unsigned short remotePort() const;
186     BLINK_PLATFORM_EXPORT void setRemotePort(unsigned short);
187
188     // Extra data associated with the underlying resource response. Resource
189     // responses can be copied. If non-null, each copy of a resource response
190     // holds a pointer to the extra data, and the extra data pointer will be
191     // deleted when the last resource response is destroyed. Setting the extra
192     // data pointer will cause the underlying resource response to be
193     // dissociated from any existing non-null extra data pointer.
194     BLINK_PLATFORM_EXPORT ExtraData* extraData() const;
195     BLINK_PLATFORM_EXPORT void setExtraData(ExtraData*);
196
197 protected:
198     BLINK_PLATFORM_EXPORT void assign(WebURLResponsePrivate*);
199
200 private:
201     WebURLResponsePrivate* m_private;
202 };
203
204 } // namespace blink
205
206 #endif