Stop using NetworkStorageSession::storageSession in WebCore
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2019 19:10:53 +0000 (19:10 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2019 19:10:53 +0000 (19:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193529

Reviewed by Tim Horton.

Source/WebCore:

Ownership of the map that NetworkStorageSession::storageSession searches needs to move to the WebKit/WebKitLegacy layer,
so when WebCore used to look in this map it needs to call a client function to ask the layer above it for the storage object.
I've called this client StorageSessionProvider::storageSession.  Right now it just looks in NetworkStorageSession::storageSession,
but this added abstraction makes it possible to move the currently process-global map to be a member of the NetworkProcess object.

* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::connect):
* WebCore.xcodeproj/project.pbxproj:
* loader/CookieJar.cpp:
(WebCore::CookieJar::create):
(WebCore::CookieJar::CookieJar):
(WebCore::CookieJar::cookies const):
(WebCore::CookieJar::setCookies):
(WebCore::CookieJar::cookiesEnabled const):
(WebCore::CookieJar::cookieRequestHeaderFieldValue const):
(WebCore::CookieJar::getRawCookies const):
(WebCore::CookieJar::deleteCookie):
* loader/CookieJar.h:
* loader/EmptyClients.cpp:
(WebCore::pageConfigurationWithEmptyClients):
* page/Page.h:
* page/SocketProvider.cpp:
(WebCore::SocketProvider::createSocketStreamHandle):
* page/SocketProvider.h:
* platform/network/NetworkingContext.h:
* platform/network/SocketStreamHandleImpl.cpp:
(WebCore::cookieDataForHandshake):
(WebCore::SocketStreamHandleImpl::platformSendHandshake):
* platform/network/StorageSessionProvider.h: Added.
(WebCore::StorageSessionProvider::~StorageSessionProvider):
* platform/network/cf/SocketStreamHandleImpl.h:
(WebCore::SocketStreamHandleImpl::create):
* platform/network/cf/SocketStreamHandleImplCFNet.cpp:
(WebCore::SocketStreamHandleImpl::SocketStreamHandleImpl):
(WebCore::SocketStreamHandleImpl::getStoredCONNECTProxyCredentials):
* platform/network/curl/SocketStreamHandleImpl.h:
(WebCore::SocketStreamHandleImpl::create):
* platform/network/soup/SocketStreamHandleImpl.h:
* platform/network/soup/SocketStreamHandleImplSoup.cpp:
(WebCore::SocketStreamHandleImpl::create):

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::createSocketStream):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkSocketStream.cpp:
(WebKit::NetworkSocketStream::create):
(WebKit::NetworkSocketStream::NetworkSocketStream):
* NetworkProcess/NetworkSocketStream.h:
* NetworkProcess/NetworkStorageSessionProvider.h: Added.
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/Network/WebSocketProvider.cpp:
(WebKit::WebSocketProvider::createSocketStreamHandle):
* WebProcess/Network/WebSocketProvider.h:
* WebProcess/WebPage/WebCookieJar.cpp:
(WebKit::WebCookieJar::WebCookieJar):
* WebProcess/WebPage/WebCookieJar.h:

Source/WebKitLegacy:

* WebCoreSupport/PageStorageSessionProvider.h: Added.
* WebKitLegacy.xcodeproj/project.pbxproj:

Source/WebKitLegacy/mac:

* Misc/WebCache.mm:
(+[WebCache addImageToCache:forURL:forFrame:]):
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):

Source/WebKitLegacy/win:

* WebView.cpp:
(WebView::initWithFrame):

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

36 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/WebSocketChannel.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/CookieJar.cpp
Source/WebCore/loader/CookieJar.h
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/SocketProvider.cpp
Source/WebCore/page/SocketProvider.h
Source/WebCore/platform/network/NetworkingContext.h
Source/WebCore/platform/network/SocketStreamHandleImpl.cpp
Source/WebCore/platform/network/StorageSessionProvider.h [new file with mode: 0644]
Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h
Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp
Source/WebCore/platform/network/curl/SocketStreamHandleImpl.h
Source/WebCore/platform/network/curl/SocketStreamHandleImplCurl.cpp
Source/WebCore/platform/network/soup/SocketStreamHandleImpl.h
Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkSocketStream.cpp
Source/WebKit/NetworkProcess/NetworkSocketStream.h
Source/WebKit/NetworkProcess/NetworkStorageSessionProvider.h [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/Network/WebSocketProvider.cpp
Source/WebKit/WebProcess/Network/WebSocketProvider.h
Source/WebKit/WebProcess/WebPage/WebCookieJar.cpp
Source/WebKit/WebProcess/WebPage/WebCookieJar.h
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/WebCoreSupport/PageStorageSessionProvider.h [new file with mode: 0644]
Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Misc/WebCache.mm
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebView.cpp

index b58a862..3e5ac12 100644 (file)
@@ -1,3 +1,51 @@
+2019-01-17  Alex Christensen  <achristensen@webkit.org>
+
+        Stop using NetworkStorageSession::storageSession in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=193529
+
+        Reviewed by Tim Horton.
+
+        Ownership of the map that NetworkStorageSession::storageSession searches needs to move to the WebKit/WebKitLegacy layer,
+        so when WebCore used to look in this map it needs to call a client function to ask the layer above it for the storage object.
+        I've called this client StorageSessionProvider::storageSession.  Right now it just looks in NetworkStorageSession::storageSession,
+        but this added abstraction makes it possible to move the currently process-global map to be a member of the NetworkProcess object.
+
+        * Modules/websockets/WebSocketChannel.cpp:
+        (WebCore::WebSocketChannel::connect):
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/CookieJar.cpp:
+        (WebCore::CookieJar::create):
+        (WebCore::CookieJar::CookieJar):
+        (WebCore::CookieJar::cookies const):
+        (WebCore::CookieJar::setCookies):
+        (WebCore::CookieJar::cookiesEnabled const):
+        (WebCore::CookieJar::cookieRequestHeaderFieldValue const):
+        (WebCore::CookieJar::getRawCookies const):
+        (WebCore::CookieJar::deleteCookie):
+        * loader/CookieJar.h:
+        * loader/EmptyClients.cpp:
+        (WebCore::pageConfigurationWithEmptyClients):
+        * page/Page.h:
+        * page/SocketProvider.cpp:
+        (WebCore::SocketProvider::createSocketStreamHandle):
+        * page/SocketProvider.h:
+        * platform/network/NetworkingContext.h:
+        * platform/network/SocketStreamHandleImpl.cpp:
+        (WebCore::cookieDataForHandshake):
+        (WebCore::SocketStreamHandleImpl::platformSendHandshake):
+        * platform/network/StorageSessionProvider.h: Added.
+        (WebCore::StorageSessionProvider::~StorageSessionProvider):
+        * platform/network/cf/SocketStreamHandleImpl.h:
+        (WebCore::SocketStreamHandleImpl::create):
+        * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
+        (WebCore::SocketStreamHandleImpl::SocketStreamHandleImpl):
+        (WebCore::SocketStreamHandleImpl::getStoredCONNECTProxyCredentials):
+        * platform/network/curl/SocketStreamHandleImpl.h:
+        (WebCore::SocketStreamHandleImpl::create):
+        * platform/network/soup/SocketStreamHandleImpl.h:
+        * platform/network/soup/SocketStreamHandleImplSoup.cpp:
+        (WebCore::SocketStreamHandleImpl::create):
+
 2019-01-17  Jon Lee  <jonlee@apple.com>
 
         [EME] Remove Amazon Prime Video from quirks list
index a048db8..4ea3b12 100644 (file)
@@ -40,6 +40,7 @@
 #include "Frame.h"
 #include "InspectorInstrumentation.h"
 #include "Logging.h"
+#include "NetworkingContext.h"
 #include "Page.h"
 #include "ProgressTracker.h"
 #include "ResourceRequest.h"
@@ -123,7 +124,7 @@ void WebSocketChannel::connect(const URL& requestedURL, const String& protocol)
         Page* page = frame->page();
         PAL::SessionID sessionID = page ? page->sessionID() : PAL::SessionID::defaultSessionID();
         String partition = m_document->domainForCachePartition();
-        m_handle = m_socketProvider->createSocketStreamHandle(m_handshake->url(), *this, sessionID, partition);
+        m_handle = m_socketProvider->createSocketStreamHandle(m_handshake->url(), *this, sessionID, partition, frame->loader().networkingContext());
     }
 }
 
