| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef ResourceResponseBase_h | 27 #ifndef ResourceResponseBase_h |
| 28 #define ResourceResponseBase_h | 28 #define ResourceResponseBase_h |
| 29 | 29 |
| 30 #include "HTTPHeaderMap.h" | 30 #include "HTTPHeaderMap.h" |
| 31 #include "KURL.h" | 31 #include "KURL.h" |
| 32 #if ENABLE(APPLICATION_CACHE) |
| 33 #include "ApplicationCacheCommon.h" |
| 34 #endif |
| 32 | 35 |
| 33 #include <memory> | 36 #include <memory> |
| 34 | 37 |
| 35 namespace WebCore { | 38 namespace WebCore { |
| 36 | 39 |
| 37 class ResourceResponse; | 40 class ResourceResponse; |
| 38 struct CrossThreadResourceResponseData; | 41 struct CrossThreadResourceResponseData; |
| 39 | 42 |
| 40 // Do not use this class directly, use the class ResponseResponse instead | 43 // Do not use this class directly, use the class ResponseResponse instead |
| 41 class ResourceResponseBase { | 44 class ResourceResponseBase { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 bool isMultipart() const { return mimeType() == "multipart/x-mixed-replace";
} | 80 bool isMultipart() const { return mimeType() == "multipart/x-mixed-replace";
} |
| 78 | 81 |
| 79 bool isAttachment() const; | 82 bool isAttachment() const; |
| 80 | 83 |
| 81 void setExpirationDate(time_t); | 84 void setExpirationDate(time_t); |
| 82 time_t expirationDate() const; | 85 time_t expirationDate() const; |
| 83 | 86 |
| 84 void setLastModifiedDate(time_t); | 87 void setLastModifiedDate(time_t); |
| 85 time_t lastModifiedDate() const; | 88 time_t lastModifiedDate() const; |
| 86 | 89 |
| 90 #if ENABLE(APPLICATION_CACHE) |
| 91 void setApplicationCacheID(ApplicationCacheID cacheID) { m_appcacheID = cach
eID; } |
| 92 ApplicationCacheID applicationCacheID() const { return m_appcacheID; } |
| 93 |
| 94 void setManifestURL(KURL& manifestURL) { m_manifestURL = manifestURL; } |
| 95 const KURL& manifestURL() const { return m_manifestURL; } |
| 96 #endif |
| 97 |
| 87 bool cacheControlContainsNoCache() const | 98 bool cacheControlContainsNoCache() const |
| 88 { | 99 { |
| 89 if (!m_haveParsedCacheControl) | 100 if (!m_haveParsedCacheControl) |
| 90 parseCacheControlDirectives(); | 101 parseCacheControlDirectives(); |
| 91 return m_cacheControlContainsNoCache; | 102 return m_cacheControlContainsNoCache; |
| 92 } | 103 } |
| 93 bool cacheControlContainsMustRevalidate() const | 104 bool cacheControlContainsMustRevalidate() const |
| 94 { | 105 { |
| 95 if (!m_haveParsedCacheControl) | 106 if (!m_haveParsedCacheControl) |
| 96 parseCacheControlDirectives(); | 107 parseCacheControlDirectives(); |
| 97 return m_cacheControlContainsMustRevalidate; | 108 return m_cacheControlContainsMustRevalidate; |
| 98 } | 109 } |
| 99 | 110 |
| 100 // The ResourceResponse subclass may "shadow" this method to provide platfor
m-specific memory usage information | 111 // The ResourceResponse subclass may "shadow" this method to provide platfor
m-specific memory usage information |
| 101 unsigned memoryUsage() const | 112 unsigned memoryUsage() const |
| 102 { | 113 { |
| 103 // average size, mostly due to URL and Header Map strings | 114 // average size, mostly due to URL and Header Map strings |
| 104 return 1280; | 115 return 1280; |
| 105 } | 116 } |
| 106 | 117 |
| 107 static bool compare(const ResourceResponse& a, const ResourceResponse& b); | 118 static bool compare(const ResourceResponse& a, const ResourceResponse& b); |
| 108 | 119 |
| 109 protected: | 120 protected: |
| 110 ResourceResponseBase() | 121 ResourceResponseBase() |
| 111 : m_expectedContentLength(0) | 122 : m_expectedContentLength(0) |
| 112 , m_httpStatusCode(0) | 123 , m_httpStatusCode(0) |
| 113 , m_expirationDate(0) | 124 , m_expirationDate(0) |
| 114 , m_lastModifiedDate(0) | 125 , m_lastModifiedDate(0) |
| 126 #if ENABLE(APPLICATION_CACHE) |
| 127 , m_appcacheID(NoApplicationCacheID) |
| 128 #endif |
| 115 , m_isNull(true) | 129 , m_isNull(true) |
| 116 , m_haveParsedCacheControl(false) | 130 , m_haveParsedCacheControl(false) |
| 117 { | 131 { |
| 118 } | 132 } |
| 119 | 133 |
| 120 ResourceResponseBase(const KURL& url, const String& mimeType, long long expe
ctedLength, const String& textEncodingName, const String& filename) | 134 ResourceResponseBase(const KURL& url, const String& mimeType, long long expe
ctedLength, const String& textEncodingName, const String& filename) |
| 121 : m_url(url) | 135 : m_url(url) |
| 122 , m_mimeType(mimeType) | 136 , m_mimeType(mimeType) |
| 123 , m_expectedContentLength(expectedLength) | 137 , m_expectedContentLength(expectedLength) |
| 124 , m_textEncodingName(textEncodingName) | 138 , m_textEncodingName(textEncodingName) |
| 125 , m_suggestedFilename(filename) | 139 , m_suggestedFilename(filename) |
| 126 , m_httpStatusCode(0) | 140 , m_httpStatusCode(0) |
| 127 , m_expirationDate(0) | 141 , m_expirationDate(0) |
| 128 , m_lastModifiedDate(0) | 142 , m_lastModifiedDate(0) |
| 143 #if ENABLE(APPLICATION_CACHE) |
| 144 , m_appcacheID(NoApplicationCacheID) |
| 145 #endif |
| 129 , m_isNull(false) | 146 , m_isNull(false) |
| 130 , m_haveParsedCacheControl(false) | 147 , m_haveParsedCacheControl(false) |
| 131 { | 148 { |
| 132 } | 149 } |
| 133 | 150 |
| 134 void lazyInit() const; | 151 void lazyInit() const; |
| 135 | 152 |
| 136 // The ResourceResponse subclass may "shadow" this method to lazily initiali
ze platform specific fields | 153 // The ResourceResponse subclass may "shadow" this method to lazily initiali
ze platform specific fields |
| 137 void platformLazyInit() { } | 154 void platformLazyInit() { } |
| 138 | 155 |
| 139 // The ResourceResponse subclass may "shadow" this method to compare platfor
m specific fields | 156 // The ResourceResponse subclass may "shadow" this method to compare platfor
m specific fields |
| 140 static bool platformCompare(const ResourceResponse&, const ResourceResponse&
) { return true; } | 157 static bool platformCompare(const ResourceResponse&, const ResourceResponse&
) { return true; } |
| 141 | 158 |
| 142 KURL m_url; | 159 KURL m_url; |
| 143 String m_mimeType; | 160 String m_mimeType; |
| 144 long long m_expectedContentLength; | 161 long long m_expectedContentLength; |
| 145 String m_textEncodingName; | 162 String m_textEncodingName; |
| 146 String m_suggestedFilename; | 163 String m_suggestedFilename; |
| 147 int m_httpStatusCode; | 164 int m_httpStatusCode; |
| 148 String m_httpStatusText; | 165 String m_httpStatusText; |
| 149 HTTPHeaderMap m_httpHeaderFields; | 166 HTTPHeaderMap m_httpHeaderFields; |
| 150 time_t m_expirationDate; | 167 time_t m_expirationDate; |
| 151 time_t m_lastModifiedDate; | 168 time_t m_lastModifiedDate; |
| 169 #if ENABLE(APPLICATION_CACHE) |
| 170 KURL m_manifestURL; |
| 171 ApplicationCacheID m_appcacheID; |
| 172 #endif |
| 152 bool m_isNull : 1; | 173 bool m_isNull : 1; |
| 153 | 174 |
| 154 private: | 175 private: |
| 155 void parseCacheControlDirectives() const; | 176 void parseCacheControlDirectives() const; |
| 156 | 177 |
| 157 mutable bool m_haveParsedCacheControl : 1; | 178 mutable bool m_haveParsedCacheControl : 1; |
| 158 mutable bool m_cacheControlContainsMustRevalidate : 1; | 179 mutable bool m_cacheControlContainsMustRevalidate : 1; |
| 159 mutable bool m_cacheControlContainsNoCache : 1; | 180 mutable bool m_cacheControlContainsNoCache : 1; |
| 160 }; | 181 }; |
| 161 | 182 |
| 162 inline bool operator==(const ResourceResponse& a, const ResourceResponse& b) { r
eturn ResourceResponseBase::compare(a, b); } | 183 inline bool operator==(const ResourceResponse& a, const ResourceResponse& b) { r
eturn ResourceResponseBase::compare(a, b); } |
| 163 inline bool operator!=(const ResourceResponse& a, const ResourceResponse& b) { r
eturn !(a == b); } | 184 inline bool operator!=(const ResourceResponse& a, const ResourceResponse& b) { r
eturn !(a == b); } |
| 164 | 185 |
| 165 struct CrossThreadResourceResponseData { | 186 struct CrossThreadResourceResponseData { |
| 166 KURL m_url; | 187 KURL m_url; |
| 167 String m_mimeType; | 188 String m_mimeType; |
| 168 long long m_expectedContentLength; | 189 long long m_expectedContentLength; |
| 169 String m_textEncodingName; | 190 String m_textEncodingName; |
| 170 String m_suggestedFilename; | 191 String m_suggestedFilename; |
| 171 int m_httpStatusCode; | 192 int m_httpStatusCode; |
| 172 String m_httpStatusText; | 193 String m_httpStatusText; |
| 173 OwnPtr<CrossThreadHTTPHeaderMapData> m_httpHeaders; | 194 OwnPtr<CrossThreadHTTPHeaderMapData> m_httpHeaders; |
| 174 time_t m_expirationDate; | 195 time_t m_expirationDate; |
| 175 time_t m_lastModifiedDate; | 196 time_t m_lastModifiedDate; |
| 197 #if ENABLE(APPLICATION_CACHE) |
| 198 ApplicationCacheID m_appcacheID; |
| 199 KURL m_manifestURL; |
| 200 #endif |
| 176 bool m_haveParsedCacheControl : 1; | 201 bool m_haveParsedCacheControl : 1; |
| 177 bool m_cacheControlContainsMustRevalidate : 1; | 202 bool m_cacheControlContainsMustRevalidate : 1; |
| 178 bool m_cacheControlContainsNoCache : 1; | 203 bool m_cacheControlContainsNoCache : 1; |
| 179 }; | 204 }; |
| 180 | 205 |
| 181 } // namespace WebCore | 206 } // namespace WebCore |
| 182 | 207 |
| 183 #endif // ResourceResponseBase_h | 208 #endif // ResourceResponseBase_h |
| OLD | NEW |