Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / platform / WebURLResponse.h
blob8966fbd7e79e444e9527bfb937371aba1106ac9e
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
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.
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.
31 #ifndef WebURLResponse_h
32 #define WebURLResponse_h
34 #include "WebCommon.h"
35 #include "WebPrivateOwnPtr.h"
36 #include "WebServiceWorkerResponseType.h"
38 namespace blink {
40 class ResourceResponse;
41 class WebCString;
42 class WebHTTPHeaderVisitor;
43 class WebHTTPLoadInfo;
44 class WebString;
45 class WebURL;
46 class WebURLLoadTiming;
47 class WebURLResponsePrivate;
49 class WebURLResponse {
50 public:
51 enum HTTPVersion { Unknown, HTTP_0_9, HTTP_1_0, HTTP_1_1 };
52 enum SecurityStyle {
53 SecurityStyleUnknown,
54 SecurityStyleUnauthenticated,
55 SecurityStyleAuthenticationBroken,
56 SecurityStyleWarning,
57 SecurityStyleAuthenticated
60 class ExtraData {
61 public:
62 virtual ~ExtraData() { }
65 ~WebURLResponse() { reset(); }
67 WebURLResponse() : m_private(0) { }
68 WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); }
69 WebURLResponse& operator=(const WebURLResponse& r)
71 assign(r);
72 return *this;
75 explicit WebURLResponse(const WebURL& url) : m_private(0)
77 initialize();
78 setURL(url);
81 BLINK_PLATFORM_EXPORT void initialize();
82 BLINK_PLATFORM_EXPORT void reset();
83 BLINK_PLATFORM_EXPORT void assign(const WebURLResponse&);
85 BLINK_PLATFORM_EXPORT bool isNull() const;
87 BLINK_PLATFORM_EXPORT WebURL url() const;
88 BLINK_PLATFORM_EXPORT void setURL(const WebURL&);
90 BLINK_PLATFORM_EXPORT unsigned connectionID() const;
91 BLINK_PLATFORM_EXPORT void setConnectionID(unsigned);
93 BLINK_PLATFORM_EXPORT bool connectionReused() const;
94 BLINK_PLATFORM_EXPORT void setConnectionReused(bool);
96 BLINK_PLATFORM_EXPORT WebURLLoadTiming loadTiming();
97 BLINK_PLATFORM_EXPORT void setLoadTiming(const WebURLLoadTiming&);
99 BLINK_PLATFORM_EXPORT WebHTTPLoadInfo httpLoadInfo();
100 BLINK_PLATFORM_EXPORT void setHTTPLoadInfo(const WebHTTPLoadInfo&);
102 BLINK_PLATFORM_EXPORT void setResponseTime(long long);
104 BLINK_PLATFORM_EXPORT WebString mimeType() const;
105 BLINK_PLATFORM_EXPORT void setMIMEType(const WebString&);
107 BLINK_PLATFORM_EXPORT long long expectedContentLength() const;
108 BLINK_PLATFORM_EXPORT void setExpectedContentLength(long long);
110 BLINK_PLATFORM_EXPORT WebString textEncodingName() const;
111 BLINK_PLATFORM_EXPORT void setTextEncodingName(const WebString&);
113 BLINK_PLATFORM_EXPORT WebString suggestedFileName() const;
114 BLINK_PLATFORM_EXPORT void setSuggestedFileName(const WebString&);
116 BLINK_PLATFORM_EXPORT HTTPVersion httpVersion() const;
117 BLINK_PLATFORM_EXPORT void setHTTPVersion(HTTPVersion);
119 BLINK_PLATFORM_EXPORT int httpStatusCode() const;
120 BLINK_PLATFORM_EXPORT void setHTTPStatusCode(int);
122 BLINK_PLATFORM_EXPORT WebString httpStatusText() const;
123 BLINK_PLATFORM_EXPORT void setHTTPStatusText(const WebString&);
125 BLINK_PLATFORM_EXPORT WebString httpHeaderField(const WebString& name) const;
126 BLINK_PLATFORM_EXPORT void setHTTPHeaderField(const WebString& name, const WebString& value);
127 BLINK_PLATFORM_EXPORT void addHTTPHeaderField(const WebString& name, const WebString& value);
128 BLINK_PLATFORM_EXPORT void clearHTTPHeaderField(const WebString& name);
129 BLINK_PLATFORM_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
131 BLINK_PLATFORM_EXPORT double lastModifiedDate() const;
132 BLINK_PLATFORM_EXPORT void setLastModifiedDate(double);
134 BLINK_PLATFORM_EXPORT long long appCacheID() const;
135 BLINK_PLATFORM_EXPORT void setAppCacheID(long long);
137 BLINK_PLATFORM_EXPORT WebURL appCacheManifestURL() const;
138 BLINK_PLATFORM_EXPORT void setAppCacheManifestURL(const WebURL&);
140 // A consumer controlled value intended to be used to record opaque
141 // security info related to this request.
142 BLINK_PLATFORM_EXPORT WebCString securityInfo() const;
143 BLINK_PLATFORM_EXPORT void setSecurityInfo(const WebCString&);
145 BLINK_PLATFORM_EXPORT SecurityStyle securityStyle() const;
146 BLINK_PLATFORM_EXPORT void setSecurityStyle(SecurityStyle);
148 BLINK_PLATFORM_EXPORT void setSecurityDetails(const WebString& protocol, const WebString& keyExchange, const WebString& cipher, const WebString& mac, int certId);
150 #if INSIDE_BLINK
151 BLINK_PLATFORM_EXPORT ResourceResponse& toMutableResourceResponse();
152 BLINK_PLATFORM_EXPORT const ResourceResponse& toResourceResponse() const;
153 #endif
155 // Flag whether this request was served from the disk cache entry.
156 BLINK_PLATFORM_EXPORT bool wasCached() const;
157 BLINK_PLATFORM_EXPORT void setWasCached(bool);
159 // Flag whether this request was loaded via the SPDY protocol or not.
160 // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy
161 BLINK_PLATFORM_EXPORT bool wasFetchedViaSPDY() const;
162 BLINK_PLATFORM_EXPORT void setWasFetchedViaSPDY(bool);
164 // Flag whether this request was loaded after the TLS/Next-Protocol-Negotiation was used.
165 // This is related to SPDY.
166 BLINK_PLATFORM_EXPORT bool wasNpnNegotiated() const;
167 BLINK_PLATFORM_EXPORT void setWasNpnNegotiated(bool);
169 // Flag whether this request was made when "Alternate-Protocol: xxx"
170 // is present in server's response.
171 BLINK_PLATFORM_EXPORT bool wasAlternateProtocolAvailable() const;
172 BLINK_PLATFORM_EXPORT void setWasAlternateProtocolAvailable(bool);
174 // Flag whether this request was loaded via an explicit proxy (HTTP, SOCKS, etc).
175 BLINK_PLATFORM_EXPORT bool wasFetchedViaProxy() const;
176 BLINK_PLATFORM_EXPORT void setWasFetchedViaProxy(bool);
178 // Flag whether this request was loaded via a ServiceWorker.
179 BLINK_PLATFORM_EXPORT bool wasFetchedViaServiceWorker() const;
180 BLINK_PLATFORM_EXPORT void setWasFetchedViaServiceWorker(bool);
182 // Flag whether the fallback request with skip service worker flag was
183 // required.
184 BLINK_PLATFORM_EXPORT bool wasFallbackRequiredByServiceWorker() const;
185 BLINK_PLATFORM_EXPORT void setWasFallbackRequiredByServiceWorker(bool);
187 // The type of the response which was fetched by the ServiceWorker.
188 BLINK_PLATFORM_EXPORT WebServiceWorkerResponseType serviceWorkerResponseType() const;
189 BLINK_PLATFORM_EXPORT void setServiceWorkerResponseType(WebServiceWorkerResponseType);
191 // The original URL of the response which was fetched by the ServiceWorker.
192 // This may be empty if the response was created inside the ServiceWorker.
193 BLINK_PLATFORM_EXPORT WebURL originalURLViaServiceWorker() const;
194 BLINK_PLATFORM_EXPORT void setOriginalURLViaServiceWorker(const WebURL&);
196 // Flag whether this request is part of a multipart response.
197 BLINK_PLATFORM_EXPORT bool isMultipartPayload() const;
198 BLINK_PLATFORM_EXPORT void setIsMultipartPayload(bool);
200 // This indicates the location of a downloaded response if the
201 // WebURLRequest had the downloadToFile flag set to true. This file path
202 // remains valid for the lifetime of the WebURLLoader used to create it.
203 BLINK_PLATFORM_EXPORT WebString downloadFilePath() const;
204 BLINK_PLATFORM_EXPORT void setDownloadFilePath(const WebString&);
206 // Remote IP address of the socket which fetched this resource.
207 BLINK_PLATFORM_EXPORT WebString remoteIPAddress() const;
208 BLINK_PLATFORM_EXPORT void setRemoteIPAddress(const WebString&);
210 // Remote port number of the socket which fetched this resource.
211 BLINK_PLATFORM_EXPORT unsigned short remotePort() const;
212 BLINK_PLATFORM_EXPORT void setRemotePort(unsigned short);
214 // Extra data associated with the underlying resource response. Resource
215 // responses can be copied. If non-null, each copy of a resource response
216 // holds a pointer to the extra data, and the extra data pointer will be
217 // deleted when the last resource response is destroyed. Setting the extra
218 // data pointer will cause the underlying resource response to be
219 // dissociated from any existing non-null extra data pointer.
220 BLINK_PLATFORM_EXPORT ExtraData* extraData() const;
221 BLINK_PLATFORM_EXPORT void setExtraData(ExtraData*);
223 protected:
224 BLINK_PLATFORM_EXPORT void assign(WebURLResponsePrivate*);
226 private:
227 WebURLResponsePrivate* m_private;
230 } // namespace blink
232 #endif