index 4d2bccc..5ea09b0 100644 (file)
                5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; };
                5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304B4191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h */; };
                5C7C88D81D0F1F4A009D2F6D /* SocketProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C88D71D0F1F2B009D2F6D /* SocketProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5C9EF2F321F06190003BDC56 /* StorageSessionProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9EF2F221F06171003BDC56 /* StorageSessionProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5CA1DEC61F71F1C700E71BD3 /* HTTPHeaderField.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CA1DEC41F71E68700E71BD3 /* HTTPHeaderField.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5CB37FFF1C62D2A100F20188 /* ScrollAnimatorMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB37FFD1C62D27800F20188 /* ScrollAnimatorMock.h */; };
                5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC8DAB1AAA302200E1C803 /* MediaAccessibilitySoftLink.h */; };
                5C9B860B1C21E3C600110F36 /* NetworkLoadMetrics.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkLoadMetrics.mm; sourceTree = "<group>"; };
                5C9EF16F1DFF719900A452E3 /* XPathGrammar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathGrammar.cpp; sourceTree = "<group>"; };
                5C9EF1701DFF719900A452E3 /* XPathGrammar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathGrammar.h; sourceTree = "<group>"; };
+               5C9EF2F221F06171003BDC56 /* StorageSessionProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageSessionProvider.h; sourceTree = "<group>"; };
                5CA1DEC21F71E68600E71BD3 /* HTTPHeaderField.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPHeaderField.cpp; sourceTree = "<group>"; };
                5CA1DEC41F71E68700E71BD3 /* HTTPHeaderField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPHeaderField.h; sourceTree = "<group>"; };
                5CB37FFC1C62D27800F20188 /* ScrollAnimatorMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollAnimatorMock.cpp; sourceTree = "<group>"; };
                                510D4A31103165EE0049EA54 /* SocketStreamHandle.h */,
                                510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */,
                                5C668E641E7C6C3500D32B3B /* SocketStreamHandleImpl.cpp */,
+                               5C9EF2F221F06171003BDC56 /* StorageSessionProvider.h */,
                                4682D1FF1F79782300C863DB /* StoredCredentialsPolicy.h */,
                                E180811016FCF42E00B80D07 /* SynchronousLoaderClient.cpp */,
                                E180811516FCF9CB00B80D07 /* SynchronousLoaderClient.h */,
                                51E0BB380DA5ACB600A9E417 /* StorageMap.h in Headers */,
                                C50D0E830FF4272900AC2644 /* StorageNamespace.h in Headers */,
                                1A37636C1A2E68BB009A7EE2 /* StorageNamespaceProvider.h in Headers */,
+                               5C9EF2F321F06190003BDC56 /* StorageSessionProvider.h in Headers */,
                                5166D3CD1E8ED48F00AD62E3 /* StorageType.h in Headers */,
                                4682D2001F79783000C863DB /* StoredCredentialsPolicy.h in Headers */,
                                416E6FE81BBD12DF000A6033 /* StreamInternalsBuiltins.h in Headers */,
index ed0c780..b1bed8f 100644 (file)
 #include "NetworkingContext.h"
 #include "PlatformStrategies.h"
 #include "SameSiteInfo.h"
+#include "StorageSessionProvider.h"
 #include <wtf/SystemTracing.h>
 
 namespace WebCore {
 
+Ref<CookieJar> CookieJar::create(Ref<StorageSessionProvider>&& storageSessionProvider)
+{
+    return adoptRef(*new CookieJar(WTFMove(storageSessionProvider)));
+}
+
 IncludeSecureCookies CookieJar::shouldIncludeSecureCookies(const Document& document, const URL& url)
 {
     return (url.protocolIs("https") && !document.foundMixedContent().contains(SecurityContext::MixedContentType::Active)) ? IncludeSecureCookies::Yes : IncludeSecureCookies::No;
@@ -52,9 +58,9 @@ SameSiteInfo CookieJar::sameSiteInfo(const Document& document)
     return { };
 }
 
-Ref<CookieJar> CookieJar::create()
+CookieJar::CookieJar(Ref<StorageSessionProvider>&& storageSessionProvider)
+    : m_storageSessionProvider(WTFMove(storageSessionProvider))
 {
-    return adoptRef(*new CookieJar);
 }
 
 CookieJar::~CookieJar() = default;
@@ -73,7 +79,7 @@ String CookieJar::cookies(Document& document, const URL& url) const
     }
 
     std::pair<String, bool> result;
-    if (auto* session = NetworkStorageSession::storageSession(document.sessionID()))
+    if (auto* session = m_storageSessionProvider->storageSession())
         result = session->cookiesForDOM(document.firstPartyForCookies(), sameSiteInfo(document), url, frameID, pageID, includeSecureCookies);
     else
         ASSERT_NOT_REACHED();
@@ -110,24 +116,24 @@ void CookieJar::setCookies(Document& document, const URL& url, const String& coo
         pageID = frame->loader().client().pageID();
     }
 
