Remove most cases of #if ENABLE(CACHE_PARTITIONING)
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2017 11:09:28 +0000 (11:09 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2017 11:09:28 +0000 (11:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167990

Reviewed by Sam Weinig.

Source/WebCore:

We'll just return empty string for the partition if partitioning is not enabled.

* html/DOMURL.cpp:
(WebCore::DOMURL::revokeObjectURL):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::cachedResource):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::url):
(WebCore::CachedResource::cachePartition):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
(WebCore::CachedResourceLoader::requestResource):
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::setDomainForCachePartition):
* loader/cache/CachedResourceRequest.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::add):
(WebCore::MemoryCache::revalidationSucceeded):
(WebCore::MemoryCache::resourceForRequestImpl):
(WebCore::MemoryCache::addImageToCache):
(WebCore::MemoryCache::removeImageFromCache):
(WebCore::MemoryCache::remove):
(WebCore::MemoryCache::removeResourcesWithOrigin):
(WebCore::MemoryCache::removeResourcesWithOrigins):
(WebCore::MemoryCache::getOriginsWithCache):
(WebCore::MemoryCache::originsWithCache):
* loader/cache/MemoryCache.h:
* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::domainForCachePartition):
* page/SecurityOrigin.h:
* platform/SchemeRegistry.cpp:
(WebCore::cachePartitioningSchemes):
(WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme):
* platform/SchemeRegistry.h:
* platform/ios/WebCoreSystemInterfaceIOS.mm:
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:
* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::setAsIsolatedCopy):
(WebCore::ResourceRequestBase::setCachePartition):
(WebCore::ResourceRequestBase::partitionName):
* platform/network/ResourceRequestBase.h:
(WebCore::ResourceRequestBase::cachePartition):
(WebCore::ResourceRequestBase::setDomainForCachePartition):
* platform/network/cf/ResourceRequest.h:
(WebCore::ResourceRequest::cachePartition): Deleted.
(WebCore::ResourceRequest::setCachePartition): Deleted.
(WebCore::ResourceRequest::setDomainForCachePartition): Deleted.
* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::ResourceRequest::doUpdatePlatformRequest):
(WebCore::ResourceRequest::doUpdateResourceRequest):
(WebCore::ResourceRequest::partitionName): Deleted.
(WebCore::ResourceRequest::doPlatformSetAsIsolatedCopy): Deleted.
* platform/network/cf/ResourceResponse.h:
* platform/network/cocoa/ResourceRequestCocoa.mm:
(WebCore::ResourceRequest::doUpdateResourceRequest):
(WebCore::ResourceRequest::doUpdatePlatformRequest):
* testing/Internals.cpp:
(WebCore::Internals::isLoadingFromMemoryCache):

Source/WebKit/mac:

* Misc/WebCache.mm:
(+[WebCache addImageToCache:forURL:forFrame:]):
(+[WebCache removeImageFromCacheForURL:forFrame:]):
* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKit2:

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::makeCacheKey):
* NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
(WebKit::NetworkCache::constructRevalidationRequest):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ResourceRequest>::encode):
(IPC::ArgumentCoder<ResourceRequest>::decode):
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/API/C/WKContext.cpp:
(WKContextRegisterURLSchemeAsCachePartitioned):
* UIProcess/WebProcessPool.cpp:
(WebKit::m_hiddenPageThrottlingTimer):
(WebKit::WebProcessPool::createNewWebProcess):
(WebKit::WebProcessPool::registerURLSchemeAsCachePartitioned):
* UIProcess/WebProcessPool.h:
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::registerURLSchemeAsCachePartitioned):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211946 268f45cc-cd09-0410-ab3c-d52691b4dbfc

51 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/WebSocketChannel.cpp
Source/WebCore/html/DOMURL.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/loader/cache/CachedResourceRequest.h
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebCore/loader/cache/MemoryCache.h
Source/WebCore/page/SecurityOrigin.cpp
Source/WebCore/page/SecurityOrigin.h
Source/WebCore/platform/SchemeRegistry.cpp
Source/WebCore/platform/SchemeRegistry.h
Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/platform/network/ResourceHandleInternal.h
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
Source/WebCore/platform/network/cf/ResourceRequest.h
Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Source/WebCore/platform/network/cf/ResourceResponse.h
Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm
Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp
Source/WebCore/platform/network/curl/ResourceHandleManager.cpp
Source/WebCore/platform/network/mac/ResourceHandleMac.mm
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
Source/WebCore/testing/Internals.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebCache.mm
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkDataTask.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in

index ad1d3f5..63e6ce7 100644 (file)
@@ -1,3 +1,74 @@
+2017-02-09  Antti Koivisto  <antti@apple.com>
+
+        Remove most cases of #if ENABLE(CACHE_PARTITIONING)
+        https://bugs.webkit.org/show_bug.cgi?id=167990
+
+        Reviewed by Sam Weinig.
+
+        We'll just return empty string for the partition if partitioning is not enabled.
+
+        * html/DOMURL.cpp:
+        (WebCore::DOMURL::revokeObjectURL):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::cachedResource):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadURL):
+        * loader/archive/cf/LegacyWebArchive.cpp:
+        (WebCore::LegacyWebArchive::create):
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::url):
+        (WebCore::CachedResource::cachePartition):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
+        (WebCore::CachedResourceLoader::requestResource):
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::setDomainForCachePartition):
+        * loader/cache/CachedResourceRequest.h:
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::add):
+        (WebCore::MemoryCache::revalidationSucceeded):
+        (WebCore::MemoryCache::resourceForRequestImpl):
+        (WebCore::MemoryCache::addImageToCache):
+        (WebCore::MemoryCache::removeImageFromCache):
+        (WebCore::MemoryCache::remove):
+        (WebCore::MemoryCache::removeResourcesWithOrigin):
+        (WebCore::MemoryCache::removeResourcesWithOrigins):
+        (WebCore::MemoryCache::getOriginsWithCache):
+        (WebCore::MemoryCache::originsWithCache):
+        * loader/cache/MemoryCache.h:
+        * page/SecurityOrigin.cpp:
+        (WebCore::SecurityOrigin::domainForCachePartition):
+        * page/SecurityOrigin.h:
+        * platform/SchemeRegistry.cpp:
+        (WebCore::cachePartitioningSchemes):
+        (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme):
+        * platform/SchemeRegistry.h:
+        * platform/ios/WebCoreSystemInterfaceIOS.mm:
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::setAsIsolatedCopy):
+        (WebCore::ResourceRequestBase::setCachePartition):
+        (WebCore::ResourceRequestBase::partitionName):
+        * platform/network/ResourceRequestBase.h:
+        (WebCore::ResourceRequestBase::cachePartition):
+        (WebCore::ResourceRequestBase::setDomainForCachePartition):
+        * platform/network/cf/ResourceRequest.h:
+        (WebCore::ResourceRequest::cachePartition): Deleted.
+        (WebCore::ResourceRequest::setCachePartition): Deleted.
+        (WebCore::ResourceRequest::setDomainForCachePartition): Deleted.
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        (WebCore::ResourceRequest::doUpdateResourceRequest):
+        (WebCore::ResourceRequest::partitionName): Deleted.
+        (WebCore::ResourceRequest::doPlatformSetAsIsolatedCopy): Deleted.
+        * platform/network/cf/ResourceResponse.h:
+        * platform/network/cocoa/ResourceRequestCocoa.mm:
+        (WebCore::ResourceRequest::doUpdateResourceRequest):
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        * testing/Internals.cpp:
+        (WebCore::Internals::isLoadingFromMemoryCache):
+
 2017-02-09  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add Web Bluetooth as Not Considering
