Changeset 177294 in webkit
- Timestamp:
- Dec 15, 2014, 11:25:23 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r177292 r177294 1 2014-12-15 Antti Koivisto <antti@apple.com> 2 3 WebKit level persistent caching 4 https://bugs.webkit.org/show_bug.cgi?id=30322 5 6 Reviewed by Sam Weinig. 7 8 Add a cache validation test. The test generates large number of validation header permutations. 9 10 * TestExpectations: Skipped until the feature is enabled. 11 * http/tests/cache/disk-cache-validation-expected.txt: Added. 12 * http/tests/cache/disk-cache-validation.html: Added. 13 * http/tests/cache/resources/cache-test.js: Added. 14 (getServerDate): 15 (makeHeaderValue): 16 (generateTestURL): 17 (loadResource): 18 (loadResources): 19 (printResults): 20 (runTests): 21 (mergeFields): 22 (generateTests): 23 * http/tests/cache/resources/generate-response.cgi: Added. 24 * platform/mac-mountainlion/TestExpectations: Added. 25 * platform/mac-wk1/TestExpectations: 26 1 27 2014-12-15 Myles C. Maxfield <mmaxfield@apple.com> 2 28 -
trunk/LayoutTests/TestExpectations
r177273 r177294 329 329 webkit.org/b/139548 fast/xmlhttprequest/xmlhttprequest-recursive-sync-event.html [ Skip ] 330 330 331 # Network process disk cache is not enabled yet 332 webkit.org/b/30322 http/tests/cache/disk-cache-validation.html [ Skip ] 333 331 334 webkit.org/b/139634 [ Debug ] fast/selectors/matches-backtracking.html [ Slow ] 332 335 webkit.org/b/139634 [ Debug ] fast/selectors/nth-child-of-register-requirement.html [ Slow ] -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r177265 r177294 81 81 compositing/iframes/overlapped-nested-iframes.html [ Pass Failure ] 82 82 83 # Disk cache is WK2 only 84 http/tests/cache/disk-cache-validation.html 85 83 86 ### END OF (2) Failures without bug reports 84 87 ######################################## -
trunk/Source/WebCore/ChangeLog
r177293 r177294 1 2014-12-15 Antti Koivisto <antti@apple.com> 2 3 WebKit level persistent caching 4 https://bugs.webkit.org/show_bug.cgi?id=30322 5 6 Reviewed by Sam Weinig. 7 8 Test: http/tests/cache/disk-cache-validation.html 9 10 * WebCore.exp.in: 11 * inspector/InspectorResourceAgent.cpp: 12 (WebCore::buildObjectForResourceResponse): 13 * platform/network/ResourceResponseBase.cpp: 14 (WebCore::ResourceResponseBase::ResourceResponseBase): 15 (WebCore::ResourceResponseBase::source): 16 (WebCore::ResourceResponseBase::setSource): 17 (WebCore::ResourceResponseBase::wasCached): Deleted. 18 (WebCore::ResourceResponseBase::setWasCached): Deleted. 19 20 Replace wasCached bit with Source enum. 21 This is useful for testing. 22 23 * platform/network/ResourceResponseBase.h: 24 (WebCore::ResourceResponseBase::containsCertificateInfo): 25 (WebCore::ResourceResponseBase::encode): 26 (WebCore::ResourceResponseBase::decode): 27 * testing/Internals.cpp: 28 (WebCore::Internals::xhrResponseSource): 29 (WebCore::Internals::clearMemoryCache): 30 * testing/Internals.h: 31 * testing/Internals.idl: 32 33 Testing support. 34 35 * xml/XMLHttpRequest.h: 36 1 37 2014-12-15 Andreas Kling <akling@apple.com> 2 38 -
trunk/Source/WebCore/WebCore.exp.in
r177259 r177294 899 899 __ZN7WebCore20ResourceResponseBase24setExpectedContentLengthEx 900 900 __ZN7WebCore20ResourceResponseBase6setURLERKNS_3URLE 901 __ZN7WebCore20ResourceResponseBase9setSourceENS0_6SourceE 901 902 __ZN7WebCore20ResourceResponseBaseC2Ev 902 903 __ZN7WebCore20StorageNamespaceImpl29createSessionStorageNamespaceEj … … 1892 1893 __ZNK7WebCore20ResourceResponseBase3urlEv 1893 1894 __ZNK7WebCore20ResourceResponseBase6isHTTPEv 1895 __ZNK7WebCore20ResourceResponseBase6sourceEv 1894 1896 __ZNK7WebCore20ResourceResponseBase8lazyInitENS0_9InitLevelE 1895 1897 __ZNK7WebCore20ResourceResponseBase8mimeTypeEv -
trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp
r176450 r177294 242 242 .setConnectionId(response.connectionID()); 243 243 244 responseObject->setFromDiskCache(response. wasCached());244 responseObject->setFromDiskCache(response.source() == ResourceResponse::Source::DiskCache || response.source() == ResourceResponse::Source::DiskCacheAfterValidation); 245 245 responseObject->setTiming(buildObjectForTiming(response.resourceLoadTiming(), loader)); 246 246 -
trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp
r173426 r177294 55 55 , m_expires(0) 56 56 , m_lastModified(0) 57 , m_wasCached(false)58 57 , m_connectionReused(false) 59 58 , m_isNull(true) … … 66 65 , m_cacheControlContainsNoStore(false) 67 66 , m_cacheControlContainsMustRevalidate(false) 67 , m_source(Source::Unknown) 68 68 { 69 69 } … … 82 82 , m_expires(0) 83 83 , m_lastModified(0) 84 , m_wasCached(false)85 84 , m_connectionReused(false) 86 85 , m_isNull(false) … … 93 92 , m_cacheControlContainsNoStore(false) 94 93 , m_cacheControlContainsMustRevalidate(false) 94 , m_source(Source::Unknown) 95 95 { 96 96 } … … 518 518 } 519 519 520 bool ResourceResponseBase::wasCached() const521 { 522 lazyInit(AllFields); 523 524 return m_ wasCached;525 } 526 527 void ResourceResponseBase::set WasCached(bool value)528 { 529 m_ wasCached = value;520 ResourceResponseBase::Source ResourceResponseBase::source() const 521 { 522 lazyInit(AllFields); 523 524 return m_source; 525 } 526 527 void ResourceResponseBase::setSource(Source source) 528 { 529 m_source = source; 530 530 } 531 531 -
trunk/Source/WebCore/platform/network/ResourceResponseBase.h
r173423 r177294 95 95 96 96 void includeCertificateInfo() const; 97 bool containsCertificateInfo() const { return m_includesCertificateInfo; } 97 98 CertificateInfo certificateInfo() const; 98 99 … … 115 116 void setConnectionReused(bool); 116 117 117 bool wasCached() const; 118 void setWasCached(bool); 118 enum class Source { Unknown, Network, DiskCache, DiskCacheAfterValidation }; 119 Source source() const; 120 void setSource(Source); 119 121 120 122 ResourceLoadTiming& resourceLoadTiming() const { return m_resourceLoadTiming; } … … 173 175 174 176 public: 175 bool m_wasCached : 1;176 177 bool m_connectionReused : 1; 177 178 … … 192 193 mutable bool m_cacheControlContainsNoStore : 1; 193 194 mutable bool m_cacheControlContainsMustRevalidate : 1; 195 196 Source m_source; 194 197 }; 195 198 … … 217 220 if (m_includesCertificateInfo) 218 221 encoder << m_certificateInfo; 222 encoder.encodeEnum(m_source); 219 223 } 220 224 … … 257 261 return false; 258 262 } 263 if (!decoder.decodeEnum(response.m_source)) 264 return false; 259 265 response.m_isNull = false; 260 266 -
trunk/Source/WebCore/testing/Internals.cpp
r177135 r177294 32 32 #include "ApplicationCacheStorage.h" 33 33 #include "BackForwardController.h" 34 #include "CachedImage.h" 34 35 #include "CachedResourceLoader.h" 35 36 #include "Chrome.h" … … 53 54 #include "FrameView.h" 54 55 #include "HTMLIFrameElement.h" 56 #include "HTMLImageElement.h" 55 57 #include "HTMLInputElement.h" 56 58 #include "HTMLNames.h" … … 103 105 #include "WebConsoleAgent.h" 104 106 #include "WorkerThread.h" 107 #include "XMLHttpRequest.h" 105 108 #include <bytecode/CodeBlock.h> 106 109 #include <inspector/InspectorAgentBase.h> … … 385 388 } 386 389 390 String Internals::xhrResponseSource(XMLHttpRequest* xhr) 391 { 392 if (!xhr) 393 return "Null xhr"; 394 if (xhr->resourceResponse().isNull()) 395 return "Null response"; 396 switch (xhr->resourceResponse().source()) { 397 case ResourceResponse::Source::Unknown: 398 return "Unknown"; 399 case ResourceResponse::Source::Network: 400 return "Network"; 401 case ResourceResponse::Source::DiskCache: 402 return "Disk cache"; 403 case ResourceResponse::Source::DiskCacheAfterValidation: 404 return "Disk cache after validation"; 405 } 406 ASSERT_NOT_REACHED(); 407 return "Error"; 408 } 409 410 void Internals::clearMemoryCache() 411 { 412 memoryCache().evictResources(); 413 } 387 414 388 415 Node* Internals::treeScopeRootNode(Node* node, ExceptionCode& ec) -
trunk/Source/WebCore/testing/Internals.h
r177135 r177294 63 63 class TimeRanges; 64 64 class TypeConversions; 65 class XMLHttpRequest; 65 66 66 67 typedef int ExceptionCode; … … 83 84 bool isPreloaded(const String& url); 84 85 bool isLoadingFromMemoryCache(const String& url); 86 String xhrResponseSource(XMLHttpRequest*); 87 void clearMemoryCache(); 85 88 86 89 PassRefPtr<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Node*, ExceptionCode&) const; -
trunk/Source/WebCore/testing/Internals.idl
r177135 r177294 43 43 boolean isPreloaded(DOMString url); 44 44 boolean isLoadingFromMemoryCache(DOMString url); 45 DOMString xhrResponseSource(XMLHttpRequest xhr); 46 void clearMemoryCache(); 45 47 46 48 [RaisesException] CSSStyleDeclaration computedStyleIncludingVisitedInfo(Node node); -
trunk/Source/WebCore/xml/XMLHttpRequest.h
r175053 r177294 145 145 XMLHttpRequestUpload* optionalUpload() const { return m_upload.get(); } 146 146 147 const ResourceResponse& resourceResponse() const { return m_response; } 148 147 149 DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange); 148 150 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); -
trunk/Source/WebKit2/CMakeLists.txt
r177125 r177294 4 4 "${WEBKIT2_DIR}/NetworkProcess" 5 5 "${WEBKIT2_DIR}/NetworkProcess/FileAPI" 6 "${WEBKIT2_DIR}/NetworkProcess/cache" 6 7 "${WEBKIT2_DIR}/Platform" 7 8 "${WEBKIT2_DIR}/Platform/IPC" -
trunk/Source/WebKit2/ChangeLog
r177291 r177294 1 2014-12-15 Antti Koivisto <antti@apple.com> 2 3 WebKit level persistent caching 4 https://bugs.webkit.org/show_bug.cgi?id=30322 5 6 Reviewed by Sam Weinig. 7 8 We can improve performance and open new optimization possibilities by bringing network caching into WebKit. 9 10 This patch implements an experimental HTTP cache living in the network process. 11 12 The main classes are: 13 14 NetworkCache 15 - Implements HTTP cache validation logic including Vary header 16 - Initially non-range GET only 17 - Fast serialization using WebKit types (ResourcesResponse etc) instead of native network layer types 18 19 NetworkCacheKey 20 - Unique identifier for cache entries 21 - Keyed on method/partition/URL 22 23 NetworkCacheStorage 24 - Storage backend 25 - dispatch-IO based implementation (generic posix implementation wouldn't be difficult) 26 - File system only (no SQLite or similar) 27 - One file per resource containing both header and body data 28 - Zero persistent global metadata 29 - Bloom filter for fast fail 30 31 NetworkCacheEncoder/Decoder 32 - Serializisation support with integrity verification. 33 34 The code is behind the NETWORK_CACHE feature flag and requires network process to be enabled to use. 35 36 This patch does not enable the feature yet by default. 37 38 Test: http/tests/cache/disk-cache-validation.html 39 40 * NetworkProcess/cache/NetworkCache.cpp: Added. 41 * NetworkProcess/cache/NetworkCache.h: Added. 42 * NetworkProcess/cache/NetworkCacheKey.cpp: Added. 43 * NetworkProcess/cache/NetworkCacheKey.h: Added. 44 * NetworkProcess/cache/NetworkCacheStorage.h: Added. 45 * NetworkProcess/cache/NetworkCacheStorage.mm: Added. 46 * NetworkProcess/cocoa/NetworkProcessCocoa.mm: 47 (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): 48 (WebKit::NetworkProcess::platformSetCacheModel): 49 * NetworkProcess/ios/NetworkProcessIOS.mm: 50 (WebKit::NetworkProcess::clearCacheForAllOrigins): 51 * NetworkProcess/mac/NetworkProcessMac.mm: 52 (WebKit::NetworkProcess::clearCacheForAllOrigins): 53 * NetworkProcess/mac/NetworkResourceLoaderMac.mm: 54 (WebKit::tryGetShareableHandleFromCFData): 55 * Platform/Logging.h: 56 * WebKit2.xcodeproj/project.pbxproj: 57 * config.h: 58 1 59 2014-12-15 Gavin Barraclough <barraclough@apple.com> 2 60 -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
r176947 r177294 33 33 #include "Logging.h" 34 34 #include "NetworkBlobRegistry.h" 35 #include "NetworkCache.h" 35 36 #include "NetworkConnectionToWebProcess.h" 36 37 #include "NetworkProcess.h" … … 45 46 #include <WebCore/BlobDataFileReference.h> 46 47 #include <WebCore/CertificateInfo.h> 48 #include <WebCore/HTTPHeaderNames.h> 47 49 #include <WebCore/NotImplemented.h> 48 50 #include <WebCore/ResourceHandle.h> … … 131 133 return; 132 134 135 m_currentRequest = originalRequest(); 136 137 #if ENABLE(NETWORK_CACHE) 138 if (!NetworkCache::shared().isEnabled() || sessionID().isEphemeral()) { 139 startNetworkLoad(); 140 return; 141 } 142 143 RefPtr<NetworkResourceLoader> loader(this); 144 NetworkCache::shared().retrieve(originalRequest(), [loader](std::unique_ptr<NetworkCache::Entry> entry) { 145 if (loader->hasOneRef()) { 146 // The loader has been aborted and is only held alive by this lambda. 147 return; 148 } 149 if (!entry) { 150 loader->startNetworkLoad(); 151 return; 152 } 153 if (loader->m_parameters.needsCertificateInfo && !entry->response.containsCertificateInfo()) { 154 loader->startNetworkLoad(); 155 return; 156 } 157 if (entry->needsRevalidation) { 158 loader->validateCacheEntry(WTF::move(entry)); 159 return; 160 } 161 loader->didRetrieveCacheEntry(WTF::move(entry)); 162 }); 163 #else 164 startNetworkLoad(); 165 #endif 166 } 167 168 void NetworkResourceLoader::startNetworkLoad() 169 { 133 170 m_networkingContext = RemoteNetworkingContext::create(sessionID(), m_parameters.shouldClearReferrerOnHTTPSToHTTPRedirect); 134 171 135 172 consumeSandboxExtensions(); 136 137 m_currentRequest = originalRequest();138 173 139 174 if (isSynchronous() || m_parameters.maximumBufferingTime > 0_ms) 140 175 m_bufferedData = WebCore::SharedBuffer::create(); 141 176 177 #if ENABLE(NETWORK_CACHE) 178 if (NetworkCache::shared().isEnabled()) 179 m_bufferedDataForCache = WebCore::SharedBuffer::create(); 180 #endif 181 142 182 bool shouldSniff = m_parameters.contentSniffingPolicy == SniffContent; 143 m_handle = ResourceHandle::create(m_networkingContext.get(), m_currentRequest, this, false /* defersLoading */, shouldSniff);183 m_handle = ResourceHandle::create(m_networkingContext.get(), m_currentRequest, this, m_defersLoading, shouldSniff); 144 184 } 145 185 … … 189 229 } 190 230 191 void NetworkResourceLoader::didReceiveResponseAsync(ResourceHandle* handle, const ResourceResponse& response) 192 { 193 ASSERT_UNUSED(handle, handle == m_handle); 194 231 #if ENABLE(NETWORK_CACHE) 232 static bool isConditionalRequest(const WebCore::ResourceRequest& request) 233 { 234 if (!request.httpHeaderField(WebCore::HTTPHeaderName::IfNoneMatch).isEmpty()) 235 return true; 236 if (!request.httpHeaderField(WebCore::HTTPHeaderName::IfModifiedSince).isEmpty()) 237 return true; 238 return false; 239 } 240 #endif 241 242 void NetworkResourceLoader::didReceiveResponseAsync(ResourceHandle* handle, const ResourceResponse& receivedResponse) 243 { 244 ASSERT_UNUSED(handle, handle == m_handle); 245 246 m_response = receivedResponse; 247 248 m_response.setSource(ResourceResponse::Source::Network); 195 249 if (m_parameters.needsCertificateInfo) 196 response.includeCertificateInfo(); 197 198 if (isSynchronous()) 199 m_synchronousLoadData->response = response; 200 else { 201 // For multipart/x-mixed-replace didReceiveResponseAsync gets called multiple times and buffering would require special handling. 202 if (response.isMultipart()) 203 m_bufferedData = nullptr; 204 205 if (!sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(response, m_parameters.isMainResource))) 206 return; 250 m_response.includeCertificateInfo(); 251 // For multipart/x-mixed-replace didReceiveResponseAsync gets called multiple times and buffering would require special handling. 252 if (!isSynchronous() && m_response.isMultipart()) 253 m_bufferedData = nullptr; 254 255 bool shouldSendDidReceiveResponse = true; 256 #if ENABLE(NETWORK_CACHE) 257 if (m_cacheEntryForValidation) { 258 bool validationSucceeded = m_response.httpStatusCode() == 304; // 304 Not Modified 259 if (validationSucceeded) 260 NetworkCache::shared().update(originalRequest(), *m_cacheEntryForValidation, m_response); 261 if (!validationSucceeded || isConditionalRequest(originalRequest())) 262 m_cacheEntryForValidation = nullptr; 263 } 264 shouldSendDidReceiveResponse = !m_cacheEntryForValidation; 265 #endif 266 267 if (shouldSendDidReceiveResponse) { 268 if (isSynchronous()) 269 m_synchronousLoadData->response = m_response; 270 else { 271 if (!sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(m_response, m_parameters.isMainResource))) 272 return; 273 } 207 274 } 208 275 209 276 // For main resources, the web process is responsible for sending back a NetworkResourceLoader::ContinueDidReceiveResponse message. 210 if (m_parameters.isMainResource) 277 bool shouldContinueDidReceiveResponse = !m_parameters.isMainResource; 278 #if ENABLE(NETWORK_CACHE) 279 shouldContinueDidReceiveResponse = shouldContinueDidReceiveResponse || m_cacheEntryForValidation; 280 #endif 281 if (!shouldContinueDidReceiveResponse) 211 282 return; 212 283 … … 224 295 { 225 296 ASSERT_UNUSED(handle, handle == m_handle); 226 297 #if ENABLE(NETWORK_CACHE) 298 ASSERT(!m_cacheEntryForValidation); 299 300 if (m_bufferedDataForCache) 301 m_bufferedDataForCache->append(buffer.get()); 302 #endif 227 303 // FIXME: At least on OS X Yosemite we always get -1 from the resource handle. 228 304 unsigned encodedDataLength = reportedEncodedDataLength >= 0 ? reportedEncodedDataLength : buffer->size(); … … 241 317 { 242 318 ASSERT_UNUSED(handle, handle == m_handle); 319 320 #if ENABLE(NETWORK_CACHE) 321 if (NetworkCache::shared().isEnabled()) { 322 if (m_cacheEntryForValidation) { 323 // 304 Not Modified 324 ASSERT(m_response.httpStatusCode() == 304); 325 LOG(NetworkCache, "(NetworkProcess) revalidated"); 326 didRetrieveCacheEntry(WTF::move(m_cacheEntryForValidation)); 327 return; 328 } 329 330 bool hasCacheableRedirect = WebCore::redirectChainAllowsReuse(m_redirectChainCacheStatus); 331 if (hasCacheableRedirect && m_redirectChainCacheStatus.status == RedirectChainCacheStatus::CachedRedirection) { 332 // FIXME: Cache the actual redirects instead of the end result. 333 double now = currentTime(); 334 double responseEndOfValidity = now + WebCore::computeFreshnessLifetimeForHTTPFamily(m_response, now) - WebCore::computeCurrentAge(m_response, now); 335 hasCacheableRedirect = responseEndOfValidity <= m_redirectChainCacheStatus.endOfValidity; 336 } 337 338 bool isPrivate = sessionID().isEphemeral(); 339 if (hasCacheableRedirect && !isPrivate) 340 NetworkCache::shared().store(originalRequest(), m_response, m_bufferedDataForCache.release()); 341 } 342 #endif 243 343 244 344 if (isSynchronous()) … … 259 359 void NetworkResourceLoader::didFail(ResourceHandle* handle, const ResourceError& error) 260 360 { 261 ASSERT_UNUSED(handle, handle == m_handle); 361 ASSERT_UNUSED(handle, !handle || handle == m_handle); 362 363 #if ENABLE(NETWORK_CACHE) 364 m_cacheEntryForValidation = nullptr; 365 #endif 262 366 263 367 if (isSynchronous()) { … … 280 384 m_currentRequest = request; 281 385 386 #if ENABLE(NETWORK_CACHE) 387 WebCore::updateRedirectChainStatus(m_redirectChainCacheStatus, redirectResponse); 388 #endif 389 282 390 if (isSynchronous()) { 283 391 // FIXME: This needs to be fixed to follow the redirect correctly even for cross-domain requests. 284 392 // This includes at least updating host records, and comparing the current request instead of the original request here. 285 if (!protocolHostAndPortAreEqual(originalRequest().url(), request.url())) {393 if (!protocolHostAndPortAreEqual(originalRequest().url(), m_currentRequest.url())) { 286 394 ASSERT(m_synchronousLoadData->error.isNull()); 287 395 m_synchronousLoadData->error = SynchronousLoaderClient::platformBadResponseError(); … … 291 399 return; 292 400 } 293 sendAbortingOnFailure(Messages::WebResourceLoader::WillSendRequest( request, redirectResponse));401 sendAbortingOnFailure(Messages::WebResourceLoader::WillSendRequest(m_currentRequest, redirectResponse)); 294 402 } 295 403 … … 429 537 } 430 538 539 #if ENABLE(NETWORK_CACHE) 540 void NetworkResourceLoader::didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry> entry) 541 { 542 if (isSynchronous()) { 543 m_synchronousLoadData->response = entry->response; 544 sendReplyToSynchronousRequest(*m_synchronousLoadData, entry->buffer.get()); 545 } else { 546 sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(entry->response, m_parameters.isMainResource)); 547 548 if (!entry->shareableResourceHandle.isNull()) 549 send(Messages::WebResourceLoader::DidReceiveResource(entry->shareableResourceHandle, currentTime())); 550 else { 551 bool shouldContinue = sendBufferMaybeAborting(*entry->buffer, entry->buffer->size()); 552 if (!shouldContinue) 553 return; 554 send(Messages::WebResourceLoader::DidFinishResourceLoad(currentTime())); 555 } 556 } 557 558 cleanup(); 559 } 560 561 void NetworkResourceLoader::validateCacheEntry(std::unique_ptr<NetworkCache::Entry> entry) 562 { 563 ASSERT(!m_handle); 564 565 String eTag = entry->response.httpHeaderField(WebCore::HTTPHeaderName::ETag); 566 String lastModified = entry->response.httpHeaderField(WebCore::HTTPHeaderName::LastModified); 567 if (!eTag.isEmpty()) 568 m_currentRequest.setHTTPHeaderField(WebCore::HTTPHeaderName::IfNoneMatch, eTag); 569 if (!lastModified.isEmpty()) 570 m_currentRequest.setHTTPHeaderField(WebCore::HTTPHeaderName::IfModifiedSince, lastModified); 571 572 m_cacheEntryForValidation = WTF::move(entry); 573 574 startNetworkLoad(); 575 } 576 #endif 577 431 578 IPC::Connection* NetworkResourceLoader::messageSenderConnection() 432 579 { -
trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
r176858 r177294 30 30 31 31 #include "MessageSender.h" 32 #include "NetworkCache.h" 32 33 #include "NetworkConnectionToWebProcessMessages.h" 33 34 #include "NetworkResourceLoadParameters.h" 34 35 #include "ShareableResource.h" 36 #include <WebCore/CacheValidation.h> 35 37 #include <WebCore/ResourceError.h> 36 38 #include <WebCore/ResourceHandleClient.h> … … 99 101 #endif 100 102 void continueWillSendRequest(const WebCore::ResourceRequest& newRequest); 103 104 WebCore::SharedBuffer* bufferedData() { return m_bufferedData.get(); } 105 const WebCore::ResourceResponse& response() const { return m_response; } 101 106 102 107 NetworkConnectionToWebProcess* connectionToWebProcess() const { return m_connection.get(); } … … 143 148 #endif 144 149 150 #if ENABLE(NETWORK_CACHE) 151 void didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry>); 152 void validateCacheEntry(std::unique_ptr<NetworkCache::Entry>); 153 #endif 154 155 void startNetworkLoad(); 145 156 void continueDidReceiveResponse(); 146 157 … … 168 179 169 180 WebCore::ResourceRequest m_currentRequest; 181 WebCore::ResourceResponse m_response; 170 182 171 183 size_t m_bytesReceived; … … 181 193 182 194 WebCore::Timer m_bufferingTimer; 195 #if ENABLE(NETWORK_CACHE) 196 RefPtr<WebCore::SharedBuffer> m_bufferedDataForCache; 197 std::unique_ptr<NetworkCache::Entry> m_cacheEntryForValidation; 198 199 WebCore::RedirectChainCacheStatus m_redirectChainCacheStatus; 200 #endif 183 201 }; 184 202 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.cpp
r176398 r177294 42 42 uint8_t* NetworkCacheEncoder::grow(size_t size) 43 43 { 44 uint8_t* position = m_buffer.data() +m_buffer.size();44 size_t newPosition = m_buffer.size(); 45 45 m_buffer.grow(m_buffer.size() + size); 46 return position;46 return m_buffer.data() + newPosition; 47 47 } 48 48 -
trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r177038 r177294 29 29 #if ENABLE(NETWORK_PROCESS) 30 30 31 #import "NetworkCache.h" 31 32 #import "NetworkProcessCreationParameters.h" 32 33 #import "NetworkResourceLoader.h" … … 63 64 if (!m_diskCacheDirectory.isNull()) { 64 65 SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle); 66 #if ENABLE(NETWORK_CACHE) 67 if (NetworkCache::shared().initialize(m_diskCacheDirectory)) { 68 NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; 69 [NSURLCache setSharedURLCache:URLCache]; 70 return; 71 } 72 #endif 65 73 #if PLATFORM(IOS) 66 74 [NSURLCache setSharedURLCache:adoptNS([[NSURLCache alloc] … … 128 136 pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity); 129 137 138 #if ENABLE(NETWORK_CACHE) 139 if (NetworkCache::shared().isEnabled()) { 140 NetworkCache::shared().setMaximumSize(urlCacheDiskCapacity); 141 return; 142 } 143 #endif 130 144 NSURLCache *nsurlCache = [NSURLCache sharedURLCache]; 131 145 [nsurlCache setMemoryCapacity:urlCacheMemoryCapacity]; … … 136 150 void NetworkProcess::clearDiskCache(std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler) 137 151 { 152 #if ENABLE(NETWORK_CACHE) 153 NetworkCache::shared().clear(); 154 #endif 155 138 156 if (!m_clearCacheDispatchGroup) 139 157 m_clearCacheDispatchGroup = dispatch_group_create(); -
trunk/Source/WebKit2/NetworkProcess/ios/NetworkProcessIOS.mm
r171066 r177294 29 29 #if PLATFORM(IOS) && ENABLE(NETWORK_PROCESS) 30 30 31 #import "NetworkCache.h" 31 32 #import "NetworkProcessCreationParameters.h" 33 #import "ResourceCachesToClear.h" 32 34 #import "SandboxInitializationParameters.h" 33 35 #import "SecItemShim.h" … … 75 77 } 76 78 77 void NetworkProcess::clearCacheForAllOrigins(uint32_t )79 void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear) 78 80 { 81 ResourceCachesToClear resourceCachesToClear = static_cast<ResourceCachesToClear>(cachesToClear); 82 if (resourceCachesToClear == InMemoryResourceCachesOnly) 83 return; 84 #if ENABLE(NETWORK_CACHE) 85 NetworkCache::shared().clear(); 86 #endif 79 87 } 80 88 -
trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm
r177038 r177294 29 29 #if PLATFORM(MAC) && ENABLE(NETWORK_PROCESS) 30 30 31 #import "NetworkCache.h" 31 32 #import "NetworkProcessCreationParameters.h" 32 33 #import "NetworkResourceLoader.h" -
trunk/Source/WebKit2/NetworkProcess/mac/NetworkResourceLoaderMac.mm
r176448 r177294 43 43 static void tryGetShareableHandleFromCFData(ShareableResource::Handle& handle, CFDataRef data) 44 44 { 45 if (!data || CFDataGetLength(data) < (CFIndex)NetworkResourceLoader::fileBackedResourceMinimumSize())46 return;47 48 45 RefPtr<SharedMemory> sharedMemory = SharedMemory::createFromVMBuffer((void*)CFDataGetBytePtr(data), CFDataGetLength(data)); 49 46 if (!sharedMemory) { -
trunk/Source/WebKit2/Platform/Logging.h
r174524 r177294 52 52 M(View) \ 53 53 M(IDB) \ 54 M(NetworkCache) \ 55 M(NetworkCacheStorage) \ 54 56 55 57 #define DECLARE_LOG_CHANNEL(name) \ -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r177192 r177294 1673 1673 E1EE53E311F8CFC000CCBEE4 /* InjectedBundlePageEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE53DC11F8CF9F00CCBEE4 /* InjectedBundlePageEditorClient.h */; }; 1674 1674 E1EE53E711F8CFFB00CCBEE4 /* InjectedBundlePageEditorClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EE53E611F8CFFB00CCBEE4 /* InjectedBundlePageEditorClient.cpp */; }; 1675 E4436ECA1A0D03FA00EAD204 /* NetworkCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4436EBE1A0CFDB200EAD204 /* NetworkCache.cpp */; }; 1676 E4436ECC1A0D040B00EAD204 /* NetworkCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E4436EBF1A0CFDB200EAD204 /* NetworkCache.h */; }; 1677 E4436ECD1A0D040B00EAD204 /* NetworkCacheKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4436EC01A0CFDB200EAD204 /* NetworkCacheKey.cpp */; }; 1678 E4436ECE1A0D040B00EAD204 /* NetworkCacheKey.h in Headers */ = {isa = PBXBuildFile; fileRef = E4436EC11A0CFDB200EAD204 /* NetworkCacheKey.h */; }; 1679 E4436ECF1A0D040B00EAD204 /* NetworkCacheStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E4436EC21A0CFDB200EAD204 /* NetworkCacheStorage.h */; }; 1680 E4436ED01A0D040B00EAD204 /* NetworkCacheStorageCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4436EC31A0CFDB200EAD204 /* NetworkCacheStorageCocoa.mm */; }; 1675 1681 E489D28A1A0A2DB80078C06A /* NetworkCacheCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E489D2831A0A2DB80078C06A /* NetworkCacheCoder.h */; }; 1676 1682 E489D28B1A0A2DB80078C06A /* NetworkCacheCoders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E489D2841A0A2DB80078C06A /* NetworkCacheCoders.cpp */; }; … … 3803 3809 E1FEF39A190F76F300731658 /* com.apple.WebKit.Databases.sb.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = com.apple.WebKit.Databases.sb.in; sourceTree = "<group>"; }; 3804 3810 E1FEF39C190F791C00731658 /* DatabaseProcessIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseProcessIOS.mm; sourceTree = "<group>"; }; 3811 E4436EBE1A0CFDB200EAD204 /* NetworkCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCache.cpp; sourceTree = "<group>"; }; 3812 E4436EBF1A0CFDB200EAD204 /* NetworkCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCache.h; sourceTree = "<group>"; }; 3813 E4436EC01A0CFDB200EAD204 /* NetworkCacheKey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheKey.cpp; sourceTree = "<group>"; }; 3814 E4436EC11A0CFDB200EAD204 /* NetworkCacheKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheKey.h; sourceTree = "<group>"; }; 3815 E4436EC21A0CFDB200EAD204 /* NetworkCacheStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheStorage.h; sourceTree = "<group>"; }; 3816 E4436EC31A0CFDB200EAD204 /* NetworkCacheStorageCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkCacheStorageCocoa.mm; sourceTree = "<group>"; }; 3805 3817 E489D2831A0A2DB80078C06A /* NetworkCacheCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheCoder.h; sourceTree = "<group>"; }; 3806 3818 E489D2841A0A2DB80078C06A /* NetworkCacheCoders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheCoders.cpp; sourceTree = "<group>"; }; … … 7121 7133 isa = PBXGroup; 7122 7134 children = ( 7135 E4436EBE1A0CFDB200EAD204 /* NetworkCache.cpp */, 7136 E4436EBF1A0CFDB200EAD204 /* NetworkCache.h */, 7123 7137 E489D2831A0A2DB80078C06A /* NetworkCacheCoder.h */, 7124 7138 E489D2841A0A2DB80078C06A /* NetworkCacheCoders.cpp */, … … 7128 7142 E489D2881A0A2DB80078C06A /* NetworkCacheEncoder.cpp */, 7129 7143 E489D2891A0A2DB80078C06A /* NetworkCacheEncoder.h */, 7144 E4436EC01A0CFDB200EAD204 /* NetworkCacheKey.cpp */, 7145 E4436EC11A0CFDB200EAD204 /* NetworkCacheKey.h */, 7146 E4436EC21A0CFDB200EAD204 /* NetworkCacheStorage.h */, 7147 E4436EC31A0CFDB200EAD204 /* NetworkCacheStorageCocoa.mm */, 7130 7148 ); 7131 7149 name = cache; … … 7229 7247 BCBAACF41452324F0053F82F /* WKBrowsingContextGroup.h in Headers */, 7230 7248 BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */, 7249 E4436ECE1A0D040B00EAD204 /* NetworkCacheKey.h in Headers */, 7231 7250 BCA284D71492F2C7001F9042 /* WKConnection.h in Headers */, 7232 7251 BC017D0716260FF4007054F5 /* WKDOMDocument.h in Headers */, … … 7674 7693 51A9E1061315CCFC009E7031 /* WebKeyValueStorageManager.h in Headers */, 7675 7694 373D122718A473F60066D9CC /* _WKFrameHandleInternal.h in Headers */, 7695 E4436ECF1A0D040B00EAD204 /* NetworkCacheStorage.h in Headers */, 7676 7696 1AE00D611831792100087DD7 /* FrameLoadState.h in Headers */, 7677 7697 BCB63478116BF10600603215 /* WebKit2_C.h in Headers */, … … 7820 7840 BC14DF9F120B635F00826C0C /* WKBundleScriptWorld.h in Headers */, 7821 7841 1AF4CEF018BC481800BC2D34 /* VisitedLinkTableController.h in Headers */, 7842 E4436ECC1A0D040B00EAD204 /* NetworkCache.h in Headers */, 7822 7843 BC4075F6124FF0270068F20A /* WKCertificateInfo.h in Headers */, 7823 7844 BC407627124FF0400068F20A /* WKCertificateInfoMac.h in Headers */, … … 9065 9086 1A6280F31919982A006AD9F9 /* WebKit.m in Sources */, 9066 9087 51FD18B51651FBAD00DBE1CE /* NetworkResourceLoader.cpp in Sources */, 9088 E4436ECD1A0D040B00EAD204 /* NetworkCacheKey.cpp in Sources */, 9067 9089 51E3B67F16F266B3009968DC /* NetworkResourceLoaderMac.mm in Sources */, 9068 9090 E152551A17011819003D7ADB /* NetworkResourceLoaderMessageReceiver.cpp in Sources */, … … 9426 9448 9321D5881A38EE74008052BE /* WKImmediateActionController.mm in Sources */, 9427 9449 1A002D48196B345D00B9AD44 /* SessionStateCoding.mm in Sources */, 9450 E4436ED01A0D040B00EAD204 /* NetworkCacheStorageCocoa.mm in Sources */, 9428 9451 BC306825125A6B9400E71278 /* WebProcessCreationParameters.cpp in Sources */, 9429 9452 1F7506B01859162C00EC0FF7 /* WKWebProcessPlugInScriptWorld.mm in Sources */, … … 9456 9479 0F5947A7187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp in Sources */, 9457 9480 D3B9484811FF4B6500032B39 /* WebSearchPopupMenu.cpp in Sources */, 9481 E4436ECA1A0D03FA00EAD204 /* NetworkCache.cpp in Sources */, 9458 9482 BCC5715C115ADAEF001CCAF9 /* WebSystemInterface.mm in Sources */, 9459 9483 C0337DD8127A51B6008FF4F4 /* WebTouchEvent.cpp in Sources */, -
trunk/Source/WebKit2/config.h
r173393 r177294 93 93 #endif 94 94 #endif 95 96 #ifndef ENABLE_NETWORK_CACHE 97 #if PLATFORM(MAC) && ENABLE(NETWORK_PROCESS) 98 #define ENABLE_NETWORK_CACHE 0 99 #endif 100 #endif
Note:
See TracChangeset
for help on using the changeset viewer.