-    if (auto* session = NetworkStorageSession::storageSession(document.sessionID()))
+    if (auto* session = m_storageSessionProvider->storageSession())
         session->setCookiesFromDOM(document.firstPartyForCookies(), sameSiteInfo(document), url, frameID, pageID, cookieString);
     else
         ASSERT_NOT_REACHED();
 }
 
-bool CookieJar::cookiesEnabled(const Document& document) const
+bool CookieJar::cookiesEnabled(const Document&) const
 {
-    if (auto* session = NetworkStorageSession::storageSession(document.sessionID()))
+    if (auto* session = m_storageSessionProvider->storageSession())
         return session->cookiesEnabled();
 
     ASSERT_NOT_REACHED();
     return false;
 }
 
-std::pair<String, SecureCookiesAccessed> CookieJar::cookieRequestHeaderFieldValue(const PAL::SessionID& sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<uint64_t> frameID, Optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const
+std::pair<String, SecureCookiesAccessed> CookieJar::cookieRequestHeaderFieldValue(const PAL::SessionID&, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<uint64_t> frameID, Optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const
 {
-    if (auto* session = NetworkStorageSession::storageSession(sessionID)) {
+    if (auto* session = m_storageSessionProvider->storageSession()) {
         std::pair<String, bool> result = session->cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies);
         return { result.first, result.second ? SecureCookiesAccessed::Yes : SecureCookiesAccessed::No };
     }
@@ -160,16 +166,16 @@ bool CookieJar::getRawCookies(const Document& document, const URL& url, Vector<C
         pageID = frame->loader().client().pageID();
     }
 
-    if (auto* session = NetworkStorageSession::storageSession(document.sessionID()))
+    if (auto* session = m_storageSessionProvider->storageSession())
         return session->getRawCookies(document.firstPartyForCookies(), sameSiteInfo(document), url, frameID, pageID, cookies);
 
     ASSERT_NOT_REACHED();
     return false;
 }
 
-void CookieJar::deleteCookie(const Document& document, const URL& url, const String& cookieName)
+void CookieJar::deleteCookie(const Document&, const URL& url, const String& cookieName)
 {
-    if (auto* session = NetworkStorageSession::storageSession(document.sessionID()))
+    if (auto* session = m_storageSessionProvider->storageSession())
         session->deleteCookie(url, cookieName);
     else
         ASSERT_NOT_REACHED();
index 07c6954..d4b50e9 100644 (file)
@@ -40,11 +40,13 @@ enum class SecureCookiesAccessed : bool { No, Yes };
 class Document;
 struct Cookie;
 struct CookieRequestHeaderFieldProxy;
+class NetworkStorageSession;
+class StorageSessionProvider;
 struct SameSiteInfo;
 
 class WEBCORE_EXPORT CookieJar : public RefCounted<CookieJar> {
 public:
-    static Ref<CookieJar> create();
+    static Ref<CookieJar> create(Ref<StorageSessionProvider>&&);
     
     static CookieRequestHeaderFieldProxy cookieRequestHeaderFieldProxy(const Document&, const URL&);
 
@@ -63,6 +65,10 @@ public:
 protected:
     static SameSiteInfo sameSiteInfo(const Document&);
     static IncludeSecureCookies shouldIncludeSecureCookies(const Document&, const URL&);
+    CookieJar(Ref<StorageSessionProvider>&&);
+
+private:
+    Ref<StorageSessionProvider> m_storageSessionProvider;
 };
 
 } // namespace WebCore
index b5b83aa..a5e5ef7 100644 (file)
@@ -535,6 +535,10 @@ Ref<StorageNamespace> EmptyStorageNamespaceProvider::createTransientLocalStorage
     return adoptRef(*new EmptyStorageNamespace);
 }
 
+class EmptyStorageSessionProvider : public StorageSessionProvider {
+    NetworkStorageSession* storageSession() const final { return nullptr; }
+};
+
 PageConfiguration pageConfigurationWithEmptyClients()
 {
     PageConfiguration pageConfiguration {
@@ -543,7 +547,7 @@ PageConfiguration pageConfigurationWithEmptyClients()
         LibWebRTCProvider::create(),
         CacheStorageProvider::create(),
         adoptRef(*new EmptyBackForwardClient),
-        CookieJar::create()
+        CookieJar::create(adoptRef(*new EmptyStorageSessionProvider))
     };
 
     static NeverDestroyed<EmptyChromeClient> dummyChromeClient;
index 522be98..b6df80a 100644 (file)
@@ -47,6 +47,7 @@
 #include <wtf/Noncopyable.h>
 #include <wtf/Ref.h>
 #include <wtf/UniqueRef.h>
+#include <wtf/WeakPtr.h>
 #include <wtf/text/WTFString.h>
 
 #if PLATFORM(COCOA)
@@ -166,7 +167,7 @@ enum class DidWrap : bool;
 enum class RouteSharingPolicy : uint8_t;
 enum class ShouldTreatAsContinuingLoad : bool;
 
-class Page : public Supplementable<Page> {
+class Page : public Supplementable<Page>, public CanMakeWeakPtr<Page> {
     WTF_MAKE_NONCOPYABLE(Page);
     WTF_MAKE_FAST_ALLOCATED;
     friend class SettingsBase;
index 078c27d..46af7f4 100644 (file)
@@ -30,9 +30,9 @@
 
 namespace WebCore {
     
-Ref<SocketStreamHandle> SocketProvider::createSocketStreamHandle(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition)
+Ref<SocketStreamHandle> SocketProvider::createSocketStreamHandle(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, const StorageSessionProvider* provider)
 {
-    return SocketStreamHandleImpl::create(url, client, sessionID, credentialPartition, { });
+    return SocketStreamHandleImpl::create(url, client, sessionID, credentialPartition, { }, provider);
 }
     
 }
index 9e8c003..e016b4d 100644 (file)
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+class StorageSessionProvider;
 class ScriptExecutionContext;
 class SocketStreamHandle;
 class SocketStreamHandleClient;
@@ -38,7 +39,7 @@ class SocketStreamHandleClient;
 class WEBCORE_EXPORT SocketProvider : public ThreadSafeRefCounted<SocketProvider> {
 public:
     static Ref<SocketProvider> create() { return adoptRef(*new SocketProvider); }
-    virtual Ref<SocketStreamHandle> createSocketStreamHandle(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition);
+    virtual Ref<SocketStreamHandle> createSocketStreamHandle(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition, const StorageSessionProvider*);
     virtual ~SocketProvider() { };
 };
 
index 6b7bd75..33a2174 100644 (file)
@@ -19,7 +19,7 @@
 
 #pragma once
 
-#include <wtf/RefCounted.h>
+#include "StorageSessionProvider.h"
 #include <wtf/RetainPtr.h>
 #include <wtf/text/WTFString.h>
 
@@ -41,7 +41,7 @@ class NetworkStorageSession;
 class ResourceError;
 class ResourceRequest;
 
-class NetworkingContext : public RefCounted<NetworkingContext> {
+class NetworkingContext : public StorageSessionProvider {
 public:
     virtual ~NetworkingContext() = default;
 
@@ -58,8 +58,6 @@ public:
 
     virtual String sourceApplicationIdentifier() const { return emptyString(); }
 
-    virtual NetworkStorageSession* storageSession() const = 0;
-
 #if PLATFORM(WIN)
     virtual ResourceError blockedError(const ResourceRequest&) const = 0;
 #endif
index a4a604c..b4a9ce7 100644 (file)
@@ -29,6 +29,7 @@
 #include "CookieRequestHeaderFieldProxy.h"
 #include "NetworkStorageSession.h"
 #include "SocketStreamHandleClient.h"
+#include "StorageSessionProvider.h"
 #include <wtf/Function.h>
 
 namespace WebCore {
@@ -76,9 +77,8 @@ static size_t removeTerminationCharacters(const uint8_t* data, size_t dataLength
     return dataLength - 2;
 }
 
-static Optional<std::pair<Vector<uint8_t>, bool>> cookieDataForHandshake(const CookieRequestHeaderFieldProxy& headerFieldProxy)
+static Optional<std::pair<Vector<uint8_t>, bool>> cookieDataForHandshake(const NetworkStorageSession* networkStorageSession, const CookieRequestHeaderFieldProxy& headerFieldProxy)
 {
-    auto networkStorageSession = NetworkStorageSession::storageSession(headerFieldProxy.sessionID);
     if (!networkStorageSession)
         return WTF::nullopt;
     
@@ -103,7 +103,7 @@ void SocketStreamHandleImpl::platformSendHandshake(const uint8_t* data, size_t l
     bool secureCookiesAccessed = false;
 
     if (headerFieldProxy) {
-        auto cookieDataFromNetworkSession = cookieDataForHandshake(headerFieldProxy.value());
+        auto cookieDataFromNetworkSession = cookieDataForHandshake(m_storageSessionProvider ? m_storageSessionProvider->storageSession() : nullptr, *headerFieldProxy);
         if (!cookieDataFromNetworkSession) {
             completionHandler(false, false);
             return;
diff --git a/Source/WebCore/platform/network/StorageSessionProvider.h b/Source/WebCore/platform/network/StorageSessionProvider.h
new file mode 100644 (file)
index 0000000..0c1555b
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 Apple, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/ThreadSafeRefCounted.h>
+
+namespace PAL {
+class SessionID;
+}
+
+namespace WebCore {
+
+class NetworkStorageSession;
+
+class StorageSessionProvider : public ThreadSafeRefCounted<StorageSessionProvider> {
+public:
+    virtual NetworkStorageSession* storageSession() const = 0;
+
+    virtual ~StorageSessionProvider() { }
+};
+
+} // namespace WebCore
index 94fe06f..77dadcc 100644 (file)
@@ -41,12 +41,13 @@ typedef struct __CFHTTPMessage* CFHTTPMessageRef;
 namespace WebCore {
 
 class Credential;
+class StorageSessionProvider;
 class ProtectionSpace;
 class SocketStreamHandleClient;
 
 class SocketStreamHandleImpl : public SocketStreamHandle {
 public:
-    static Ref<SocketStreamHandleImpl> create(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData) { return adoptRef(*new SocketStreamHandleImpl(url, client, sessionID, credentialPartition, WTFMove(auditData))); }
+    static Ref<SocketStreamHandleImpl> create(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData, const StorageSessionProvider* provider) { return adoptRef(*new SocketStreamHandleImpl(url, client, sessionID, credentialPartition, WTFMove(auditData), provider)); }
 
     virtual ~SocketStreamHandleImpl();
 
@@ -58,7 +59,7 @@ private:
     Optional<size_t> platformSendInternal(const uint8_t*, size_t);
     bool sendPendingData();
 
-    WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition, SourceApplicationAuditToken&&);
+    WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition, SourceApplicationAuditToken&&, const StorageSessionProvider*);
     void createStreams();
     void scheduleStreams();
     void chooseProxy();
@@ -103,6 +104,7 @@ private:
     PAL::SessionID m_sessionID;
     String m_credentialPartition;
     SourceApplicationAuditToken m_auditData;
+    RefPtr<const StorageSessionProvider> m_storageSessionProvider;
 
     StreamBuffer<uint8_t, 1024 * 1024> m_buffer;
     static const unsigned maxBufferSize = 100 * 1024 * 1024;
index 85ff3eb..78732e1 100644 (file)
@@ -40,6 +40,7 @@
 #include "ProtectionSpace.h"
 #include "SocketStreamError.h"
 #include "SocketStreamHandleClient.h"
+#include "StorageSessionProvider.h"
 #include <CFNetwork/CFNetwork.h>
 #include <wtf/Condition.h>
 #include <wtf/Lock.h>
@@ -95,7 +96,7 @@ static inline auto callbacksRunLoopMode()
 #endif
 }
 
-SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData)
+SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData, const StorageSessionProvider* provider)
     : SocketStreamHandle(url, client)
     , m_connectingSubstate(New)
     , m_connectionType(Unknown)
@@ -103,6 +104,7 @@ SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandl
     , m_sessionID(sessionID)
     , m_credentialPartition(credentialPartition)
     , m_auditData(WTFMove(auditData))
+    , m_storageSessionProvider(provider)
 {
     LOG(Network, "SocketStreamHandle %p new client %p", this, &m_client);
 
@@ -367,7 +369,7 @@ bool SocketStreamHandleImpl::getStoredCONNECTProxyCredentials(const ProtectionSp
 
     // Try system credential storage first, matching HTTP behavior (CFNetwork only asks the client for password if it couldn't find it in Keychain).
     Credential storedCredential;
-    if (auto* storageSession = NetworkStorageSession::storageSession(m_sessionID)) {
+    if (auto* storageSession = m_storageSessionProvider ? m_storageSessionProvider->storageSession() : nullptr) {
         storedCredential = storageSession->credentialStorage().getFromPersistentStorage(protectionSpace);
         if (storedCredential.isEmpty())
             storedCredential = storageSession->credentialStorage().get(m_credentialPartition, protectionSpace);
index 24e5e1c..b32c56a 100644 (file)
 namespace WebCore {
 
 class SocketStreamHandleClient;
+class StorageSessionProvider;
 
 class SocketStreamHandleImpl : public SocketStreamHandle {
 public:
-    static Ref<SocketStreamHandleImpl> create(const URL& url, SocketStreamHandleClient& client, PAL::SessionID, const String&, SourceApplicationAuditToken&&) { return adoptRef(*new SocketStreamHandleImpl(url, client)); }
+    static Ref<SocketStreamHandleImpl> create(const URL& url, SocketStreamHandleClient& client, PAL::SessionID, const String&, SourceApplicationAuditToken&&, const StorageSessionProvider* provider) { return adoptRef(*new SocketStreamHandleImpl(url, client, provider)); }
 
     virtual ~SocketStreamHandleImpl();
 
@@ -56,7 +57,7 @@ public:
     WEBCORE_EXPORT void platformClose() final;
 
 private:
-    WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&);
+    WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&, const StorageSessionProvider*);
 
     size_t bufferedAmount() final;
     Optional<size_t> platformSendInternal(const uint8_t*, size_t);
@@ -69,6 +70,7 @@ private:
     static const size_t kWriteBufferSize = 4 * 1024;
     static const size_t kReadBufferSize = 4 * 1024;
 
+    RefPtr<const StorageSessionProvider> m_storageSessionProvider;
     RefPtr<Thread> m_workerThread;
     std::atomic<bool> m_running { true };
 
index 5bda1cf..9b9a74c 100644 (file)
@@ -46,8 +46,9 @@
 
 namespace WebCore {
 
-SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client)
+SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client, const StorageSessionProvider* provider)
     : SocketStreamHandle(url, client)
+    , m_storageSessionProvider(provider)
 {
     LOG(Network, "SocketStreamHandle %p new client %p", this, &m_client);
     ASSERT(isMainThread());
index 28aac78..851a17f 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Google Inc.  All rights reserved.
@@ -48,10 +49,11 @@ namespace WebCore {
 
 class SocketStreamError;
 class SocketStreamHandleClient;
+class StorageSessionProvider;
 
 class SocketStreamHandleImpl final : public SocketStreamHandle {
 public:
-    static Ref<SocketStreamHandleImpl> create(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String&, SourceApplicationAuditToken&&);
+    static Ref<SocketStreamHandleImpl> create(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String&, SourceApplicationAuditToken&&, const StorageSessionProvider*);
     virtual ~SocketStreamHandleImpl();
 
     const URL& url() const { return m_url; }
@@ -60,7 +62,7 @@ public:
     void platformSendHandshake(const uint8_t* data, size_t length, const Optional<CookieRequestHeaderFieldProxy>&, Function<void(bool, bool)>&&) final;
     void platformClose() final;
 private:
-    SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&);
+    SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&, const StorageSessionProvider*);
 
     size_t bufferedAmount() final;
     Optional<size_t> platformSendInternal(const uint8_t*, size_t);
@@ -78,6 +80,8 @@ private:
     void didFail(SocketStreamError&&);
     void writeReady();
 
+    RefPtr<const StorageSessionProvider> m_storageSessionProvider;
+    
     GRefPtr<GIOStream> m_stream;
     GRefPtr<GInputStream> m_inputStream;
     GRefPtr<GPollableOutputStream> m_outputStream;
index 5d9dc96..2c4a7ed 100644 (file)
@@ -41,6 +41,7 @@
 #include "SocketStreamError.h"
 #include "SocketStreamHandleClient.h"
 #include "SoupNetworkSession.h"
+#include "StorageSessionProvider.h"
 #include "URLSoup.h"
 #include <gio/gio.h>
 #include <glib.h>
@@ -81,12 +82,12 @@ static void socketClientEventCallback(GSocketClient*, GSocketClientEvent event,
 }
 #endif
 
-Ref<SocketStreamHandleImpl> SocketStreamHandleImpl::create(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String&, SourceApplicationAuditToken&&)
+Ref<SocketStreamHandleImpl> SocketStreamHandleImpl::create(const URL& url, SocketStreamHandleClient& client, PAL::SessionID, const String&, SourceApplicationAuditToken&&, const StorageSessionProvider* storageSessionProvider)
 {
-    Ref<SocketStreamHandleImpl> socket = adoptRef(*new SocketStreamHandleImpl(url, client));
+    Ref<SocketStreamHandleImpl> socket = adoptRef(*new SocketStreamHandleImpl(url, client, storageSessionProvider));
 
 #if SOUP_CHECK_VERSION(2, 61, 90)
-    auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID);
+    auto* networkStorageSession = storageSessionProvider ? storageSessionProvider->storageSession() : nullptr;
     if (!networkStorageSession)
         return socket;
 
@@ -96,7 +97,6 @@ Ref<SocketStreamHandleImpl> SocketStreamHandleImpl::create(const URL& url, Socke
         url.protocolIs("wss") ? reinterpret_cast<SoupSessionConnectProgressCallback>(connectProgressCallback) : nullptr,
         reinterpret_cast<GAsyncReadyCallback>(connectedCallback), &protectedSocketStreamHandle.leakRef());
 #else
-    UNUSED_PARAM(sessionID);
     unsigned port = url.port() ? url.port().value() : (url.protocolIs("wss") ? 443 : 80);
     GRefPtr<GSocketClient> socketClient = adoptGRef(g_socket_client_new());
     if (url.protocolIs("wss")) {
@@ -111,8 +111,9 @@ Ref<SocketStreamHandleImpl> SocketStreamHandleImpl::create(const URL& url, Socke
     return socket;
 }
 
-SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client)
+SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client, const StorageSessionProvider* provider)
     : SocketStreamHandle(url, client)
+    , m_storageSessionProvider(provider)
     , m_cancellable(adoptGRef(g_cancellable_new()))
 {
     LOG(Network, "SocketStreamHandle %p new client %p", this, &m_client);
index e492f8a..3436967 100644 (file)
@@ -1,3 +1,26 @@
+2019-01-17  Alex Christensen  <achristensen@webkit.org>
+
+        Stop using NetworkStorageSession::storageSession in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=193529
+
+        Reviewed by Tim Horton.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::createSocketStream):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkSocketStream.cpp:
+        (WebKit::NetworkSocketStream::create):
+        (WebKit::NetworkSocketStream::NetworkSocketStream):
+        * NetworkProcess/NetworkSocketStream.h:
+        * NetworkProcess/NetworkStorageSessionProvider.h: Added.
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/Network/WebSocketProvider.cpp:
+        (WebKit::WebSocketProvider::createSocketStreamHandle):
+        * WebProcess/Network/WebSocketProvider.h:
+        * WebProcess/WebPage/WebCookieJar.cpp:
+        (WebKit::WebCookieJar::WebCookieJar):
+        * WebProcess/WebPage/WebCookieJar.h:
+
 2019-01-16  Youenn Fablet  <youenn@apple.com>
 
         Add a new SPI for controlling getUserMedia
index dbac30b..6413203 100644 (file)
@@ -281,7 +281,7 @@ void NetworkConnectionToWebProcess::createSocketStream(URL&& url, PAL::SessionID
 #if PLATFORM(COCOA)
     token = { m_networkProcess->sourceApplicationAuditData() };
 #endif
-    m_networkSocketStreams.set(identifier, NetworkSocketStream::create(WTFMove(url), sessionID, cachePartition, identifier, m_connection, WTFMove(token)));
+    m_networkSocketStreams.set(identifier, NetworkSocketStream::create(m_networkProcess.get(), WTFMove(url), sessionID, cachePartition, identifier, m_connection, WTFMove(token)));
 }
 
 void NetworkConnectionToWebProcess::destroySocketStream(uint64_t identifier)
index 8fd8f0c..e26721f 100644 (file)
@@ -27,6 +27,7 @@
 #include "NetworkSocketStream.h"
 
 #include "DataReference.h"
+#include "NetworkStorageSessionProvider.h"
 #include "WebSocketStreamMessages.h"
 #include <WebCore/CookieRequestHeaderFieldProxy.h>
 #include <WebCore/SocketStreamError.h>
 namespace WebKit {
 using namespace WebCore;
 
-Ref<NetworkSocketStream> NetworkSocketStream::create(URL&& url, PAL::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
+Ref<NetworkSocketStream> NetworkSocketStream::create(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
 {
-    return adoptRef(*new NetworkSocketStream(WTFMove(url), sessionID, credentialPartition, identifier, connection, WTFMove(auditData)));
+    return adoptRef(*new NetworkSocketStream(networkProcess, WTFMove(url), sessionID, credentialPartition, identifier, connection, WTFMove(auditData)));
 }
 
-NetworkSocketStream::NetworkSocketStream(URL&& url, PAL::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
+NetworkSocketStream::NetworkSocketStream(NetworkProcess& networkProcess, URL&& url, PAL::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection, SourceApplicationAuditToken&& auditData)
     : m_identifier(identifier)
     , m_connection(connection)
-    , m_impl(SocketStreamHandleImpl::create(url, *this, sessionID, credentialPartition, WTFMove(auditData)))
+    , m_impl(SocketStreamHandleImpl::create(url, *this, sessionID, credentialPartition, WTFMove(auditData), NetworkStorageSessionProvider::create(networkProcess, sessionID).ptr()))
 {
 }
 
index c74f5c6..145fc0c 100644 (file)
@@ -39,9 +39,11 @@ class DataReference;
 
 namespace WebKit {
 
+class NetworkProcess;
+
 class NetworkSocketStream : public RefCounted<NetworkSocketStream>, public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandleClient {
 public:
-    static Ref<NetworkSocketStream> create(URL&&, PAL::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
+    static Ref<NetworkSocketStream> create(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
     ~NetworkSocketStream();
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
@@ -62,7 +64,7 @@ private:
     IPC::Connection* messageSenderConnection() final;
     uint64_t messageSenderDestinationID() final;
 
-    NetworkSocketStream(URL&&, PAL::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
+    NetworkSocketStream(NetworkProcess&, URL&&, PAL::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&, WebCore::SourceApplicationAuditToken&&);
 
     uint64_t m_identifier;
     IPC::Connection& m_connection;
diff --git a/Source/WebKit/NetworkProcess/NetworkStorageSessionProvider.h b/Source/WebKit/NetworkProcess/NetworkStorageSessionProvider.h
new file mode 100644 (file)
index 0000000..04ac475
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "NetworkProcess.h"
+#include <WebCore/NetworkStorageSession.h>
+#include <WebCore/StorageSessionProvider.h>
+#include <pal/SessionID.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebKit {
+
+class NetworkStorageSessionProvider final : public WebCore::StorageSessionProvider {
+public:
+    static Ref<NetworkStorageSessionProvider> create(NetworkProcess& networkProcess, const PAL::SessionID& sessionID) { return adoptRef(*new NetworkStorageSessionProvider(networkProcess, sessionID)); }
+    
+private:
+    NetworkStorageSessionProvider(NetworkProcess& networkProcess, const PAL::SessionID& sessionID)
+        : m_networkProcess(makeWeakPtr(networkProcess))
+        , m_sessionID(sessionID) { }
+
+    WebCore::NetworkStorageSession* storageSession() const final
+    {
+        if (m_networkProcess)
+            return WebCore::NetworkStorageSession::storageSession(m_sessionID);
+        return nullptr;
+    }
+
+    WeakPtr<NetworkProcess> m_networkProcess;
+    PAL::SessionID m_sessionID;
+};
+
+}
index 97141e8..23fb68a 100644 (file)
                5C8DD3811FE455CA00F2A556 /* WebsiteAutoplayQuirk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteAutoplayQuirk.h; sourceTree = "<group>"; };
                5C9E56801DF7F05500C9EE33 /* WKWebsitePolicies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKWebsitePolicies.cpp; sourceTree = "<group>"; };
                5C9E56811DF7F05500C9EE33 /* WKWebsitePolicies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsitePolicies.h; sourceTree = "<group>"; };
+               5C9EF2E721F058F9003BDC56 /* NetworkStorageSessionProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkStorageSessionProvider.h; sourceTree = "<group>"; };
                5CA26D7F217ABBB600F97A35 /* WKSafeBrowsingWarning.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKSafeBrowsingWarning.mm; sourceTree = "<group>"; };
                5CA26D80217ABBB600F97A35 /* WKSafeBrowsingWarning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKSafeBrowsingWarning.h; sourceTree = "<group>"; };
                5CA98549210BEB5A0057EB6B /* SafeBrowsingWarning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SafeBrowsingWarning.h; sourceTree = "<group>"; };
                                5C0B177D1E7C886700E9123C /* NetworkSocketStream.cpp */,
                                5C0B177E1E7C886700E9123C /* NetworkSocketStream.h */,
                                5C0B177F1E7C886700E9123C /* NetworkSocketStream.messages.in */,
+                               5C9EF2E721F058F9003BDC56 /* NetworkStorageSessionProvider.h */,
                                462107D71F38DBD300DD7810 /* PingLoad.cpp */,
                                5CE85B1F1C88E6430070BFCE /* PingLoad.h */,
                                83A0ED331F747CC7003299EB /* PreconnectTask.cpp */,
index 2b2b89a..54709db 100644 (file)
@@ -36,7 +36,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-Ref<SocketStreamHandle> WebSocketProvider::createSocketStreamHandle(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition)
+Ref<SocketStreamHandle> WebSocketProvider::createSocketStreamHandle(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, const StorageSessionProvider*)
 {
     return WebSocketStream::create(url, client, sessionID, credentialPartition);
 }
index 69b7fa3..290b99c 100644 (file)
@@ -32,7 +32,7 @@ namespace WebKit {
 class WebSocketProvider final : public WebCore::SocketProvider {
 public:
     static Ref<WebSocketProvider> create() { return adoptRef(*new WebSocketProvider); }
-    Ref<WebCore::SocketStreamHandle> createSocketStreamHandle(const URL&, WebCore::SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition) final;
+    Ref<WebCore::SocketStreamHandle> createSocketStreamHandle(const URL&, WebCore::SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition, const WebCore::StorageSessionProvider*) final;
     virtual ~WebSocketProvider() { }
 };
 
index bf35f8e..160edef 100644 (file)
 #include <WebCore/Frame.h>
 #include <WebCore/FrameLoader.h>
 #include <WebCore/FrameLoaderClient.h>
+#include <WebCore/StorageSessionProvider.h>
 
 namespace WebKit {
 
+class WebStorageSessionProvider : public WebCore::StorageSessionProvider {
+    // NetworkStorageSessions are accessed only in the NetworkProcess.
+    WebCore::NetworkStorageSession* storageSession() const final { return nullptr; }
+};
+
+WebCookieJar::WebCookieJar()
+    : WebCore::CookieJar(adoptRef(*new WebStorageSessionProvider)) { }
+
 String WebCookieJar::cookies(WebCore::Document& document, const URL& url) const
 {
     Optional<uint64_t> frameID;
index 23e36b4..97dd76f 100644 (file)
@@ -39,6 +39,8 @@ public:
     std::pair<String, WebCore::SecureCookiesAccessed> cookieRequestHeaderFieldValue(const PAL::SessionID&, const URL& firstParty, const WebCore::SameSiteInfo&, const URL&, Optional<uint64_t> frameID, Optional<uint64_t> pageID, WebCore::IncludeSecureCookies) const final;
     bool getRawCookies(const WebCore::Document&, const URL&, Vector<WebCore::Cookie>&) const final;
     void deleteCookie(const WebCore::Document&, const URL&, const String& cookieName) final;
+private:
+    WebCookieJar();
 };
 
 } // namespace WebKit
index 20d269c..0256b9c 100644 (file)
@@ -1,3 +1,13 @@
+2019-01-17  Alex Christensen  <achristensen@webkit.org>
+
+        Stop using NetworkStorageSession::storageSession in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=193529
+
+        Reviewed by Tim Horton.
+
+        * WebCoreSupport/PageStorageSessionProvider.h: Added.
+        * WebKitLegacy.xcodeproj/project.pbxproj:
+
 2019-01-04  Youenn Fablet  <youenn@apple.com>
 
         CSP violation reports should bypass CSP checks
diff --git a/Source/WebKitLegacy/WebCoreSupport/PageStorageSessionProvider.h b/Source/WebKitLegacy/WebCoreSupport/PageStorageSessionProvider.h
new file mode 100644 (file)
index 0000000..4d84f1a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <WebCore/NetworkStorageSession.h>
+#include <WebCore/Page.h>
+#include <WebCore/StorageSessionProvider.h>
+#include <wtf/WeakPtr.h>
+
+class PageStorageSessionProvider final : public WebCore::StorageSessionProvider {
+public:
+    static Ref<PageStorageSessionProvider> create() { return adoptRef(*new PageStorageSessionProvider); }
+
+    WebCore::NetworkStorageSession* storageSession() const
+    {
+        if (m_page)
+            return WebCore::NetworkStorageSession::storageSession(m_page->sessionID());
+        return nullptr;
+    }
+
+    void setPage(WebCore::Page& page)
+    {
+        m_page = makeWeakPtr(page);
+    }
+
+private:
+    WeakPtr<WebCore::Page> m_page;
+};
index 57d7bd7..f209004 100644 (file)
                598AD9281201CF3200ABAE4E /* WebDeviceOrientationProviderMock.mm in Sources */ = {isa = PBXBuildFile; fileRef = 598AD9271201CF3200ABAE4E /* WebDeviceOrientationProviderMock.mm */; };
                598AD92A1201CF3B00ABAE4E /* WebDeviceOrientationProviderMockInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 598AD9291201CF3B00ABAE4E /* WebDeviceOrientationProviderMockInternal.h */; };
                598ADA461202275000ABAE4E /* WebDeviceOrientationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 598ADA451202275000ABAE4E /* WebDeviceOrientationProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5C9EF2F521F061BE003BDC56 /* PageStorageSessionProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9EF2F421F061BE003BDC56 /* PageStorageSessionProvider.h */; };
                5CE44F4A206D70EA003EFD01 /* PingHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE44F49206D70E9003EFD01 /* PingHandle.h */; };
                5D7BF8140C2A1D90008CE06D /* WebInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D7BF8120C2A1D90008CE06D /* WebInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5D7BF8150C2A1D90008CE06D /* WebInspector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5D7BF8130C2A1D90008CE06D /* WebInspector.mm */; };
                598AD9271201CF3200ABAE4E /* WebDeviceOrientationProviderMock.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDeviceOrientationProviderMock.mm; sourceTree = "<group>"; };
                598AD9291201CF3B00ABAE4E /* WebDeviceOrientationProviderMockInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDeviceOrientationProviderMockInternal.h; sourceTree = "<group>"; };
                598ADA451202275000ABAE4E /* WebDeviceOrientationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDeviceOrientationProvider.h; sourceTree = "<group>"; };
+               5C9EF2F421F061BE003BDC56 /* PageStorageSessionProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PageStorageSessionProvider.h; path = WebCoreSupport/PageStorageSessionProvider.h; sourceTree = SOURCE_ROOT; };
                5CE44F49206D70E9003EFD01 /* PingHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PingHandle.h; path = WebCoreSupport/PingHandle.h; sourceTree = SOURCE_ROOT; };
                5D7BF8120C2A1D90008CE06D /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; };
                5D7BF8130C2A1D90008CE06D /* WebInspector.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspector.mm; sourceTree = "<group>"; };
                                A10C1D4418202FFB0036883A /* ios */,
                                B82958D1132707D0000D0E79 /* CorrectionPanel.h */,
                                B82958D2132707D0000D0E79 /* CorrectionPanel.mm */,
+                               5C9EF2F421F061BE003BDC56 /* PageStorageSessionProvider.h */,
                                5CE44F49206D70E9003EFD01 /* PingHandle.h */,
                                7C01CB81173435C900C5D807 /* PopupMenuMac.h */,
                                7C01CB82173435C900C5D807 /* PopupMenuMac.mm */,
                                E1531BD82187B954002E3F81 /* NSURLDownloadSPI.h in Headers */,
                                93D4379B1D57ABEF00AB85EA /* ObjCEventListener.h in Headers */,
                                93D4379D1D57ABEF00AB85EA /* ObjCNodeFilterCondition.h in Headers */,
+                               5C9EF2F521F061BE003BDC56 /* PageStorageSessionProvider.h in Headers */,
                                5CE44F4A206D70EA003EFD01 /* PingHandle.h in Headers */,
                                A10C1D5F1820300E0036883A /* PopupMenuIOS.h in Headers */,
                                7C01CB85173435C900C5D807 /* PopupMenuMac.h in Headers */,
index d146beb..1468ca1 100644 (file)
@@ -1,3 +1,16 @@
+2019-01-17  Alex Christensen  <achristensen@webkit.org>
+
+        Stop using NetworkStorageSession::storageSession in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=193529
+
+        Reviewed by Tim Horton.
+
+        * Misc/WebCache.mm:
+        (+[WebCache addImageToCache:forURL:forFrame:]):
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+        (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
+
 2019-01-15  Alex Christensen  <achristensen@webkit.org>
 
         Reduce use of NetworkStorageSession::defaultStorageSession in WebCore
index def768e..857055d 100644 (file)
@@ -38,6 +38,7 @@
 #import <WebCore/Document.h>
 #import <WebCore/MemoryCache.h>
 #import <WebCore/NetworkStorageSession.h>
+#import <WebCore/StorageSessionProvider.h>
 #import <wtf/MainThread.h>
 #import <wtf/RunLoop.h>
 
 #import <WebCore/WebCoreThreadRun.h>
 #endif
 
+class DefaultStorageSessionProvider : public WebCore::StorageSessionProvider {
+    WebCore::NetworkStorageSession* storageSession() const final
+    {
+        return &WebCore::NetworkStorageSession::defaultStorageSession();
+    }
+};
+
 @implementation WebCache
 
 + (void)initialize
     if (!image || !url || ![[url absoluteString] length])
         return false;
 
-    return WebCore::MemoryCache::singleton().addImageToCache(RetainPtr<CGImageRef>(image), url, frame ? core(frame)->document()->domainForCachePartition() : emptyString(), PAL::SessionID::defaultSessionID(), WebCore::CookieJar::create().ptr());
+    auto provider = adoptRef(*new DefaultStorageSessionProvider);
+    return WebCore::MemoryCache::singleton().addImageToCache(RetainPtr<CGImageRef>(image), url, frame ? core(frame)->document()->domainForCachePartition() : emptyString(), PAL::SessionID::defaultSessionID(), WebCore::CookieJar::create(WTFMove(provider)).ptr());
 }
 
 + (void)removeImageFromCacheForURL:(NSURL *)url
index 64a946b..85eab48 100644 (file)
@@ -37,6 +37,7 @@
 #import "DOMInternal.h"
 #import "DOMNodeInternal.h"
 #import "DOMRangeInternal.h"
+#import "PageStorageSessionProvider.h"
 #import "StorageThread.h"
 #import "WebAlternativeTextClient.h"
 #import "WebApplicationCacheInternal.h"
@@ -1440,13 +1441,14 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     _private->group = WebViewGroup::getOrCreate(groupName, _private->preferences._localStorageDatabasePath);
     _private->group->addWebView(self);
 
+    auto storageProvider = PageStorageSessionProvider::create();
     PageConfiguration pageConfiguration(
         makeUniqueRef<WebEditorClient>(self),
         SocketProvider::create(),
         LibWebRTCProvider::create(),
         WebCore::CacheStorageProvider::create(),
         BackForwardList::create(self),
-        CookieJar::create()
+        CookieJar::create(storageProvider.copyRef())
     );
 #if !PLATFORM(IOS_FAMILY)
     pageConfiguration.chromeClient = new WebChromeClient(self);
@@ -1477,6 +1479,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     pageConfiguration.userContentProvider = &_private->group->userContentController();
     pageConfiguration.visitedLinkStore = &_private->group->visitedLinkStore();
     _private->page = new Page(WTFMove(pageConfiguration));
+    storageProvider->setPage(*_private->page);
 
     _private->page->setGroupName(groupName);
 
@@ -1706,13 +1709,14 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     _private->group = WebViewGroup::getOrCreate(groupName, _private->preferences._localStorageDatabasePath);
     _private->group->addWebView(self);
 
+    auto storageProvider = PageStorageSessionProvider::create();
     PageConfiguration pageConfiguration(
         makeUniqueRef<WebEditorClient>(self),
         SocketProvider::create(),
         LibWebRTCProvider::create(),
         WebCore::CacheStorageProvider::create(),
         BackForwardList::create(self),
-        CookieJar::create()
+        CookieJar::create(storageProvider.copyRef())
     );
     pageConfiguration.chromeClient = new WebChromeClientIOS(self);
 #if ENABLE(DRAG_SUPPORT)
@@ -1734,6 +1738,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     pageConfiguration.pluginInfoProvider = &WebPluginInfoProvider::singleton();
 
     _private->page = new Page(WTFMove(pageConfiguration));
+    storageProvider->setPage(*_private->page);
     
     [self setSmartInsertDeleteEnabled:YES];
     
index 55d6857..607a209 100644 (file)
@@ -1,3 +1,13 @@
+2019-01-17  Alex Christensen  <achristensen@webkit.org>
+
+        Stop using NetworkStorageSession::storageSession in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=193529
+
+        Reviewed by Tim Horton.
+
+        * WebView.cpp:
+        (WebView::initWithFrame):
+
 2019-01-15  Alex Christensen  <achristensen@webkit.org>
 
         Reduce use of NetworkStorageSession::defaultStorageSession in WebCore
index 964d0ed..b829a67 100644 (file)
@@ -32,6 +32,7 @@
 #include "DOMCoreClasses.h"
 #include "FullscreenVideoController.h"
 #include "MarshallingHelpers.h"
+#include "PageStorageSessionProvider.h"
 #include "PluginDatabase.h"
 #include "PluginView.h"
 #include "WebApplicationCache.h"
@@ -3106,13 +3107,14 @@ HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
 
     m_inspectorClient = new WebInspectorClient(this);
 
+    auto storageProvider = PageStorageSessionProvider::create();
     PageConfiguration configuration(
         makeUniqueRef<WebEditorClient>(this),
         SocketProvider::create(),
         makeUniqueRef<LibWebRTCProvider>(),
         WebCore::CacheStorageProvider::create(),
         BackForwardList::create(),
-        CookieJar::create()
+        CookieJar::create(storageProvider.copyRef())
     );
     configuration.chromeClient = new WebChromeClient(this);
     configuration.contextMenuClient = new WebContextMenuClient(this);
@@ -3128,6 +3130,7 @@ HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
     configuration.pluginInfoProvider = &WebPluginInfoProvider::singleton();
 
     m_page = new Page(WTFMove(configuration));
+    storageProvider->setPage(*m_page);
     provideGeolocationTo(m_page, *new WebGeolocationClient(this));
 
     m_page->addLayoutMilestones({ DidFirstLayout, DidFirstVisuallyNonEmptyLayout });