index 323c98e..e76f6b9 100644 (file)
@@ -124,11 +124,7 @@ void WebSocketChannel::connect(const URL& requestedURL, const String& protocol)
         ref();
         Page* page = frame->page();
         SessionID sessionID = page ? page->sessionID() : SessionID::defaultSessionID();
-#if ENABLE(CACHE_PARTITIONING)
         String partition = m_document->topDocument().securityOrigin().domainForCachePartition();
-#else
-        String partition = emptyString();
-#endif
         m_handle = m_socketProvider->createSocketStreamHandle(m_handshake->url(), *this, sessionID, partition);
     }
 }
index 67e2d05..1a5cd62 100644 (file)
@@ -120,9 +120,8 @@ void DOMURL::revokeObjectURL(ScriptExecutionContext& scriptExecutionContext, con
 {
     URL url(URL(), urlString);
     ResourceRequest request(url);
-#if ENABLE(CACHE_PARTITIONING)
     request.setDomainForCachePartition(scriptExecutionContext.topOrigin().domainForCachePartition());
-#endif
+
     MemoryCache::removeRequestFromSessionCaches(scriptExecutionContext, request);
 
     scriptExecutionContext.publicURLManager().revoke(url);
index 16b7967..de057b5 100644 (file)
@@ -260,9 +260,7 @@ CachedResource* InspectorPageAgent::cachedResource(Frame* frame, const URL& url)
     CachedResource* cachedResource = frame->document()->cachedResourceLoader().cachedResource(MemoryCache::removeFragmentIdentifierIfNeeded(url));
     if (!cachedResource) {
         ResourceRequest request(url);
-#if ENABLE(CACHE_PARTITIONING)
         request.setDomainForCachePartition(frame->document()->topOrigin().domainForCachePartition());
-#endif
         cachedResource = MemoryCache::singleton().resourceForRequest(request, frame->page()->sessionID());
     }
 
index e66582e..c18c29c 100644 (file)
@@ -1201,10 +1201,9 @@ void FrameLoader::loadURL(const FrameLoadRequest& frameLoadRequest, const String
         RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(referrer);
         addHTTPOriginIfNeeded(request, referrerOrigin->toString());
     }
-#if ENABLE(CACHE_PARTITIONING)
     if (&m_frame.tree().top() != &m_frame)
         request.setDomainForCachePartition(m_frame.tree().top().document()->securityOrigin().domainForCachePartition());
-#endif
+
     addExtraFieldsToRequest(request, newLoadType, true);
     if (newLoadType == FrameLoadType::Reload || newLoadType == FrameLoadType::ReloadFromOrigin)
         request.setCachePolicy(ReloadIgnoringCacheData);
index 4e1a673..097482f 100644 (file)
@@ -514,9 +514,8 @@ RefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString, Fr
                 }
 
                 ResourceRequest request(subresourceURL);
-#if ENABLE(CACHE_PARTITIONING)
                 request.setDomainForCachePartition(frame.document()->topOrigin().domainForCachePartition());
-#endif
+
                 if (auto* cachedResource = MemoryCache::singleton().resourceForRequest(request, frame.page()->sessionID())) {
                     if (auto resource = ArchiveResource::create(cachedResource->resourceBuffer(), subresourceURL, cachedResource->response())) {
                         subresources.append(resource.releaseNonNull());
index 816b539..a340f89 100644 (file)
@@ -114,9 +114,7 @@ public:
     const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
     ResourceRequest& resourceRequest() { return m_resourceRequest; }
     const URL& url() const { return m_resourceRequest.url();}
-#if ENABLE(CACHE_PARTITIONING)
     const String& cachePartition() const { return m_resourceRequest.cachePartition(); }
-#endif
     SessionID sessionID() const { return m_sessionID; }
     Type type() const { return m_type; }
 
index 612c863..6e81651 100644 (file)
@@ -217,10 +217,8 @@ CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestCSSStyleS
 
 CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSStyleSheet(CachedResourceRequest&& request)
 {
-#if ENABLE(CACHE_PARTITIONING)
     ASSERT(document());
     request.setDomainForCachePartition(*document());
-#endif
 
     auto& memoryCache = MemoryCache::singleton();
     if (request.allowsCaching()) {
@@ -733,10 +731,8 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
 
     // See if we can use an existing resource from the cache.
     CachedResourceHandle<CachedResource> resource;
-#if ENABLE(CACHE_PARTITIONING)
     if (document())
         request.setDomainForCachePartition(*document());
-#endif
 
     if (request.allowsCaching())
         resource = memoryCache.resourceForRequest(request.resourceRequest(), sessionID());
index 5d9a3ca..635ccde 100644 (file)
@@ -129,12 +129,10 @@ void CachedResourceRequest::upgradeInsecureRequestIfNeeded(Document& document)
     upgradeInsecureResourceRequestIfNeeded(m_resourceRequest, document);
 }
 
-#if ENABLE(CACHE_PARTITIONING)
 void CachedResourceRequest::setDomainForCachePartition(Document& document)
 {
     m_resourceRequest.setDomainForCachePartition(document.topOrigin().domainForCachePartition());
 }
-#endif
 
 static inline String acceptHeaderValueFromType(CachedResource::Type type)
 {
index 8c1e138..1030b36 100644 (file)
@@ -75,9 +75,7 @@ public:
 #if ENABLE(CONTENT_EXTENSIONS)
     void applyBlockedStatus(const ContentExtensions::BlockedStatus&);
 #endif
-#if ENABLE(CACHE_PARTITIONING)
     void setDomainForCachePartition(Document&);
-#endif
     bool isLinkPreload() const { return m_isLinkPreload; }
     void setIsLinkPreload() { m_isLinkPreload = true; }
 
index d8d30df..75ee84b 100644 (file)
@@ -115,11 +115,8 @@ bool MemoryCache::add(CachedResource& resource)
 
     ASSERT(WTF::isMainThread());
 
-#if ENABLE(CACHE_PARTITIONING)
     auto key = std::make_pair(resource.url(), resource.cachePartition());
-#else
-    auto& key = resource.url();
-#endif
+
     ensureSessionResourceMap(resource.sessionID()).set(key, &resource);
     resource.setInCache(true);
     
@@ -144,11 +141,8 @@ void MemoryCache::revalidationSucceeded(CachedResource& revalidatingResource, co
     remove(revalidatingResource);
 
     auto& resources = ensureSessionResourceMap(resource.sessionID());
-#if ENABLE(CACHE_PARTITIONING)
     auto key = std::make_pair(resource.url(), resource.cachePartition());
-#else
-    auto& key = resource.url();
-#endif
+
     ASSERT(!resources.get(key));
     resources.set(key, &resource);
     resource.setInCache(true);
@@ -189,11 +183,7 @@ CachedResource* MemoryCache::resourceForRequestImpl(const ResourceRequest& reque
     ASSERT(WTF::isMainThread());
     URL url = removeFragmentIdentifierIfNeeded(request.url());
 
-#if ENABLE(CACHE_PARTITIONING)
     auto key = std::make_pair(url, request.cachePartition());
-#else
-    auto& key = url;
-#endif
     return resources.get(key);
 }
 
@@ -232,9 +222,8 @@ bool MemoryCache::addImageToCache(NativeImagePtr&& image, const URL& url, const
 
     cachedImage->addClient(dummyCachedImageClient());
     cachedImage->setDecodedSize(bitmapImage->decodedSize());
-#if ENABLE(CACHE_PARTITIONING)
     cachedImage->resourceRequest().setDomainForCachePartition(domainForCachePartition);
-#endif
+
     return add(*cachedImage.release());
 }
 
@@ -244,12 +233,8 @@ void MemoryCache::removeImageFromCache(const URL& url, const String& domainForCa
     if (!resources)
         return;
 
-#if ENABLE(CACHE_PARTITIONING)
     auto key = std::make_pair(url, ResourceRequest::partitionName(domainForCachePartition));
-#else
-    UNUSED_PARAM(domainForCachePartition);
-    auto& key = url;
-#endif
+
     CachedResource* resource = resources->get(key);
     if (!resource)
         return;
@@ -439,11 +424,8 @@ void MemoryCache::remove(CachedResource& resource)
     // The resource may have already been removed by someone other than our caller,
     // who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>.
     if (auto* resources = sessionResourceMap(resource.sessionID())) {
-#if ENABLE(CACHE_PARTITIONING)
         auto key = std::make_pair(resource.url(), resource.cachePartition());
-#else
-        auto& key = resource.url();
-#endif
+
         if (resource.inCache()) {
             // Remove resource from the resource map.
             resources->remove(key);
@@ -527,21 +509,17 @@ void MemoryCache::resourceAccessed(CachedResource& resource)
 
 void MemoryCache::removeResourcesWithOrigin(SecurityOrigin& origin)
 {
-#if ENABLE(CACHE_PARTITIONING)
     String originPartition = ResourceRequest::partitionName(origin.host());
-#endif
 
     Vector<CachedResource*> resourcesWithOrigin;
     for (auto& resources : m_sessionResources.values()) {
         for (auto& keyValue : *resources) {
             auto& resource = *keyValue.value;
-#if ENABLE(CACHE_PARTITIONING)
             auto& partitionName = keyValue.key.second;
             if (partitionName == originPartition) {
                 resourcesWithOrigin.append(&resource);
                 continue;
             }
-#endif
             RefPtr<SecurityOrigin> resourceOrigin = SecurityOrigin::create(resource.url());
             if (resourceOrigin->equal(&origin))
                 resourcesWithOrigin.append(&resource);
@@ -558,25 +536,19 @@ void MemoryCache::removeResourcesWithOrigins(SessionID sessionID, const HashSet<
     if (!resourceMap)
         return;
 
-#if ENABLE(CACHE_PARTITIONING)
     HashSet<String> originPartitions;
 
     for (auto& origin : origins)
         originPartitions.add(ResourceRequest::partitionName(origin->host()));
-#endif
 
     Vector<CachedResource*> resourcesToRemove;
     for (auto& keyValuePair : *resourceMap) {
         auto& resource = *keyValuePair.value;
-
-#if ENABLE(CACHE_PARTITIONING)
         auto& partitionName = keyValuePair.key.second;
         if (originPartitions.contains(partitionName)) {
             resourcesToRemove.append(&resource);
             continue;
         }
-#endif
-
         if (origins.contains(SecurityOrigin::create(resource.url()).ptr()))
             resourcesToRemove.append(&resource);
     }
@@ -587,19 +559,14 @@ void MemoryCache::removeResourcesWithOrigins(SessionID sessionID, const HashSet<
 
 void MemoryCache::getOriginsWithCache(SecurityOriginSet& origins)
 {
-#if ENABLE(CACHE_PARTITIONING)
-    static NeverDestroyed<String> httpString("http");
-#endif
     for (auto& resources : m_sessionResources.values()) {
         for (auto& keyValue : *resources) {
             auto& resource = *keyValue.value;
-#if ENABLE(CACHE_PARTITIONING)
             auto& partitionName = keyValue.key.second;
             if (!partitionName.isEmpty())
-                origins.add(SecurityOrigin::create(httpString, partitionName, 0));
+                origins.add(SecurityOrigin::create(ASCIILiteral("http"), partitionName, 0));
             else
-#endif
-            origins.add(SecurityOrigin::create(resource.url()));
+                origins.add(SecurityOrigin::create(resource.url()));
         }
     }
 }
@@ -612,13 +579,11 @@ HashSet<RefPtr<SecurityOrigin>> MemoryCache::originsWithCache(SessionID sessionI
     if (it != m_sessionResources.end()) {
         for (auto& keyValue : *it->value) {
             auto& resource = *keyValue.value;
-#if ENABLE(CACHE_PARTITIONING)
             auto& partitionName = keyValue.key.second;
             if (!partitionName.isEmpty())
                 origins.add(SecurityOrigin::create("http", partitionName, 0));
             else
-#endif
-            origins.add(SecurityOrigin::create(resource.url()));
+                origins.add(SecurityOrigin::create(resource.url()));
         }
     }
 
index 1836c2b..c5d97e1 100644 (file)
@@ -168,11 +168,7 @@ public:
     WEBCORE_EXPORT void pruneLiveResourcesToSize(unsigned targetSize, bool shouldDestroyDecodedDataForAllLiveResources = false);
 
 private:
-#if ENABLE(CACHE_PARTITIONING)
     typedef HashMap<std::pair<URL, String /* partitionName */>, CachedResource*> CachedResourceMap;
-#else
-    typedef HashMap<URL, CachedResource*> CachedResourceMap;
-#endif
     typedef ListHashSet<CachedResource*> LRUList;
 
     MemoryCache();
index 63fd8f2..38fa1e9 100644 (file)
@@ -395,7 +395,6 @@ void SecurityOrigin::grantStorageAccessFromFileURLsQuirk()
     m_needsStorageAccessFromFileURLsQuirk = true;
 }
 
-#if ENABLE(CACHE_PARTITIONING)
 String SecurityOrigin::domainForCachePartition() const
 {
     if (m_storageBlockingPolicy != BlockThirdPartyStorage)
@@ -409,7 +408,6 @@ String SecurityOrigin::domainForCachePartition() const
 
     return emptyString();
 }
-#endif
 
 void SecurityOrigin::enforceFilePathSeparation()
 {
index 2fba8cd..e63f4bd 100644 (file)
@@ -138,9 +138,7 @@ public:
     void grantStorageAccessFromFileURLsQuirk();
     bool needsStorageAccessFromFileURLsQuirk() const { return m_needsStorageAccessFromFileURLsQuirk; }
 
-#if ENABLE(CACHE_PARTITIONING)
     WEBCORE_EXPORT String domainForCachePartition() const;
-#endif
 
     bool canAccessDatabase(const SecurityOrigin& topOrigin) const { return canAccessStorage(&topOrigin); };
     bool canAccessSessionStorage(const SecurityOrigin& topOrigin) const { return canAccessStorage(&topOrigin, AlwaysAllowFromThirdParty); }
index ea25db8..5bad3cd 100644 (file)
@@ -167,13 +167,11 @@ static URLSchemesMap& ContentSecurityPolicyBypassingSchemes()
     return schemes;
 }
 
-#if ENABLE(CACHE_PARTITIONING)
 static URLSchemesMap& cachePartitioningSchemes()
 {
     static NeverDestroyed<URLSchemesMap> schemes;
     return schemes;
 }
-#endif
 
 static URLSchemesMap& alwaysRevalidatedSchemes()
 {
@@ -343,7 +341,6 @@ bool SchemeRegistry::shouldAlwaysRevalidateURLScheme(const String& scheme)
     return alwaysRevalidatedSchemes().contains(scheme);
 }
 
-#if ENABLE(CACHE_PARTITIONING)
 void SchemeRegistry::registerURLSchemeAsCachePartitioned(const String& scheme)
 {
     cachePartitioningSchemes().add(scheme);
@@ -355,7 +352,6 @@ bool SchemeRegistry::shouldPartitionCacheForURLScheme(const String& scheme)
         return false;
     return cachePartitioningSchemes().contains(scheme);
 }
-#endif
 
 bool SchemeRegistry::isUserExtensionScheme(const String& scheme)
 {
index 578a49d..cd6f4be 100644 (file)
@@ -94,11 +94,9 @@ public:
     WEBCORE_EXPORT static void registerURLSchemeAsAlwaysRevalidated(const String&);
     static bool shouldAlwaysRevalidateURLScheme(const String&);
 
-#if ENABLE(CACHE_PARTITIONING)
     // Schemes whose requests should be partitioned in the cache
     WEBCORE_EXPORT static void registerURLSchemeAsCachePartitioned(const String& scheme);
     static bool shouldPartitionCacheForURLScheme(const String& scheme);
-#endif
 
     static bool isUserExtensionScheme(const String& scheme);
 };
index 6455819..8e40cf3 100644 (file)
@@ -66,9 +66,7 @@ WEBCORE_EXPORT CFStringRef(*wkCaptionAppearanceGetSettingsChangedNotification)(v
 WEBCORE_EXPORT bool (*wkIsPublicSuffix)(NSString *host);
 #endif
 
-#if ENABLE(CACHE_PARTITIONING)
 WEBCORE_EXPORT CFStringRef (*wkCachePartitionKey)(void);
-#endif
 
 WEBCORE_EXPORT int (*wkExernalDeviceTypeForPlayer)(AVPlayer *);
 WEBCORE_EXPORT NSString *(*wkExernalDeviceDisplayNameForPlayer)(AVPlayer *);
index 3d0ad30..5adf12e 100644 (file)
@@ -235,9 +235,7 @@ extern CGFloat (*wkNSReboundDeltaForElasticDelta)(CGFloat delta);
 extern bool (*wkIsPublicSuffix)(NSString *host);
 #endif
 
-#if ENABLE(CACHE_PARTITIONING)
 extern CFStringRef (*wkCachePartitionKey)(void);
-#endif
 
 typedef enum {
     wkExternalPlaybackTypeNone,
index ff91974..c4b33f4 100644 (file)
@@ -113,9 +113,7 @@ CGFloat (*wkNSReboundDeltaForElasticDelta)(CGFloat delta);
 bool (*wkIsPublicSuffix)(NSString *host);
 #endif
 
-#if ENABLE(CACHE_PARTITIONING)
 CFStringRef (*wkCachePartitionKey)(void);
-#endif
 
 int (*wkExernalDeviceTypeForPlayer)(AVPlayer *);
 NSString *(*wkExernalDeviceDisplayNameForPlayer)(AVPlayer *);
index 331d9b3..d84de90 100644 (file)
@@ -79,11 +79,7 @@ public:
         , m_client(client)
         , m_firstRequest(request)
         , m_lastHTTPMethod(request.httpMethod())
-#if ENABLE(CACHE_PARTITIONING)
         , m_partition(request.cachePartition())
-#else
-        , m_partition(emptyString())
-#endif
         , m_defersLoading(defersLoading)
         , m_shouldContentSniff(shouldContentSniff)
         , m_usesAsyncCallbacks(client && client->usesAsyncCallbacks())
index e48baca..6914671 100644 (file)
@@ -27,6 +27,7 @@
 #include "ResourceRequestBase.h"
 
 #include "HTTPHeaderNames.h"
+#include "PublicSuffix.h"
 #include "ResourceRequest.h"
 #include <wtf/PointerComparison.h>
 
@@ -66,6 +67,7 @@ void ResourceRequestBase::setAsIsolatedCopy(const ResourceRequest& other)
     setPriority(other.priority());
     setRequester(other.requester());
     setInitiatorIdentifier(other.initiatorIdentifier().isolatedCopy());
+    setCachePartition(other.cachePartition());
 
     updateResourceRequest();
     m_httpHeaderFields = other.httpHeaderFields().isolatedCopy();
@@ -86,8 +88,6 @@ void ResourceRequestBase::setAsIsolatedCopy(const ResourceRequest& other)
     if (other.m_httpBody)
         setHTTPBody(other.m_httpBody->isolatedCopy());
     setAllowCookies(other.m_allowCookies);
-
-    const_cast<ResourceRequest&>(asResourceRequest()).doPlatformSetAsIsolatedCopy(other);
 }
 
 bool ResourceRequestBase::isEmpty() const
@@ -640,4 +640,32 @@ bool ResourceRequestBase::defaultAllowCookies()
 }
 #endif
 
+void ResourceRequestBase::setCachePartition(const String& cachePartition)
+{
+#if ENABLE(CACHE_PARTITIONING)
+    ASSERT(!cachePartition.isNull());
+    ASSERT(cachePartition == partitionName(cachePartition));
+    m_cachePartition = cachePartition;
+#else
+    UNUSED_PARAM(cachePartition);
+#endif
+}
+
+String ResourceRequestBase::partitionName(const String& domain)
+{
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+    if (domain.isNull())
+        return emptyString();
+    String highLevel = topPrivatelyControlledDomain(domain);
+    if (highLevel.isNull())
+        return emptyString();
+    return highLevel;
+#else
+#if ENABLE(CACHE_PARTITIONING)
+#error Cache partitioning requires PUBLIC_SUFFIX_LIST
+#endif
+    return emptyString();
+#endif
+}
+
 }
index 711a46a..86415ea 100644 (file)
@@ -136,6 +136,11 @@ public:
     WEBCORE_EXPORT ResourceLoadPriority priority() const;
     WEBCORE_EXPORT void setPriority(ResourceLoadPriority);
 
+    WEBCORE_EXPORT static String partitionName(const String& domain);
+    const String& cachePartition() const { return m_cachePartition; }
+    WEBCORE_EXPORT void setCachePartition(const String&);
+    void setDomainForCachePartition(const String& domain) { setCachePartition(partitionName(domain)); }
+
     WEBCORE_EXPORT bool isConditional() const;
     WEBCORE_EXPORT void makeUnconditional();
 
@@ -237,6 +242,7 @@ protected:
     ResourceLoadPriority m_priority { ResourceLoadPriority::Low };
     Requester m_requester { Requester::Unspecified };
     String m_initiatorIdentifier;
+    String m_cachePartition { emptyString() };
 
 private:
     const ResourceRequest& asResourceRequest() const;
index 563a183..767c0aa 100644 (file)
@@ -137,11 +137,7 @@ void ResourceHandle::createCFURLConnection(bool shouldUseCredentialStorage, bool
         firstRequest().setURL(urlWithCredentials);
     }
 
-#if ENABLE(CACHE_PARTITIONING)
     String partition = firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
 
     // <rdar://problem/7174050> - For URLs that match the paths of those previously challenged for HTTP Basic authentication,
     // try and reuse the credential preemptively, as allowed by RFC 2617.
@@ -306,11 +302,7 @@ ResourceRequest ResourceHandle::willSendRequest(ResourceRequest&& request, Resou
     d->m_lastHTTPMethod = request.httpMethod();
     request.removeCredentials();
 
-#if ENABLE(CACHE_PARTITIONING)
     String partition = firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
 
     if (!protocolHostAndPortAreEqual(request.url(), redirectResponse.url())) {
         // The network layer might carry over some headers from the original request that
@@ -395,11 +387,7 @@ bool ResourceHandle::tryHandlePasswordBasedAuthentication(const AuthenticationCh
     if (!challenge.protectionSpace().isPasswordBased())
         return false;
 
-#if ENABLE(CACHE_PARTITIONING)
     String partition = firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
 
     if (!d->m_user.isNull() && !d->m_pass.isNull()) {
         RetainPtr<CFURLCredentialRef> cfCredential = adoptCF(CFURLCredentialCreate(kCFAllocatorDefault, d->m_user.createCFString().get(), d->m_pass.createCFString().get(), 0, kCFURLCredentialPersistenceNone));
@@ -490,13 +478,7 @@ void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge
         if (challenge.failureResponse().httpStatusCode() == 401)
             urlToStore = challenge.failureResponse().url(); 
 
-#if ENABLE(CACHE_PARTITIONING)
-        String partition = firstRequest().cachePartition();
-#else
-        String partition = emptyString();
-#endif
-
-        d->m_context->storageSession().credentialStorage().set(partition, webCredential, challenge.protectionSpace(), urlToStore);
+        d->m_context->storageSession().credentialStorage().set(firstRequest().cachePartition(), webCredential, challenge.protectionSpace(), urlToStore);
 
         if (d->m_connection) {
 #if PLATFORM(COCOA)
index 2e6f9fe..12f1b66 100644 (file)
@@ -94,17 +94,6 @@ public:
     WEBCORE_EXPORT static CFStringRef isUserInitiatedKey();
 #endif
 
-#if ENABLE(CACHE_PARTITIONING)
-    WEBCORE_EXPORT static String partitionName(const String& domain);
-    const String& cachePartition() const { return m_cachePartition.isNull() ? emptyString() : m_cachePartition; }
-    void setCachePartition(const String& cachePartition)
-    {
-        ASSERT(cachePartition == partitionName(cachePartition));
-        m_cachePartition = cachePartition;
-    }
-    void setDomainForCachePartition(const String& domain) { m_cachePartition = partitionName(domain); }
-#endif
-
 #if PLATFORM(COCOA) || USE(CFURLCONNECTION)
     WEBCORE_EXPORT CFURLRequestRef cfURLRequest(HTTPBodyUpdatePolicy) const;
     void setStorageSession(CFURLStorageSessionRef);
@@ -131,9 +120,6 @@ private:
 #if PLATFORM(COCOA)
     RetainPtr<NSURLRequest> m_nsRequest;
 #endif
-#if ENABLE(CACHE_PARTITIONING)
-    String m_cachePartition;
-#endif
 
     static bool s_httpPipeliningEnabled;
 };
index 258f390..bd87d68 100644 (file)
@@ -361,32 +361,6 @@ void ResourceRequest::setHTTPPipeliningEnabled(bool flag)
     s_httpPipeliningEnabled = flag;
 }
 
-#if ENABLE(CACHE_PARTITIONING)
-String ResourceRequest::partitionName(const String& domain)
-{
-    if (domain.isNull())
-        return emptyString();
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-    String highLevel = topPrivatelyControlledDomain(domain);
-    if (highLevel.isNull())
-        return emptyString();
-    return highLevel;
-#else
-    return domain;
-#endif
-}
-#endif
-
-void ResourceRequest::doPlatformSetAsIsolatedCopy(const ResourceRequest& other)
-{
-#if ENABLE(CACHE_PARTITIONING)
-    m_cachePartition = other.m_cachePartition.isolatedCopy();
-#else
-    UNUSED_PARAM(other);
-#endif
-}
-
-
 // FIXME: It is confusing that this function both sets connection count and determines maximum request count at network layer. This can and should be done separately.
 unsigned initializeMaximumHTTPConnectionCountPerHost()
 {
index 3da41d2..3d934d5 100644 (file)
@@ -103,8 +103,6 @@ private:
     String platformSuggestedFilename() const;
     CertificateInfo platformCertificateInfo() const;
 
-    void doPlatformSetAsIsolatedCopy(const ResourceResponse&) const;
-
 #if PLATFORM(COCOA)
     void initNSURLResponse() const;
 #endif
index d880012..e4fe524 100644 (file)
@@ -148,13 +148,11 @@ void ResourceRequest::doUpdateResourceRequest()
             m_responseContentDispositionEncodingFallbackArray.uncheckedAppend(CFStringConvertEncodingToIANACharSetName(encoding));
     }
 
-#if ENABLE(CACHE_PARTITIONING)
     if (m_nsRequest) {
         NSString* cachePartition = [NSURLProtocol propertyForKey:(NSString *)wkCachePartitionKey() inRequest:m_nsRequest.get()];
         if (cachePartition)
             m_cachePartition = cachePartition;
     }
-#endif
 }
 
 void ResourceRequest::doUpdateResourceHTTPBody()
@@ -218,13 +216,11 @@ void ResourceRequest::doUpdatePlatformRequest()
     }
     [nsRequest setContentDispositionEncodingFallbackArray:encodingFallbacks];
 
-#if ENABLE(CACHE_PARTITIONING)
     String partition = cachePartition();
     if (!partition.isNull() && !partition.isEmpty()) {
         NSString *partitionValue = [NSString stringWithUTF8String:partition.utf8().data()];
         [NSURLProtocol setProperty:partitionValue forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];
     }
-#endif
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
     if (m_url.isLocalFile()) {
index 57a5de4..c254011 100644 (file)
@@ -179,11 +179,7 @@ void ResourceHandle::platformLoadResourceSynchronously(NetworkingContext* contex
 
 void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
 {
-#if ENABLE(CACHE_PARTITIONING)
     String partition = firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
 
     if (!d->m_user.isNull() && !d->m_pass.isNull()) {
         Credential credential(d->m_user, d->m_pass, CredentialPersistenceNone);
@@ -241,11 +237,7 @@ void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge
         return;
     }
 
-#if ENABLE(CACHE_PARTITIONING)
     String partition = firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
 
     if (shouldUseCredentialStorage()) {
         if (challenge.failureResponse().httpStatusCode() == 401) {
index d8df781..5ee2ebb 100644 (file)
@@ -1041,11 +1041,7 @@ void ResourceHandleManager::applyAuthenticationToRequest(ResourceHandle* handle,
     // m_user/m_pass are credentials given manually, for instance, by the arguments passed to XMLHttpRequest.open().
     ResourceHandleInternal* d = handle->getInternal();
 
-#if ENABLE(CACHE_PARTITIONING)
     String partition = handle->firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
 
     if (handle->shouldUseCredentialStorage()) {
         if (d->m_user.isEmpty() && d->m_pass.isEmpty()) {
index 4f83ba3..ada8988 100644 (file)
@@ -151,12 +151,7 @@ void ResourceHandle::createNSURLConnection(id delegate, bool shouldUseCredential
         if (d->m_user.isEmpty() && d->m_pass.isEmpty()) {
             // <rdar://problem/7174050> - For URLs that match the paths of those previously challenged for HTTP Basic authentication, 
             // try and reuse the credential preemptively, as allowed by RFC 2617.
-#if ENABLE(CACHE_PARTITIONING)
-            String partition = firstRequest().cachePartition();
-#else
-            String partition = emptyString();
-#endif
-            d->m_initialCredential = d->m_context->storageSession().credentialStorage().get(partition, firstRequest().url());
+            d->m_initialCredential = d->m_context->storageSession().credentialStorage().get(firstRequest().cachePartition(), firstRequest().url());
         } else {
             // If there is already a protection space known for the URL, update stored credentials before sending a request.
             // This makes it possible to implement logout by sending an XMLHttpRequest with known incorrect credentials, and aborting it immediately
index eb44c24..e76fac8 100644 (file)
@@ -201,11 +201,7 @@ static void applyAuthenticationToRequest(ResourceHandle* handle, ResourceRequest
     // m_user/m_pass are credentials given manually, for instance, by the arguments passed to XMLHttpRequest.open().
     ResourceHandleInternal* d = handle->getInternal();
 
-#if ENABLE(CACHE_PARTITIONING)
-    String partition = firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
+    String partition = request.cachePartition();
 
     if (handle->shouldUseCredentialStorage()) {
         if (d->m_user.isEmpty() && d->m_pass.isEmpty())
@@ -829,11 +825,7 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall
 {
     ASSERT(d->m_currentWebChallenge.isNull());
 
-#if ENABLE(CACHE_PARTITIONING)
     String partition = firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
 
     // FIXME: Per the specification, the user shouldn't be asked for credentials if there were incorrect ones provided explicitly.
     bool useCredentialStorage = shouldUseCredentialStorage();
@@ -899,11 +891,7 @@ void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge
         return;
     }
 
-#if ENABLE(CACHE_PARTITIONING)
     String partition = firstRequest().cachePartition();
-#else
-    String partition = emptyString();
-#endif
 
     if (shouldUseCredentialStorage()) {
         // Eventually we will manage per-session credentials only internally or use some newly-exposed API from libsoup,
index 3eeca69..67fb851 100644 (file)
@@ -563,9 +563,8 @@ bool Internals::isLoadingFromMemoryCache(const String& url)
         return false;
 
     ResourceRequest request(contextDocument()->completeURL(url));
-#if ENABLE(CACHE_PARTITIONING)
     request.setDomainForCachePartition(contextDocument()->topOrigin().domainForCachePartition());
-#endif
+    
     CachedResource* resource = MemoryCache::singleton().resourceForRequest(request, contextDocument()->page()->sessionID());
     return resource && resource->status() == CachedResource::Cached;
 }
index 975ba0f..099ce5a 100644 (file)
@@ -1,3 +1,16 @@
+2017-02-09  Antti Koivisto  <antti@apple.com>
+
+        Remove most cases of #if ENABLE(CACHE_PARTITIONING)
+        https://bugs.webkit.org/show_bug.cgi?id=167990
+
+        Reviewed by Sam Weinig.
+
+        * Misc/WebCache.mm:
+        (+[WebCache addImageToCache:forURL:forFrame:]):
+        (+[WebCache removeImageFromCacheForURL:forFrame:]):
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2017-02-07  Alexey Proskuryakov  <ap@apple.com>
 
         Don't migrate WebKit DOM headers in MigrateHeaders.make
index cd97deb..2f50828 100644 (file)
@@ -34,6 +34,7 @@
 #import <WebCore/ApplicationCacheStorage.h>
 #import <WebCore/CredentialStorage.h>
 #import <WebCore/CrossOriginPreflightResultCache.h>
+#import <WebCore/Document.h>
 #import <WebCore/MemoryCache.h>
 #import <runtime/InitializeThreading.h>
 #import <wtf/MainThread.h>
 #import <WebCore/WebCoreThreadRun.h>
 #endif
 
-#if ENABLE(CACHE_PARTITIONING)
-#import <WebCore/Document.h>
-#endif
-
 @implementation WebCache
 
 + (void)initialize
     if (!image || !url || ![[url absoluteString] length])
         return false;
     WebCore::SecurityOrigin* topOrigin = nullptr;
-#if ENABLE(CACHE_PARTITIONING)
     if (frame)
         topOrigin = &core(frame)->document()->topOrigin();
-#endif
     return WebCore::MemoryCache::singleton().addImageToCache(RetainPtr<CGImageRef>(image), url, topOrigin ? topOrigin->domainForCachePartition() : emptyString());
 }
 
     if (!url)
         return;
     WebCore::SecurityOrigin* topOrigin = nullptr;
-#if ENABLE(CACHE_PARTITIONING)
     if (frame)
         topOrigin = &core(frame)->document()->topOrigin();
-#endif
     WebCore::MemoryCache::singleton().removeImageFromCache(url, topOrigin ? topOrigin->domainForCachePartition() : emptyString());
 }
 
index 2b7f8ed..efe32e0 100644 (file)
@@ -124,9 +124,7 @@ void InitWebCoreSystemInterface(void)
     INIT(IsPublicSuffix);
 #endif
 
-#if ENABLE(CACHE_PARTITIONING)
     INIT(CachePartitionKey);
-#endif
 
     INIT(ExernalDeviceTypeForPlayer);
     INIT(ExernalDeviceDisplayNameForPlayer);
index 87d51d3..a58bef7 100644 (file)
@@ -1,3 +1,38 @@
+2017-02-09  Antti Koivisto  <antti@apple.com>
+
+        Remove most cases of #if ENABLE(CACHE_PARTITIONING)
+        https://bugs.webkit.org/show_bug.cgi?id=167990
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::Cache::makeCacheKey):
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
+        (WebKit::NetworkCache::constructRevalidationRequest):
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<ResourceRequest>::encode):
+        (IPC::ArgumentCoder<ResourceRequest>::decode):
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextRegisterURLSchemeAsCachePartitioned):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::m_hiddenPageThrottlingTimer):
+        (WebKit::WebProcessPool::createNewWebProcess):
+        (WebKit::WebProcessPool::registerURLSchemeAsCachePartitioned):
+        * UIProcess/WebProcessPool.h:
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+        (WebKit::WebProcess::registerURLSchemeAsCachePartitioned):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2017-02-08  Simon Fraser  <simon.fraser@apple.com>
 
         Put names on more UIViews for ease of debugging
index 4ec3151..aeee92d 100644 (file)
@@ -63,11 +63,7 @@ NetworkDataTask::NetworkDataTask(NetworkSession& session, NetworkDataTaskClient&
     : m_failureTimer(*this, &NetworkDataTask::failureTimerFired)
     , m_session(session)
     , m_client(&client)
-#if ENABLE(CACHE_PARTITIONING)
     , m_partition(requestWithCredentials.cachePartition())
-#else
-    , m_partition(emptyString())
-#endif
     , m_storedCredentials(storedCredentials)
     , m_lastHTTPMethod(requestWithCredentials.httpMethod())
     , m_firstRequest(requestWithCredentials)
index 718062a..bab56b3 100644 (file)
@@ -572,17 +572,12 @@ void NetworkResourceLoader::didRetrieveCacheEntry(std::unique_ptr<NetworkCache::
     send(Messages::WebResourceLoader::DidReceiveResponse(entry->response(), needsContinueDidReceiveResponseMessage));
 
     if (entry->sourceStorageRecord().bodyHash && !m_parameters.derivedCachedDataTypesToRetrieve.isEmpty()) {
-#if ENABLE(CACHE_PARTITIONING)
-        String partition = originalRequest().cachePartition();
-#else
-        String partition;
-#endif
         auto bodyHash = *entry->sourceStorageRecord().bodyHash;
         auto* entryPtr = entry.release();
         auto retrieveCount = m_parameters.derivedCachedDataTypesToRetrieve.size();
 
         for (auto& type : m_parameters.derivedCachedDataTypesToRetrieve) {
-            NetworkCache::DataKey key { partition, type, bodyHash };
+            NetworkCache::DataKey key { originalRequest().cachePartition(), type, bodyHash };
             NetworkCache::singleton().retrieveData(key, [loader = makeRef(*this), entryPtr, type, retrieveCount] (const uint8_t* data, size_t size) mutable {
                 loader->m_retrievedDerivedDataCount++;
                 bool retrievedAll = loader->m_retrievedDerivedDataCount == retrieveCount;
index ede21df..ec85c69 100644 (file)
@@ -116,16 +116,10 @@ void Cache::setCapacity(size_t maximumSize)
 
 Key Cache::makeCacheKey(const WebCore::ResourceRequest& request)
 {
-#if ENABLE(CACHE_PARTITIONING)
-    String partition = request.cachePartition();
-#else
-    String partition;
-#endif
-
     // FIXME: This implements minimal Range header disk cache support. We don't parse
     // ranges so only the same exact range request will be served from the cache.
     String range = request.httpHeaderField(WebCore::HTTPHeaderName::Range);
-    return { partition, resourceType(), range, request.url().string(), m_storage->salt() };
+    return { request.cachePartition(), resourceType(), range, request.url().string(), m_storage->salt() };
 }
 
 static bool cachePolicyAllowsExpired(WebCore::ResourceRequestCachePolicy policy)
index fcba7f1..db36bb8 100644 (file)
@@ -89,12 +89,10 @@ static inline ResourceRequest constructRevalidationRequest(const Key& key, const
     ResourceRequest revalidationRequest(key.identifier());
     revalidationRequest.setHTTPHeaderFields(subResourceInfo.requestHeaders());
     revalidationRequest.setFirstPartyForCookies(subResourceInfo.firstPartyForCookies());
-#if ENABLE(CACHE_PARTITIONING)
     if (!key.partition().isEmpty())
         revalidationRequest.setCachePartition(key.partition());
-#endif
     ASSERT_WITH_MESSAGE(key.range().isEmpty(), "range is not supported");
-
+    
     revalidationRequest.makeUnconditional();
     if (entry) {
         String eTag = entry->response().httpHeaderField(HTTPHeaderName::ETag);
index be84c9d..3542e72 100644 (file)
@@ -979,10 +979,7 @@ bool ArgumentCoder<Cursor>::decode(Decoder& decoder, Cursor& cursor)
 
 void ArgumentCoder<ResourceRequest>::encode(Encoder& encoder, const ResourceRequest& resourceRequest)
 {
-#if ENABLE(CACHE_PARTITIONING)
     encoder << resourceRequest.cachePartition();
-#endif
-
     encoder << resourceRequest.hiddenFromInspector();
 
     if (resourceRequest.encodingRequiresPlatformData()) {
@@ -996,12 +993,10 @@ void ArgumentCoder<ResourceRequest>::encode(Encoder& encoder, const ResourceRequ
 
 bool ArgumentCoder<ResourceRequest>::decode(Decoder& decoder, ResourceRequest& resourceRequest)
 {
-#if ENABLE(CACHE_PARTITIONING)
     String cachePartition;
     if (!decoder.decode(cachePartition))
         return false;
     resourceRequest.setCachePartition(cachePartition);
-#endif
 
     bool isHiddenFromInspector;
     if (!decoder.decode(isHiddenFromInspector))
index e1dab40..a7bdfd2 100644 (file)
@@ -91,9 +91,7 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << urlSchemesRegisteredAsDisplayIsolated;
     encoder << urlSchemesRegisteredAsCORSEnabled;
     encoder << urlSchemesRegisteredAsAlwaysRevalidated;
-#if ENABLE(CACHE_PARTITIONING)
     encoder << urlSchemesRegisteredAsCachePartitioned;
-#endif
     encoder.encodeEnum(cacheModel);
     encoder << shouldAlwaysUseComplexTextCodePath;
     encoder << shouldEnableMemoryPressureReliefLogging;
@@ -221,10 +219,8 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat
         return false;
     if (!decoder.decode(parameters.urlSchemesRegisteredAsAlwaysRevalidated))
         return false;
-#if ENABLE(CACHE_PARTITIONING)
     if (!decoder.decode(parameters.urlSchemesRegisteredAsCachePartitioned))
         return false;
-#endif
     if (!decoder.decodeEnum(parameters.cacheModel))
         return false;
     if (!decoder.decode(parameters.shouldAlwaysUseComplexTextCodePath))
index 8b94abb..65ab65b 100644 (file)
@@ -100,9 +100,7 @@ struct WebProcessCreationParameters {
     Vector<String> urlSchemesRegisteredAsDisplayIsolated;
     Vector<String> urlSchemesRegisteredAsCORSEnabled;
     Vector<String> urlSchemesRegisteredAsAlwaysRevalidated;
-#if ENABLE(CACHE_PARTITIONING)
     Vector<String> urlSchemesRegisteredAsCachePartitioned;
-#endif
 
     CacheModel cacheModel;
 
index b774af5..7482de6 100644 (file)
@@ -379,12 +379,7 @@ void WKContextRegisterURLSchemeAsBypassingContentSecurityPolicy(WKContextRef con
 
 void WKContextRegisterURLSchemeAsCachePartitioned(WKContextRef contextRef, WKStringRef urlScheme)
 {
-#if ENABLE(CACHE_PARTITIONING)
     toImpl(contextRef)->registerURLSchemeAsCachePartitioned(toImpl(urlScheme)->string());
-#else
-    UNUSED_PARAM(contextRef);
-    UNUSED_PARAM(urlScheme);
-#endif
 }
 
 void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef, WKStringRef urlScheme)
index 02089c8..074b831 100644 (file)
@@ -187,10 +187,8 @@ WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration)
     for (auto& scheme : m_configuration->alwaysRevalidatedURLSchemes())
         m_schemesToRegisterAsAlwaysRevalidated.add(scheme);
 
-#if ENABLE(CACHE_PARTITIONING)
     for (const auto& urlScheme : m_configuration->cachePartitionedURLSchemes())
         m_schemesToRegisterAsCachePartitioned.add(urlScheme);
-#endif
 
     platformInitialize();
 
@@ -596,9 +594,7 @@ WebProcessProxy& WebProcessPool::createNewWebProcess()
     copyToVector(m_schemesToRegisterAsDisplayIsolated, parameters.urlSchemesRegisteredAsDisplayIsolated);
     copyToVector(m_schemesToRegisterAsCORSEnabled, parameters.urlSchemesRegisteredAsCORSEnabled);
     copyToVector(m_schemesToRegisterAsAlwaysRevalidated, parameters.urlSchemesRegisteredAsAlwaysRevalidated);
-#if ENABLE(CACHE_PARTITIONING)
     copyToVector(m_schemesToRegisterAsCachePartitioned, parameters.urlSchemesRegisteredAsCachePartitioned);
-#endif
 
     parameters.shouldAlwaysUseComplexTextCodePath = m_alwaysUsesComplexTextCodePath;
     parameters.shouldUseFontSmoothing = m_shouldUseFontSmoothing;
@@ -1004,13 +1000,11 @@ void WebProcessPool::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(con
         processPool->unregisterSchemeForCustomProtocol(urlScheme);
 }
 
-#if ENABLE(CACHE_PARTITIONING)
 void WebProcessPool::registerURLSchemeAsCachePartitioned(const String& urlScheme)
 {
     m_schemesToRegisterAsCachePartitioned.add(urlScheme);
     sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsCachePartitioned(urlScheme));
 }
-#endif
 
 void WebProcessPool::setCacheModel(CacheModel cacheModel)
 {
index ae56ffe..b793498 100644 (file)
@@ -210,9 +210,7 @@ public:
     void registerURLSchemeAsNoAccess(const String&);
     void registerURLSchemeAsDisplayIsolated(const String&);
     void registerURLSchemeAsCORSEnabled(const String&);
-#if ENABLE(CACHE_PARTITIONING)
     void registerURLSchemeAsCachePartitioned(const String&);
-#endif
 
     VisitedLinkStore& visitedLinkStore() { return m_visitedLinkStore.get(); }
 
@@ -499,9 +497,7 @@ private:
     HashSet<String> m_schemesToRegisterAsDisplayIsolated;
     HashSet<String> m_schemesToRegisterAsCORSEnabled;
     HashSet<String> m_schemesToRegisterAsAlwaysRevalidated;
-#if ENABLE(CACHE_PARTITIONING)
     HashSet<String> m_schemesToRegisterAsCachePartitioned;
-#endif
 
     bool m_alwaysUsesComplexTextCodePath;
     bool m_shouldUseFontSmoothing;
index 93cb2eb..e5603be 100644 (file)
@@ -1589,11 +1589,7 @@ void PluginView::setCookiesForURL(const String& urlString, const String& cookieS
 
 bool PluginView::getAuthenticationInfo(const ProtectionSpace& protectionSpace, String& username, String& password)
 {
-#if ENABLE(CACHE_PARTITIONING)
     String partitionName = m_pluginElement->contentDocument()->topDocument().securityOrigin().domainForCachePartition();
-#else
-    String partitionName = emptyString();
-#endif
     Credential credential = CredentialStorage::defaultCredentialStorage().get(partitionName, protectionSpace);
     if (credential.isEmpty())
         credential = CredentialStorage::defaultCredentialStorage().getFromPersistentStorage(protectionSpace);
index 5dcb000..e25127c 100644 (file)
@@ -111,9 +111,7 @@ void InitWebCoreSystemInterface(void)
         INIT(IsPublicSuffix);
 #endif
 
-#if ENABLE(CACHE_PARTITIONING)
         INIT(CachePartitionKey);
-#endif
 
         INIT(ExernalDeviceTypeForPlayer);
         INIT(ExernalDeviceDisplayNameForPlayer);
index 1379b7f..e6a33ca 100644 (file)
@@ -337,10 +337,8 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
     for (auto& scheme : parameters.urlSchemesRegisteredAsAlwaysRevalidated)
         registerURLSchemeAsAlwaysRevalidated(scheme);
 
-#if ENABLE(CACHE_PARTITIONING)
     for (auto& scheme : parameters.urlSchemesRegisteredAsCachePartitioned)
         registerURLSchemeAsCachePartitioned(scheme);
-#endif
 
     setDefaultRequestTimeoutInterval(parameters.defaultRequestTimeoutInterval);
 
@@ -462,12 +460,10 @@ void WebProcess::registerURLSchemeAsAlwaysRevalidated(const String& urlScheme) c
     SchemeRegistry::registerURLSchemeAsAlwaysRevalidated(urlScheme);
 }
 
-#if ENABLE(CACHE_PARTITIONING)
 void WebProcess::registerURLSchemeAsCachePartitioned(const String& urlScheme) const
 {
     SchemeRegistry::registerURLSchemeAsCachePartitioned(urlScheme);
 }
-#endif
 
 void WebProcess::setDefaultRequestTimeoutInterval(double timeoutInterval)
 {
index 701d0c2..9f87593 100644 (file)
@@ -257,9 +257,7 @@ private:
     void registerURLSchemeAsDisplayIsolated(const String&) const;
     void registerURLSchemeAsCORSEnabled(const String&) const;
     void registerURLSchemeAsAlwaysRevalidated(const String&) const;
-#if ENABLE(CACHE_PARTITIONING)
     void registerURLSchemeAsCachePartitioned(const String&) const;
-#endif
     void setDefaultRequestTimeoutInterval(double);
     void setAlwaysUsesComplexTextCodePath(bool);
     void setShouldUseFontSmoothing(bool);
index aa617ef..d4041b1 100644 (file)
@@ -36,9 +36,7 @@ messages -> WebProcess LegacyReceiver {
     RegisterURLSchemeAsNoAccess(String scheme)
     RegisterURLSchemeAsDisplayIsolated(String scheme)
     RegisterURLSchemeAsCORSEnabled(String scheme)
-#if ENABLE(CACHE_PARTITIONING)
     RegisterURLSchemeAsCachePartitioned(String scheme)
-#endif
     SetDefaultRequestTimeoutInterval(double timeoutInterval)
     SetAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText)
     SetShouldUseFontSmoothing(bool useFontSmoothing)