Changeset 240292 in webkit


Ignore:
Timestamp:
Jan 22, 2019 1:28:28 PM (5 years ago)
Author:
achristensen@apple.com
Message:

Move NetworkStorageSession ownership to NetworkProcess
https://bugs.webkit.org/show_bug.cgi?id=193580

Reviewed by Geoff Garen.

Source/WebCore:

NetworkStorageSessions used to be owned by a process-global map living in WebCore.
This patch moves the ownership to the WebKit/WebKitLegacy layer.
In WebKitLegacy they are still owned by a process-global map for compatibility.
In WebKit they are owned by a map owned by the NetworkProcess object.
There were three non-NetworkProcess uses of NetworkStorageSessions which have been dealt with thusly:

  1. The WebProcess used to clear credentials from a NetworkStorageSession. Since this was the only use

of a NetworkStorageSession in the WebProcess we can conclude there were no credentials to clear,
so this code was removed with no change in behavior.

  1. The WebProcess used NetworkStorageSessions to get persistent credentials. This was turned

into a static method that does the same thing. We should audit these calls and decide if we really want them.

  1. The UIProcess used NetworkStorageSessions in APIHTTPCookieStore to interact with the default cookie

storage on Cocoa platforms. This has been replaced by functions that do the same thing directly.

  • platform/network/CredentialStorage.h:
  • platform/network/NetworkStorageSession.cpp:

(WebCore::NetworkStorageSession::processMayUseCookieAPI):
(WebCore::NetworkStorageSession::globalSessionMap): Deleted.
(WebCore::NetworkStorageSession::storageSession): Deleted.
(WebCore::NetworkStorageSession::destroySession): Deleted.
(WebCore::NetworkStorageSession::forEach): Deleted.

  • platform/network/NetworkStorageSession.h:
  • platform/network/cf/NetworkStorageSessionCFNet.cpp:

(WebCore::NetworkStorageSession::createCFStorageSessionForIdentifier):
(WebCore::createCFStorageSessionForIdentifier): Deleted.
(WebCore::defaultNetworkStorageSession): Deleted.
(WebCore::NetworkStorageSession::switchToNewTestingSession): Deleted.
(WebCore::NetworkStorageSession::defaultStorageSession): Deleted.
(WebCore::NetworkStorageSession::ensureSession): Deleted.

  • platform/network/cf/SocketStreamHandleImplCFNet.cpp:

(WebCore::SocketStreamHandleImpl::getStoredCONNECTProxyCredentials):

  • platform/network/cocoa/CookieStorageObserver.h:
  • platform/network/curl/NetworkStorageSessionCurl.cpp:

(WebCore::defaultSession): Deleted.
(WebCore::NetworkStorageSession::defaultStorageSession): Deleted.
(WebCore::NetworkStorageSession::ensureSession): Deleted.
(WebCore::NetworkStorageSession::switchToNewTestingSession): Deleted.

  • platform/network/soup/NetworkStorageSessionSoup.cpp:

(WebCore::NetworkStorageSession::clearSoupNetworkSessionAndCookieStorage):
(WebCore::defaultSession): Deleted.
(WebCore::NetworkStorageSession::defaultStorageSession): Deleted.
(WebCore::NetworkStorageSession::ensureSession): Deleted.
(WebCore::NetworkStorageSession::switchToNewTestingSession): Deleted.

Source/WebKit:

  • NetworkProcess/Cookies/WebCookieManager.cpp:

(WebKit::WebCookieManager::WebCookieManager):
(WebKit::WebCookieManager::getHostnamesWithCookies):
(WebKit::WebCookieManager::deleteCookiesForHostname):
(WebKit::WebCookieManager::deleteAllCookies):
(WebKit::WebCookieManager::deleteCookie):
(WebKit::WebCookieManager::deleteAllCookiesModifiedSince):
(WebKit::WebCookieManager::getAllCookies):
(WebKit::WebCookieManager::getCookies):
(WebKit::WebCookieManager::setCookie):
(WebKit::WebCookieManager::setCookies):
(WebKit::WebCookieManager::startObservingCookieChanges):
(WebKit::WebCookieManager::stopObservingCookieChanges):

  • NetworkProcess/Cookies/WebCookieManager.h:
  • NetworkProcess/Cookies/mac/WebCookieManagerMac.mm:

(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):

  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::storageSession):
(WebKit::NetworkConnectionToWebProcess::cookiesForDOM):
(WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM):
(WebKit::NetworkConnectionToWebProcess::cookiesEnabled):
(WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue):
(WebKit::NetworkConnectionToWebProcess::getRawCookies):
(WebKit::NetworkConnectionToWebProcess::deleteCookie):
(WebKit::NetworkConnectionToWebProcess::removeStorageAccessForFrame):
(WebKit::NetworkConnectionToWebProcess::removeStorageAccessForAllFramesOnPage):

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::initializeNetworkProcess):
(WebKit::NetworkProcess::clearCachedCredentials):
(WebKit::NetworkProcess::switchToNewTestingSession):
(WebKit::NetworkProcess::ensureSession):
(WebKit::NetworkProcess::storageSession const):
(WebKit::NetworkProcess::defaultStorageSession const):
(WebKit::NetworkProcess::forEachNetworkStorageSession):
(WebKit::NetworkProcess::destroySession):
(WebKit::NetworkProcess::updatePrevalentDomainsToBlockCookiesFor):
(WebKit::NetworkProcess::setAgeCapForClientSideCookies):
(WebKit::NetworkProcess::hasStorageAccessForFrame):
(WebKit::NetworkProcess::getAllStorageAccessEntries):
(WebKit::NetworkProcess::grantStorageAccess):
(WebKit::NetworkProcess::removeAllStorageAccess):
(WebKit::NetworkProcess::removePrevalentDomains):
(WebKit::NetworkProcess::setCacheMaxAgeCapForPrevalentResources):
(WebKit::NetworkProcess::resetCacheMaxAgeCapForPrevalentResources):
(WebKit::NetworkProcess::fetchWebsiteData):
(WebKit::NetworkProcess::deleteWebsiteData):
(WebKit::NetworkProcess::deleteWebsiteDataForOrigins):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::validateCacheEntryForMaxAgeCapValidation):
(WebKit::NetworkResourceLoader::logCookieInformation const):

  • NetworkProcess/NetworkSession.cpp:

(WebKit::NetworkSession::networkStorageSession const):

  • NetworkProcess/NetworkStorageSessionProvider.h:
  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::makeUseDecision):
(WebKit::NetworkCache::Cache::retrieve):
(WebKit::NetworkCache::Cache::makeEntry):
(WebKit::NetworkCache::Cache::makeRedirectEntry):
(WebKit::NetworkCache::Cache::update):

  • NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:

(WebKit::NetworkCache::SpeculativeLoad::willSendRedirectedRequest):

  • NetworkProcess/cocoa/NetworkProcessCocoa.mm:

(WebKit::NetworkProcess::platformSyncAllCookies):

  • NetworkProcess/cocoa/NetworkSessionCocoa.mm:

(-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:task:_schemeUpgraded:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):

  • NetworkProcess/mac/RemoteNetworkingContext.mm:

(WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):

  • SourcesCocoa.txt:
  • UIProcess/API/APIHTTPCookieStore.cpp:

(API::HTTPCookieStore::~HTTPCookieStore):
(API::HTTPCookieStore::cookies):
(API::HTTPCookieStore::setCookie):
(API::HTTPCookieStore::deleteCookie):
(API::HTTPCookieStore::registerObserver):
(API::HTTPCookieStore::unregisterObserver):
(API::HTTPCookieStore::registerForNewProcessPoolNotifications):
(API::HTTPCookieStore::flushDefaultUIProcessCookieStore):
(API::HTTPCookieStore::getAllDefaultUIProcessCookieStoreCookies):
(API::HTTPCookieStore::setCookieInDefaultUIProcessCookieStore):
(API::HTTPCookieStore::deleteCookieFromDefaultUIProcessCookieStore):
(API::HTTPCookieStore::startObservingChangesToDefaultUIProcessCookieStore):
(API::HTTPCookieStore::stopObservingChangesToDefaultUIProcessCookieStore):

  • UIProcess/API/APIHTTPCookieStore.h:
  • UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm: Added.

(API::HTTPCookieStore::flushDefaultUIProcessCookieStore):
(API::HTTPCookieStore::getAllDefaultUIProcessCookieStoreCookies):
(API::HTTPCookieStore::setCookieInDefaultUIProcessCookieStore):
(API::HTTPCookieStore::deleteCookieFromDefaultUIProcessCookieStore):
(API::HTTPCookieStore::startObservingChangesToDefaultUIProcessCookieStore):
(API::HTTPCookieStore::stopObservingChangesToDefaultUIProcessCookieStore):

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::clearCachedCredentials):

  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/Plugins/PluginView.cpp:

(WebKit::PluginView::getAuthenticationInfo):

  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::deleteWebsiteData):
(WebKit::WebProcess::clearCachedCredentials): Deleted.

  • WebProcess/WebProcess.h:
  • WebProcess/WebProcess.messages.in:

Source/WebKitLegacy:

  • WebCoreSupport/NetworkStorageSessionMap.cpp: Added.

(defaultNetworkStorageSession):
(globalSessionMap):
(NetworkStorageSessionMap::storageSession):
(NetworkStorageSessionMap::defaultStorageSession):
(NetworkStorageSessionMap::switchToNewTestingSession):
(NetworkStorageSessionMap::ensureSession):
(NetworkStorageSessionMap::destroySession):

  • WebCoreSupport/NetworkStorageSessionMap.h: Added.
  • WebCoreSupport/PageStorageSessionProvider.h:
  • WebKitLegacy.xcodeproj/project.pbxproj:

Source/WebKitLegacy/mac:

  • Misc/WebCache.mm:

(+[WebCache clearCachedCredentials]):

  • Misc/WebDownload.mm:

(-[WebDownloadInternal download:didReceiveAuthenticationChallenge:]):

  • Plugins/WebBaseNetscapePluginView.mm:

(WebKit::getAuthenticationInfo):

  • WebCoreSupport/WebFrameNetworkingContext.mm:

(WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebFrameNetworkingContext::destroyPrivateBrowsingSession):
(WebFrameNetworkingContext::storageSession const):

  • WebView/WebPreferences.mm:

(+[WebPreferences _switchNetworkLoaderToNewTestingSession]):
(+[WebPreferences _clearNetworkLoaderSession]):
(+[WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:]):

Source/WebKitLegacy/win:

  • WebCoreSupport/WebFrameNetworkingContext.cpp:

(WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts):
(WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebFrameNetworkingContext::destroyPrivateBrowsingSession):
(WebFrameNetworkingContext::storageSession const):

  • WebDownloadCFNet.cpp:

(WebDownload::didReceiveAuthenticationChallenge):

  • WebPreferences.cpp:

(WebPreferences::clearNetworkLoaderSession):
(WebPreferences::switchNetworkLoaderToNewTestingSession):

Location:
trunk/Source
Files:
3 added
62 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r240277 r240292  
     12019-01-22  Alex Christensen  <achristensen@webkit.org>
     2
     3        Move NetworkStorageSession ownership to NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=193580
     5
     6        Reviewed by Geoff Garen.
     7
     8        NetworkStorageSessions used to be owned by a process-global map living in WebCore.
     9        This patch moves the ownership to the WebKit/WebKitLegacy layer.
     10        In WebKitLegacy they are still owned by a process-global map for compatibility.
     11        In WebKit they are owned by a map owned by the NetworkProcess object.
     12        There were three non-NetworkProcess uses of NetworkStorageSessions which have been dealt with thusly:
     13        1. The WebProcess used to clear credentials from a NetworkStorageSession.  Since this was the only use
     14        of a NetworkStorageSession in the WebProcess we can conclude there were no credentials to clear,
     15        so this code was removed with no change in behavior.
     16        2. The WebProcess used NetworkStorageSessions to get persistent credentials.  This was turned
     17        into a static method that does the same thing.  We should audit these calls and decide if we really want them.
     18        3. The UIProcess used NetworkStorageSessions in APIHTTPCookieStore to interact with the default cookie
     19        storage on Cocoa platforms.  This has been replaced by functions that do the same thing directly.
     20
     21        * platform/network/CredentialStorage.h:
     22        * platform/network/NetworkStorageSession.cpp:
     23        (WebCore::NetworkStorageSession::processMayUseCookieAPI):
     24        (WebCore::NetworkStorageSession::globalSessionMap): Deleted.
     25        (WebCore::NetworkStorageSession::storageSession): Deleted.
     26        (WebCore::NetworkStorageSession::destroySession): Deleted.
     27        (WebCore::NetworkStorageSession::forEach): Deleted.
     28        * platform/network/NetworkStorageSession.h:
     29        * platform/network/cf/NetworkStorageSessionCFNet.cpp:
     30        (WebCore::NetworkStorageSession::createCFStorageSessionForIdentifier):
     31        (WebCore::createCFStorageSessionForIdentifier): Deleted.
     32        (WebCore::defaultNetworkStorageSession): Deleted.
     33        (WebCore::NetworkStorageSession::switchToNewTestingSession): Deleted.
     34        (WebCore::NetworkStorageSession::defaultStorageSession): Deleted.
     35        (WebCore::NetworkStorageSession::ensureSession): Deleted.
     36        * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
     37        (WebCore::SocketStreamHandleImpl::getStoredCONNECTProxyCredentials):
     38        * platform/network/cocoa/CookieStorageObserver.h:
     39        * platform/network/curl/NetworkStorageSessionCurl.cpp:
     40        (WebCore::defaultSession): Deleted.
     41        (WebCore::NetworkStorageSession::defaultStorageSession): Deleted.
     42        (WebCore::NetworkStorageSession::ensureSession): Deleted.
     43        (WebCore::NetworkStorageSession::switchToNewTestingSession): Deleted.
     44        * platform/network/soup/NetworkStorageSessionSoup.cpp:
     45        (WebCore::NetworkStorageSession::clearSoupNetworkSessionAndCookieStorage):
     46        (WebCore::defaultSession): Deleted.
     47        (WebCore::NetworkStorageSession::defaultStorageSession): Deleted.
     48        (WebCore::NetworkStorageSession::ensureSession): Deleted.
     49        (WebCore::NetworkStorageSession::switchToNewTestingSession): Deleted.
     50
    1512019-01-22  Devin Rousso  <drousso@apple.com>
    252
  • trunk/Source/WebCore/platform/network/CredentialStorage.h

    r240031 r240292  
    4545
    4646    // OS persistent storage.
    47     WEBCORE_EXPORT Credential getFromPersistentStorage(const ProtectionSpace&);
     47    WEBCORE_EXPORT static Credential getFromPersistentStorage(const ProtectionSpace&);
    4848
    4949    WEBCORE_EXPORT void clearCredentials();
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp

    r239737 r240292  
    4343bool NetworkStorageSession::m_processMayUseCookieAPI = false;
    4444
    45 HashMap<PAL::SessionID, std::unique_ptr<NetworkStorageSession>>& NetworkStorageSession::globalSessionMap()
    46 {
    47     static NeverDestroyed<HashMap<PAL::SessionID, std::unique_ptr<NetworkStorageSession>>> map;
    48     return map;
    49 }
    50 
    51 NetworkStorageSession* NetworkStorageSession::storageSession(PAL::SessionID sessionID)
    52 {
    53     if (sessionID == PAL::SessionID::defaultSessionID())
    54         return &defaultStorageSession();
    55     return globalSessionMap().get(sessionID);
    56 }
    57 
    58 void NetworkStorageSession::destroySession(PAL::SessionID sessionID)
    59 {
    60     ASSERT(sessionID != PAL::SessionID::defaultSessionID());
    61     globalSessionMap().remove(sessionID);
    62 }
    63 
    64 void NetworkStorageSession::forEach(const WTF::Function<void(const WebCore::NetworkStorageSession&)>& functor)
    65 {
    66     functor(defaultStorageSession());
    67     for (auto& storageSession : globalSessionMap().values())
    68         functor(*storageSession);
    69 }
    70 
    7145bool NetworkStorageSession::processMayUseCookieAPI()
    7246{
    7347    return m_processMayUseCookieAPI;
    74 };
     48}
    7549
    7650void NetworkStorageSession::permitProcessToUseCookieAPI(bool value)
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.h

    r240031 r240292  
    7575    WTF_MAKE_NONCOPYABLE(NetworkStorageSession); WTF_MAKE_FAST_ALLOCATED;
    7676public:
    77     WEBCORE_EXPORT static NetworkStorageSession& defaultStorageSession();
    78     WEBCORE_EXPORT static NetworkStorageSession* storageSession(PAL::SessionID);
    79     WEBCORE_EXPORT static void ensureSession(PAL::SessionID, const String& identifierBase = String());
    80     WEBCORE_EXPORT static void destroySession(PAL::SessionID);
    81     WEBCORE_EXPORT static void forEach(const WTF::Function<void(const WebCore::NetworkStorageSession&)>&);
    8277    WEBCORE_EXPORT static void permitProcessToUseCookieAPI(bool);
    8378    WEBCORE_EXPORT static bool processMayUseCookieAPI();
    8479
    85     WEBCORE_EXPORT static void switchToNewTestingSession();
    86 
    8780    PAL::SessionID sessionID() const { return m_sessionID; }
    8881    CredentialStorage& credentialStorage() { return m_credentialStorage; }
     
    9386
    9487#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
    95     WEBCORE_EXPORT static void ensureSession(PAL::SessionID, const String& identifierBase, RetainPtr<CFHTTPCookieStorageRef>&&);
    96     NetworkStorageSession(PAL::SessionID, RetainPtr<CFURLStorageSessionRef>&&, RetainPtr<CFHTTPCookieStorageRef>&&);
    97     explicit NetworkStorageSession(PAL::SessionID);
     88    WEBCORE_EXPORT static RetainPtr<CFURLStorageSessionRef> createCFStorageSessionForIdentifier(CFStringRef identifier);
     89    WEBCORE_EXPORT NetworkStorageSession(PAL::SessionID, RetainPtr<CFURLStorageSessionRef>&&, RetainPtr<CFHTTPCookieStorageRef>&&);
     90    WEBCORE_EXPORT explicit NetworkStorageSession(PAL::SessionID);
    9891
    9992    // May be null, in which case a Foundation default should be used.
     
    10295    WEBCORE_EXPORT static void setStorageAccessAPIEnabled(bool);
    10396#elif USE(SOUP)
    104     NetworkStorageSession(PAL::SessionID, std::unique_ptr<SoupNetworkSession>&&);
     97    WEBCORE_EXPORT NetworkStorageSession(PAL::SessionID, std::unique_ptr<SoupNetworkSession>&&);
    10598    ~NetworkStorageSession();
    10699
     
    114107    void saveCredentialToPersistentStorage(const ProtectionSpace&, const Credential&);
    115108#elif USE(CURL)
    116     NetworkStorageSession(PAL::SessionID, NetworkingContext*);
     109    WEBCORE_EXPORT NetworkStorageSession(PAL::SessionID, NetworkingContext*);
    117110    ~NetworkStorageSession();
    118111
     
    125118    NetworkingContext* context() const;
    126119#else
    127     NetworkStorageSession(PAL::SessionID, NetworkingContext*);
     120    WEBCORE_EXPORT NetworkStorageSession(PAL::SessionID, NetworkingContext*);
    128121    ~NetworkStorageSession();
    129122
     
    167160
    168161private:
    169     static HashMap<PAL::SessionID, std::unique_ptr<NetworkStorageSession>>& globalSessionMap();
    170162    PAL::SessionID m_sessionID;
    171163
  • trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp

    r240031 r240292  
    4141static bool storageAccessAPIEnabled;
    4242
    43 static RetainPtr<CFURLStorageSessionRef> createCFStorageSessionForIdentifier(CFStringRef identifier)
     43RetainPtr<CFURLStorageSessionRef> NetworkStorageSession::createCFStorageSessionForIdentifier(CFStringRef identifier)
    4444{
    4545    auto storageSession = adoptCF(_CFURLStorageSessionCreate(kCFAllocatorDefault, identifier, nullptr));
     
    8686}
    8787
    88 
    89 static std::unique_ptr<NetworkStorageSession>& defaultNetworkStorageSession()
    90 {
    91     ASSERT(isMainThread());
    92     static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
    93     return session;
    94 }
    95 
    96 void NetworkStorageSession::switchToNewTestingSession()
    97 {
    98     // Session name should be short enough for shared memory region name to be under the limit, otehrwise sandbox rules won't work (see <rdar://problem/13642852>).
    99     String sessionName = String::format("WebKit Test-%u", static_cast<uint32_t>(getCurrentProcessID()));
    100 
    101     auto session = adoptCF(createPrivateStorageSession(sessionName.createCFString().get()));
    102 
    103     RetainPtr<CFHTTPCookieStorageRef> cookieStorage;
    104     if (NetworkStorageSession::processMayUseCookieAPI()) {
    105         ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
    106         if (session)
    107             cookieStorage = adoptCF(_CFURLStorageSessionCopyCookieStorage(kCFAllocatorDefault, session.get()));
    108     }
    109 
    110     defaultNetworkStorageSession() = std::make_unique<NetworkStorageSession>(PAL::SessionID::defaultSessionID(), WTFMove(session), WTFMove(cookieStorage));
    111 }
    112 
    113 NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
    114 {
    115     if (!defaultNetworkStorageSession())
    116         defaultNetworkStorageSession() = std::make_unique<NetworkStorageSession>(PAL::SessionID::defaultSessionID());
    117     return *defaultNetworkStorageSession();
    118 }
    119 
    120 void NetworkStorageSession::ensureSession(PAL::SessionID sessionID, const String& identifierBase, RetainPtr<CFHTTPCookieStorageRef>&& cookieStorage)
    121 {
    122     auto addResult = globalSessionMap().add(sessionID, nullptr);
    123     if (!addResult.isNewEntry)
    124         return;
    125 
    126     RetainPtr<CFStringRef> cfIdentifier = String(identifierBase + ".PrivateBrowsing").createCFString();
    127 
    128     RetainPtr<CFURLStorageSessionRef> storageSession;
    129     if (sessionID.isEphemeral())
    130         storageSession = adoptCF(createPrivateStorageSession(cfIdentifier.get()));
    131     else
    132         storageSession = createCFStorageSessionForIdentifier(cfIdentifier.get());
    133 
    134     if (NetworkStorageSession::processMayUseCookieAPI()) {
    135         ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
    136         if (!cookieStorage && storageSession)
    137             cookieStorage = adoptCF(_CFURLStorageSessionCopyCookieStorage(kCFAllocatorDefault, storageSession.get()));
    138     }
    139 
    140     addResult.iterator->value = std::make_unique<NetworkStorageSession>(sessionID, WTFMove(storageSession), WTFMove(cookieStorage));
    141 }
    142 
    143 void NetworkStorageSession::ensureSession(PAL::SessionID sessionID, const String& identifierBase)
    144 {
    145     ensureSession(sessionID, identifierBase, nullptr);
    146 }
    147 
    14888RetainPtr<CFHTTPCookieStorageRef> NetworkStorageSession::cookieStorage() const
    14989{
  • trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp

    r240117 r240292  
    371371    Credential storedCredential;
    372372    if (auto* storageSession = m_storageSessionProvider ? m_storageSessionProvider->storageSession() : nullptr) {
    373         storedCredential = storageSession->credentialStorage().getFromPersistentStorage(protectionSpace);
     373        storedCredential = CredentialStorage::getFromPersistentStorage(protectionSpace);
    374374        if (storedCredential.isEmpty())
    375375            storedCredential = storageSession->credentialStorage().get(m_credentialPartition, protectionSpace);
  • trunk/Source/WebCore/platform/network/cocoa/CookieStorageObserver.h

    r239535 r240292  
    3636namespace WebCore {
    3737
    38 class CookieStorageObserver : public ThreadSafeRefCounted<CookieStorageObserver> {
     38class WEBCORE_EXPORT CookieStorageObserver : public ThreadSafeRefCounted<CookieStorageObserver> {
    3939public:
    4040    static Ref<CookieStorageObserver> create(NSHTTPCookieStorage *);
    41     CookieStorageObserver(NSHTTPCookieStorage *);
    4241    ~CookieStorageObserver();
    4342
    44     void startObserving(WTF::Function<void()>&& callback);
     43    void startObserving(Function<void()>&& callback);
    4544    void stopObserving();
    4645
     
    4847
    4948private:
     49    CookieStorageObserver(NSHTTPCookieStorage *);
     50
    5051    RetainPtr<NSHTTPCookieStorage> m_cookieStorage;
    5152    bool m_hasRegisteredInternalsForNotifications { false };
  • trunk/Source/WebCore/platform/network/curl/CurlResourceHandleDelegate.cpp

    r235821 r240292  
    9090    static const auto setCookieHeader = "set-cookie: ";
    9191
    92     const auto& storageSession = NetworkStorageSession::defaultStorageSession();
     92    const auto& storageSession = *d()->m_context->storageSession(PAL::SessionID::defaultSessionID());
    9393    const auto& cookieJar = storageSession.cookieStorage();
    9494    for (const auto& header : response.headers) {
  • trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp

    r239427 r240292  
    8686    m_cookieDatabase->open();
    8787    return m_cookieDatabase;
    88 }
    89 
    90 static std::unique_ptr<NetworkStorageSession>& defaultSession()
    91 {
    92     ASSERT(isMainThread());
    93     static std::unique_ptr<NetworkStorageSession> session;
    94     return session;
    95 }
    96 
    97 NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
    98 {
    99     if (!defaultSession())
    100         defaultSession() = std::make_unique<NetworkStorageSession>(PAL::SessionID::defaultSessionID(), nullptr);
    101     return *defaultSession();
    102 }
    103 
    104 void NetworkStorageSession::ensureSession(PAL::SessionID, const String&)
    105 {
    106     // FIXME: Implement for WebKit to use.
    107 }
    108 
    109 void NetworkStorageSession::switchToNewTestingSession()
    110 {
    111     // FIXME: Implement for WebKit to use.
    11288}
    11389
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp

    r240132 r240292  
    146146        addCacheValidationHeaders(request);
    147147
    148         auto& storageSession = NetworkStorageSession::defaultStorageSession();
     148        auto& storageSession = *d->m_context->storageSession(PAL::SessionID::defaultSessionID());
    149149        auto& cookieJar = storageSession.cookieStorage();
    150150        auto includeSecureCookies = request.url().protocolIs("https") ? IncludeSecureCookies::Yes : IncludeSecureCookies::No;
     
    232232        if (challenge.failureResponse().httpStatusCode() == 401)
    233233            urlToStore = challenge.failureResponse().url();
    234         NetworkStorageSession::defaultStorageSession().credentialStorage().set(partition, credential, challenge.protectionSpace(), urlToStore);
     234        d->m_context->storageSession(PAL::SessionID::defaultSessionID())->credentialStorage().set(partition, credential, challenge.protectionSpace(), urlToStore);
    235235
    236236        restartRequestWithCredential(challenge.protectionSpace(), credential);
     
    247247            // There is a race condition here, since a different credential might have already been stored by another ResourceHandle,
    248248            // but the observable effect should be very minor, if any.
    249             NetworkStorageSession::defaultStorageSession().credentialStorage().remove(partition, challenge.protectionSpace());
     249            d->m_context->storageSession(PAL::SessionID::defaultSessionID())->credentialStorage().remove(partition, challenge.protectionSpace());
    250250        }
    251251
    252252        if (!challenge.previousFailureCount()) {
    253             Credential credential = NetworkStorageSession::defaultStorageSession().credentialStorage().get(partition, challenge.protectionSpace());
     253            Credential credential = d->m_context->storageSession(PAL::SessionID::defaultSessionID())->credentialStorage().get(partition, challenge.protectionSpace());
    254254            if (!credential.isEmpty() && credential != d->m_initialCredential) {
    255255                ASSERT(credential.persistence() == CredentialPersistenceNone);
    256256                if (challenge.failureResponse().httpStatusCode() == 401) {
    257257                    // Store the credential back, possibly adding it as a default for this directory.
    258                     NetworkStorageSession::defaultStorageSession().credentialStorage().set(partition, credential, challenge.protectionSpace(), challenge.failureResponse().url());
     258                    d->m_context->storageSession(PAL::SessionID::defaultSessionID())->credentialStorage().set(partition, credential, challenge.protectionSpace(), challenge.failureResponse().url());
    259259                }
    260260
     
    290290        if (challenge.failureResponse().httpStatusCode() == 401) {
    291291            URL urlToStore = challenge.failureResponse().url();
    292             NetworkStorageSession::defaultStorageSession().credentialStorage().set(partition, credential, challenge.protectionSpace(), urlToStore);
     292            d->m_context->storageSession(PAL::SessionID::defaultSessionID())->credentialStorage().set(partition, credential, challenge.protectionSpace(), urlToStore);
    293293        }
    294294    }
     
    347347            // <rdar://problem/7174050> - For URLs that match the paths of those previously challenged for HTTP Basic authentication,
    348348            // try and reuse the credential preemptively, as allowed by RFC 2617.
    349             d->m_initialCredential = NetworkStorageSession::defaultStorageSession().credentialStorage().get(partition, request.url());
     349            d->m_initialCredential = d->m_context->storageSession(PAL::SessionID::defaultSessionID())->credentialStorage().get(partition, request.url());
    350350        } else if (!redirect) {
    351351            // If there is already a protection space known for the URL, update stored credentials
     
    353353            // XMLHttpRequest with known incorrect credentials, and aborting it immediately (so that
    354354            // an authentication dialog doesn't pop up).
    355             NetworkStorageSession::defaultStorageSession().credentialStorage().set(partition, credential, request.url());
     355            d->m_context->storageSession(PAL::SessionID::defaultSessionID())->credentialStorage().set(partition, credential, request.url());
    356356        }
    357357    }
  • trunk/Source/WebCore/platform/network/soup/DNSResolveQueueSoup.cpp

    r229359 r240292  
    3434#include <libsoup/soup.h>
    3535#include <wtf/CompletionHandler.h>
     36#include <wtf/Function.h>
    3637#include <wtf/MainThread.h>
     38#include <wtf/NeverDestroyed.h>
    3739#include <wtf/glib/GUniquePtr.h>
    3840#include <wtf/text/CString.h>
     
    7779}
    7880
     81Function<NetworkStorageSession&()>& globalDefaultNetworkStorageSessionAccessor()
     82{
     83    static NeverDestroyed<Function<NetworkStorageSession&()>> accessor;
     84    return accessor.get();
     85}
     86
     87void DNSResolveQueueSoup::setGlobalDefaultNetworkStorageSessionAccessor(Function<NetworkStorageSession&()>&& accessor)
     88{
     89    globalDefaultNetworkStorageSessionAccessor() = WTFMove(accessor);
     90}
     91
    7992void DNSResolveQueueSoup::updateIsUsingProxy()
    8093{
    8194    GRefPtr<GProxyResolver> resolver;
    82     g_object_get(NetworkStorageSession::defaultStorageSession().getOrCreateSoupNetworkSession().soupSession(), "proxy-resolver", &resolver.outPtr(), nullptr);
     95    g_object_get(globalDefaultNetworkStorageSessionAccessor()().getOrCreateSoupNetworkSession().soupSession(), "proxy-resolver", &resolver.outPtr(), nullptr);
    8396    ASSERT(resolver);
    8497
     
    163176    ASSERT(isMainThread());
    164177
    165     soup_session_prefetch_dns(NetworkStorageSession::defaultStorageSession().getOrCreateSoupNetworkSession().soupSession(), hostname.utf8().data(), nullptr, resolvedCallback, nullptr);
     178    soup_session_prefetch_dns(globalDefaultNetworkStorageSessionAccessor()().getOrCreateSoupNetworkSession().soupSession(), hostname.utf8().data(), nullptr, resolvedCallback, nullptr);
    166179}
    167180
     
    172185    auto address = adoptGRef(soup_address_new(hostname.utf8().data(), 0));
    173186    auto cancellable = adoptGRef(g_cancellable_new());
    174     soup_address_resolve_async(address.get(), soup_session_get_async_context(WebCore::NetworkStorageSession::defaultStorageSession().getOrCreateSoupNetworkSession().soupSession()), cancellable.get(), resolvedWithObserverCallback, this);
     187    soup_address_resolve_async(address.get(), soup_session_get_async_context(WebCore::globalDefaultNetworkStorageSessionAccessor()().getOrCreateSoupNetworkSession().soupSession()), cancellable.get(), resolvedWithObserverCallback, this);
    175188
    176189    g_object_set_data(G_OBJECT(address.get()), "identifier", GUINT_TO_POINTER(identifier));
  • trunk/Source/WebCore/platform/network/soup/DNSResolveQueueSoup.h

    r229359 r240292  
    3333namespace WebCore {
    3434
     35class NetworkStorageSession;
     36
    3537class DNSResolveQueueSoup final : public DNSResolveQueue {
    3638public:
     
    3840
    3941    DNSResolveQueueSoup() = default;
     42    static void setGlobalDefaultNetworkStorageSessionAccessor(Function<NetworkStorageSession&()>&&);
    4043    void resolve(const String& hostname, uint64_t identifier, DNSCompletionHandler&&) final;
    4144    void stopResolve(uint64_t identifier) final;
  • trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp

    r239427 r240292  
    6666}
    6767
    68 static std::unique_ptr<NetworkStorageSession>& defaultSession()
    69 {
    70     ASSERT(isMainThread());
    71     static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
    72     return session;
    73 }
    74 
    75 NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
    76 {
    77     if (!defaultSession())
    78         defaultSession() = std::make_unique<NetworkStorageSession>(PAL::SessionID::defaultSessionID(), nullptr);
    79     return *defaultSession();
    80 }
    81 
    82 void NetworkStorageSession::ensureSession(PAL::SessionID sessionID, const String&)
    83 {
    84     ASSERT(!globalSessionMap().contains(sessionID));
    85     globalSessionMap().add(sessionID, std::make_unique<NetworkStorageSession>(sessionID, std::make_unique<SoupNetworkSession>(sessionID)));
    86 }
    87 
    88 void NetworkStorageSession::switchToNewTestingSession()
    89 {
    90     defaultSession() = std::make_unique<NetworkStorageSession>(PAL::SessionID::defaultSessionID(), std::make_unique<SoupNetworkSession>());
    91 }
    92 
    9368SoupNetworkSession& NetworkStorageSession::getOrCreateSoupNetworkSession() const
    9469{
     
    10075void NetworkStorageSession::clearSoupNetworkSessionAndCookieStorage()
    10176{
    102     ASSERT(defaultSession().get() == this);
    10377    m_session = nullptr;
    10478    m_cookieObserverHandler = nullptr;
  • trunk/Source/WebKit/ChangeLog

    r240289 r240292  
     12019-01-22  Alex Christensen  <achristensen@webkit.org>
     2
     3        Move NetworkStorageSession ownership to NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=193580
     5
     6        Reviewed by Geoff Garen.
     7
     8        * NetworkProcess/Cookies/WebCookieManager.cpp:
     9        (WebKit::WebCookieManager::WebCookieManager):
     10        (WebKit::WebCookieManager::getHostnamesWithCookies):
     11        (WebKit::WebCookieManager::deleteCookiesForHostname):
     12        (WebKit::WebCookieManager::deleteAllCookies):
     13        (WebKit::WebCookieManager::deleteCookie):
     14        (WebKit::WebCookieManager::deleteAllCookiesModifiedSince):
     15        (WebKit::WebCookieManager::getAllCookies):
     16        (WebKit::WebCookieManager::getCookies):
     17        (WebKit::WebCookieManager::setCookie):
     18        (WebKit::WebCookieManager::setCookies):
     19        (WebKit::WebCookieManager::startObservingCookieChanges):
     20        (WebKit::WebCookieManager::stopObservingCookieChanges):
     21        * NetworkProcess/Cookies/WebCookieManager.h:
     22        * NetworkProcess/Cookies/mac/WebCookieManagerMac.mm:
     23        (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
     24        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     25        (WebKit::storageSession):
     26        (WebKit::NetworkConnectionToWebProcess::cookiesForDOM):
     27        (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM):
     28        (WebKit::NetworkConnectionToWebProcess::cookiesEnabled):
     29        (WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue):
     30        (WebKit::NetworkConnectionToWebProcess::getRawCookies):
     31        (WebKit::NetworkConnectionToWebProcess::deleteCookie):
     32        (WebKit::NetworkConnectionToWebProcess::removeStorageAccessForFrame):
     33        (WebKit::NetworkConnectionToWebProcess::removeStorageAccessForAllFramesOnPage):
     34        * NetworkProcess/NetworkProcess.cpp:
     35        (WebKit::NetworkProcess::initializeNetworkProcess):
     36        (WebKit::NetworkProcess::clearCachedCredentials):
     37        (WebKit::NetworkProcess::switchToNewTestingSession):
     38        (WebKit::NetworkProcess::ensureSession):
     39        (WebKit::NetworkProcess::storageSession const):
     40        (WebKit::NetworkProcess::defaultStorageSession const):
     41        (WebKit::NetworkProcess::forEachNetworkStorageSession):
     42        (WebKit::NetworkProcess::destroySession):
     43        (WebKit::NetworkProcess::updatePrevalentDomainsToBlockCookiesFor):
     44        (WebKit::NetworkProcess::setAgeCapForClientSideCookies):
     45        (WebKit::NetworkProcess::hasStorageAccessForFrame):
     46        (WebKit::NetworkProcess::getAllStorageAccessEntries):
     47        (WebKit::NetworkProcess::grantStorageAccess):
     48        (WebKit::NetworkProcess::removeAllStorageAccess):
     49        (WebKit::NetworkProcess::removePrevalentDomains):
     50        (WebKit::NetworkProcess::setCacheMaxAgeCapForPrevalentResources):
     51        (WebKit::NetworkProcess::resetCacheMaxAgeCapForPrevalentResources):
     52        (WebKit::NetworkProcess::fetchWebsiteData):
     53        (WebKit::NetworkProcess::deleteWebsiteData):
     54        (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
     55        * NetworkProcess/NetworkProcess.h:
     56        * NetworkProcess/NetworkResourceLoader.cpp:
     57        (WebKit::NetworkResourceLoader::validateCacheEntryForMaxAgeCapValidation):
     58        (WebKit::NetworkResourceLoader::logCookieInformation const):
     59        * NetworkProcess/NetworkSession.cpp:
     60        (WebKit::NetworkSession::networkStorageSession const):
     61        * NetworkProcess/NetworkStorageSessionProvider.h:
     62        * NetworkProcess/cache/NetworkCache.cpp:
     63        (WebKit::NetworkCache::makeUseDecision):
     64        (WebKit::NetworkCache::Cache::retrieve):
     65        (WebKit::NetworkCache::Cache::makeEntry):
     66        (WebKit::NetworkCache::Cache::makeRedirectEntry):
     67        (WebKit::NetworkCache::Cache::update):
     68        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
     69        (WebKit::NetworkCache::SpeculativeLoad::willSendRedirectedRequest):
     70        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
     71        (WebKit::NetworkProcess::platformSyncAllCookies):
     72        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
     73        (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
     74        (-[WKNetworkSessionDelegate URLSession:task:_schemeUpgraded:completionHandler:]):
     75        (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
     76        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
     77        * NetworkProcess/mac/RemoteNetworkingContext.mm:
     78        (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
     79        * SourcesCocoa.txt:
     80        * UIProcess/API/APIHTTPCookieStore.cpp:
     81        (API::HTTPCookieStore::~HTTPCookieStore):
     82        (API::HTTPCookieStore::cookies):
     83        (API::HTTPCookieStore::setCookie):
     84        (API::HTTPCookieStore::deleteCookie):
     85        (API::HTTPCookieStore::registerObserver):
     86        (API::HTTPCookieStore::unregisterObserver):
     87        (API::HTTPCookieStore::registerForNewProcessPoolNotifications):
     88        (API::HTTPCookieStore::flushDefaultUIProcessCookieStore):
     89        (API::HTTPCookieStore::getAllDefaultUIProcessCookieStoreCookies):
     90        (API::HTTPCookieStore::setCookieInDefaultUIProcessCookieStore):
     91        (API::HTTPCookieStore::deleteCookieFromDefaultUIProcessCookieStore):
     92        (API::HTTPCookieStore::startObservingChangesToDefaultUIProcessCookieStore):
     93        (API::HTTPCookieStore::stopObservingChangesToDefaultUIProcessCookieStore):
     94        * UIProcess/API/APIHTTPCookieStore.h:
     95        * UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm: Added.
     96        (API::HTTPCookieStore::flushDefaultUIProcessCookieStore):
     97        (API::HTTPCookieStore::getAllDefaultUIProcessCookieStoreCookies):
     98        (API::HTTPCookieStore::setCookieInDefaultUIProcessCookieStore):
     99        (API::HTTPCookieStore::deleteCookieFromDefaultUIProcessCookieStore):
     100        (API::HTTPCookieStore::startObservingChangesToDefaultUIProcessCookieStore):
     101        (API::HTTPCookieStore::stopObservingChangesToDefaultUIProcessCookieStore):
     102        * UIProcess/WebProcessPool.cpp:
     103        (WebKit::WebProcessPool::clearCachedCredentials):
     104        * WebKit.xcodeproj/project.pbxproj:
     105        * WebProcess/Plugins/PluginView.cpp:
     106        (WebKit::PluginView::getAuthenticationInfo):
     107        * WebProcess/WebProcess.cpp:
     108        (WebKit::WebProcess::deleteWebsiteData):
     109        (WebKit::WebProcess::clearCachedCredentials): Deleted.
     110        * WebProcess/WebProcess.h:
     111        * WebProcess/WebProcess.messages.in:
     112
    11132019-01-22  Per Arne Vollan  <pvollan@apple.com>
    2114
  • trunk/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp

    r238771 r240292  
    4747}
    4848
    49 WebCookieManager::WebCookieManager(ChildProcess& process)
     49WebCookieManager::WebCookieManager(NetworkProcess& process)
    5050    : m_process(process)
    5151{
     
    5858{
    5959    HashSet<String> hostnames;
    60     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     60    if (auto* storageSession = m_process.storageSession(sessionID))
    6161        storageSession->getHostnamesWithCookies(hostnames);
    6262
     
    6666void WebCookieManager::deleteCookiesForHostname(PAL::SessionID sessionID, const String& hostname)
    6767{
    68     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     68    if (auto* storageSession = m_process.storageSession(sessionID))
    6969        storageSession->deleteCookiesForHostnames({ hostname });
    7070}
     
    7373void WebCookieManager::deleteAllCookies(PAL::SessionID sessionID)
    7474{
    75     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     75    if (auto* storageSession = m_process.storageSession(sessionID))
    7676        storageSession->deleteAllCookies();
    7777}
     
    7979void WebCookieManager::deleteCookie(PAL::SessionID sessionID, const Cookie& cookie, CallbackID callbackID)
    8080{
    81     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     81    if (auto* storageSession = m_process.storageSession(sessionID))
    8282        storageSession->deleteCookie(cookie);
    8383
     
    8787void WebCookieManager::deleteAllCookiesModifiedSince(PAL::SessionID sessionID, WallTime time, CallbackID callbackID)
    8888{
    89     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     89    if (auto* storageSession = m_process.storageSession(sessionID))
    9090        storageSession->deleteAllCookiesModifiedSince(time);
    9191
     
    9696{
    9797    Vector<Cookie> cookies;
    98     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     98    if (auto* storageSession = m_process.storageSession(sessionID))
    9999        cookies = storageSession->getAllCookies();
    100100
     
    105105{
    106106    Vector<Cookie> cookies;
    107     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     107    if (auto* storageSession = m_process.storageSession(sessionID))
    108108        cookies = storageSession->getCookies(url);
    109109
     
    113113void WebCookieManager::setCookie(PAL::SessionID sessionID, const Cookie& cookie, CallbackID callbackID)
    114114{
    115     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     115    if (auto* storageSession = m_process.storageSession(sessionID))
    116116        storageSession->setCookie(cookie);
    117117
     
    121121void WebCookieManager::setCookies(PAL::SessionID sessionID, const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL, CallbackID callbackID)
    122122{
    123     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     123    if (auto* storageSession = m_process.storageSession(sessionID))
    124124        storageSession->setCookies(cookies, url, mainDocumentURL);
    125125
     
    135135void WebCookieManager::startObservingCookieChanges(PAL::SessionID sessionID)
    136136{
    137     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID)) {
     137    if (auto* storageSession = m_process.storageSession(sessionID)) {
    138138        WebCore::startObservingCookieChanges(*storageSession, [this, sessionID] {
    139139            notifyCookiesDidChange(sessionID);
     
    144144void WebCookieManager::stopObservingCookieChanges(PAL::SessionID sessionID)
    145145{
    146     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     146    if (auto* storageSession = m_process.storageSession(sessionID))
    147147        WebCore::stopObservingCookieChanges(*storageSession);
    148148}
  • trunk/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.h

    r239624 r240292  
    4646namespace WebKit {
    4747
    48 class ChildProcess;
     48class NetworkProcess;
    4949
    5050class WebCookieManager : public NetworkProcessSupplement, public IPC::MessageReceiver {
    5151    WTF_MAKE_NONCOPYABLE(WebCookieManager);
    5252public:
    53     WebCookieManager(ChildProcess&);
     53    WebCookieManager(NetworkProcess&);
    5454    ~WebCookieManager();
    5555
     
    8787    void stopObservingCookieChanges(PAL::SessionID);
    8888
    89     ChildProcess& m_process;
     89    NetworkProcess& m_process;
    9090};
    9191
  • trunk/Source/WebKit/NetworkProcess/Cookies/mac/WebCookieManagerMac.mm

    r239143 r240292  
    2727#import "WebCookieManager.h"
    2828
     29#import "NetworkProcess.h"
    2930#import "NetworkSession.h"
    3031#import <WebCore/NetworkStorageSession.h>
     
    4142    [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:static_cast<NSHTTPCookieAcceptPolicy>(policy)];
    4243
    43     NetworkStorageSession::forEach([&] (const NetworkStorageSession& networkStorageSession) {
     44    m_process.forEachNetworkStorageSession([&] (const auto& networkStorageSession) {
    4445        if (auto cookieStorage = networkStorageSession.cookieStorage())
    4546            CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
  • trunk/Source/WebKit/NetworkProcess/Cookies/soup/WebCookieManagerSoup.cpp

    r229426 r240292  
    2828
    2929#include "ChildProcess.h"
     30#include "NetworkProcess.h"
    3031#include <WebCore/NetworkStorageSession.h>
    3132#include <WebCore/SoupNetworkSession.h>
     
    5253    }
    5354
    54     NetworkStorageSession::forEach([soupPolicy] (const NetworkStorageSession& session) {
     55    m_process.forEachNetworkStorageSession([soupPolicy] (const auto& session) {
    5556        soup_cookie_jar_set_accept_policy(session.cookieStorage(), soupPolicy);
    5657    });
     
    5960HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy()
    6061{
    61     switch (soup_cookie_jar_get_accept_policy(NetworkStorageSession::defaultStorageSession().cookieStorage())) {
     62    switch (soup_cookie_jar_get_accept_policy(m_process.defaultStorageSession().cookieStorage())) {
    6263    case SOUP_COOKIE_JAR_ACCEPT_ALWAYS:
    6364        return HTTPCookieAcceptPolicyAlways;
     
    8687    }
    8788
    88     auto& storageSession = NetworkStorageSession::defaultStorageSession();
     89    auto& storageSession = m_process.defaultStorageSession();
    8990    soup_cookie_jar_set_accept_policy(jar.get(), soup_cookie_jar_get_accept_policy(storageSession.cookieStorage()));
    9091    storageSession.setCookieStorage(jar.get());
  • trunk/Source/WebKit/NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h

    r240030 r240292  
    9797#if PLATFORM(COCOA)
    9898    void registerProtocolClass(NSURLSessionConfiguration*);
     99#endif
     100#if PLATFORM(COCOA) || USE(SOUP)
    99101    static void networkProcessCreated(NetworkProcess&);
    100102#endif
  • trunk/Source/WebKit/NetworkProcess/CustomProtocols/soup/LegacyCustomProtocolManagerSoup.cpp

    r228373 r240292  
    3737using namespace WebCore;
    3838
     39RefPtr<NetworkProcess>& lastCreatedNetworkProcess()
     40{
     41    static NeverDestroyed<RefPtr<NetworkProcess>> networkProcess;
     42    return networkProcess.get();
     43}
     44
     45void LegacyCustomProtocolManager::networkProcessCreated(NetworkProcess& networkProcess)
     46{
     47    lastCreatedNetworkProcess() = &networkProcess;
     48}
     49
    3950LegacyCustomProtocolManager::WebSoupRequestAsyncData::WebSoupRequestAsyncData(GRefPtr<GTask>&& requestTask, WebKitSoupRequestGeneric* requestGeneric)
    4051    : task(WTFMove(requestTask))
     
    92103    ASSERT(genericRequestClass);
    93104    genericRequestClass->schemes = const_cast<const char**>(reinterpret_cast<char**>(m_registeredSchemes->pdata));
    94     NetworkStorageSession::forEach([](const WebCore::NetworkStorageSession& session) {
     105    lastCreatedNetworkProcess()->forEachNetworkStorageSession([](const auto& session) {
    95106        if (auto* soupSession = session.soupNetworkSession())
    96107            soupSession->setupCustomProtocols();
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r240243 r240292  
    409409}
    410410
    411 static NetworkStorageSession& storageSession(PAL::SessionID sessionID)
     411static NetworkStorageSession& storageSession(const NetworkProcess& networkProcess, PAL::SessionID sessionID)
    412412{
    413413    ASSERT(sessionID.isValid());
    414414    if (sessionID != PAL::SessionID::defaultSessionID()) {
    415         if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     415        if (auto* storageSession = networkProcess.storageSession(sessionID))
    416416            return *storageSession;
    417417
     
    420420        LOG_ERROR("Non-default storage session was requested, but there was no session for it. Please file a bug unless you just disabled private browsing, in which case it's an expected race.");
    421421    }
    422     return NetworkStorageSession::defaultStorageSession();
     422    return networkProcess.defaultStorageSession();
    423423}
    424424
     
    449449void NetworkConnectionToWebProcess::cookiesForDOM(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<uint64_t> frameID, Optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies, String& cookieString, bool& secureCookiesAccessed)
    450450{
    451     auto& networkStorageSession = storageSession(sessionID);
     451    auto& networkStorageSession = storageSession(networkProcess(), sessionID);
    452452    std::tie(cookieString, secureCookiesAccessed) = networkStorageSession.cookiesForDOM(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies);
    453453#if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
     
    461461void NetworkConnectionToWebProcess::setCookiesFromDOM(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<uint64_t> frameID, Optional<uint64_t> pageID, const String& cookieString)
    462462{
    463     auto& networkStorageSession = storageSession(sessionID);
     463    auto& networkStorageSession = storageSession(networkProcess(), sessionID);
    464464    networkStorageSession.setCookiesFromDOM(firstParty, sameSiteInfo, url, frameID, pageID, cookieString);
    465465#if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
     
    473473void NetworkConnectionToWebProcess::cookiesEnabled(PAL::SessionID sessionID, bool& result)
    474474{
    475     result = storageSession(sessionID).cookiesEnabled();
     475    result = storageSession(networkProcess(), sessionID).cookiesEnabled();
    476476}
    477477
    478478void NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<uint64_t> frameID, Optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies, String& cookieString, bool& secureCookiesAccessed)
    479479{
    480     std::tie(cookieString, secureCookiesAccessed) = storageSession(sessionID).cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies);
     480    std::tie(cookieString, secureCookiesAccessed) = storageSession(networkProcess(), sessionID).cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies);
    481481}
    482482
    483483void NetworkConnectionToWebProcess::getRawCookies(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<uint64_t> frameID, Optional<uint64_t> pageID, Vector<Cookie>& result)
    484484{
    485     storageSession(sessionID).getRawCookies(firstParty, sameSiteInfo, url, frameID, pageID, result);
     485    storageSession(networkProcess(), sessionID).getRawCookies(firstParty, sameSiteInfo, url, frameID, pageID, result);
    486486}
    487487
    488488void NetworkConnectionToWebProcess::deleteCookie(PAL::SessionID sessionID, const URL& url, const String& cookieName)
    489489{
    490     storageSession(sessionID).deleteCookie(url, cookieName);
     490    storageSession(networkProcess(), sessionID).deleteCookie(url, cookieName);
    491491}
    492492
     
    563563{
    564564#if ENABLE(RESOURCE_LOAD_STATISTICS)
    565     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     565    if (auto* storageSession = networkProcess().storageSession(sessionID))
    566566        storageSession->removeStorageAccessForFrame(frameID, pageID);
    567567#else
     
    575575{
    576576#if ENABLE(RESOURCE_LOAD_STATISTICS)
    577     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
     577    if (auto* storageSession = networkProcess().storageSession(sessionID))
    578578        storageSession->removeStorageAccessForAllFramesOnPage(pageID);
    579579#else
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r240243 r240292  
    9292#endif
    9393
     94#if USE(SOUP)
     95#include <WebCore/DNSResolveQueueSoup.h>
     96#endif
     97
    9498#if ENABLE(SERVICE_WORKER)
    9599#include "WebSWServerToContextConnectionMessages.h"
     
    143147#if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
    144148    addSupplement<LegacyCustomProtocolManager>();
    145 #if PLATFORM(COCOA)
     149#endif
     150#if PLATFORM(COCOA) || USE(SOUP)
    146151    LegacyCustomProtocolManager::networkProcessCreated(*this);
    147 #endif
    148152#endif
    149153#if ENABLE(PROXIMITY_NETWORKING)
    150154    addSupplement<NetworkProximityManager>();
     155#endif
     156
     157#if USE(SOUP)
     158    DNSResolveQueueSoup::setGlobalDefaultNetworkStorageSessionAccessor([this] {
     159        return defaultStorageSession();
     160    });
     161    defaultStorageSession().clearSoupNetworkSessionAndCookieStorage();
    151162#endif
    152163
     
    303314
    304315    if (parameters.shouldUseTestingNetworkSession)
    305         NetworkStorageSession::switchToNewTestingSession();
     316        switchToNewTestingSession();
    306317
    307318    SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectoryExtensionHandle);
     
    437448void NetworkProcess::clearCachedCredentials()
    438449{
    439     NetworkStorageSession::defaultStorageSession().credentialStorage().clearCredentials();
     450    defaultStorageSession().credentialStorage().clearCredentials();
    440451    if (auto* networkSession = this->networkSession(PAL::SessionID::defaultSessionID()))
    441452        networkSession->clearCredentials();
     
    458469}
    459470
     471void NetworkProcess::switchToNewTestingSession()
     472{
     473    // Session name should be short enough for shared memory region name to be under the limit, otehrwise sandbox rules won't work (see <rdar://problem/13642852>).
     474    String sessionName = String::format("WebKit Test-%u", static_cast<uint32_t>(getCurrentProcessID()));
     475
     476    auto session = adoptCF(WebCore::createPrivateStorageSession(sessionName.createCFString().get()));
     477
     478#if PLATFORM(COCOA)
     479    RetainPtr<CFHTTPCookieStorageRef> cookieStorage;
     480    if (WebCore::NetworkStorageSession::processMayUseCookieAPI()) {
     481        ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
     482        if (session)
     483            cookieStorage = adoptCF(_CFURLStorageSessionCopyCookieStorage(kCFAllocatorDefault, session.get()));
     484    }
     485
     486    m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID(), WTFMove(session), WTFMove(cookieStorage));
     487#elif USE(SOUP)
     488    m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID(), std::make_unique<WebCore::SoupNetworkSession>());
     489#endif
     490}
     491
     492#if PLATFORM(COCOA)
     493void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, const String& identifierBase, RetainPtr<CFHTTPCookieStorageRef>&& cookieStorage)
     494#else
     495void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, const String& identifierBase)
     496#endif
     497{
     498    auto addResult = m_networkStorageSessions.add(sessionID, nullptr);
     499    if (!addResult.isNewEntry)
     500        return;
     501
     502#if PLATFORM(COCOA)
     503    RetainPtr<CFURLStorageSessionRef> storageSession;
     504    RetainPtr<CFStringRef> cfIdentifier = String(identifierBase + ".PrivateBrowsing").createCFString();
     505    if (sessionID.isEphemeral())
     506        storageSession = adoptCF(createPrivateStorageSession(cfIdentifier.get()));
     507    else
     508        storageSession = WebCore::NetworkStorageSession::createCFStorageSessionForIdentifier(cfIdentifier.get());
     509
     510    if (NetworkStorageSession::processMayUseCookieAPI()) {
     511        ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
     512        if (!cookieStorage && storageSession)
     513            cookieStorage = adoptCF(_CFURLStorageSessionCopyCookieStorage(kCFAllocatorDefault, storageSession.get()));
     514    }
     515
     516    addResult.iterator->value = std::make_unique<NetworkStorageSession>(sessionID, WTFMove(storageSession), WTFMove(cookieStorage));
     517#elif USE(SOUP)
     518    addResult.iterator->value = std::make_unique<NetworkStorageSession>(sessionID, std::make_unique<SoupNetworkSession>(sessionID));
     519#endif
     520}
     521
     522WebCore::NetworkStorageSession* NetworkProcess::storageSession(const PAL::SessionID& sessionID) const
     523{
     524    if (sessionID == PAL::SessionID::defaultSessionID())
     525        return &defaultStorageSession();
     526    return m_networkStorageSessions.get(sessionID);
     527}
     528
     529WebCore::NetworkStorageSession& NetworkProcess::defaultStorageSession() const
     530{
     531    if (!m_defaultNetworkStorageSession)
     532        m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID());
     533    return *m_defaultNetworkStorageSession;
     534}
     535
     536void NetworkProcess::forEachNetworkStorageSession(const Function<void(WebCore::NetworkStorageSession&)>& functor)
     537{
     538    functor(defaultStorageSession());
     539    for (auto& storageSession : m_networkStorageSessions.values())
     540        functor(*storageSession);
     541}
     542
    460543NetworkSession* NetworkProcess::networkSession(const PAL::SessionID& sessionID) const
    461544{
     
    472555    if (auto session = m_networkSessions.take(sessionID))
    473556        session->get().invalidateAndCancel();
    474     NetworkStorageSession::destroySession(sessionID);
     557    m_networkStorageSessions.remove(sessionID);
    475558    m_sessionsControlledByAutomation.remove(sessionID);
    476559    CacheStorage::Engine::destroyEngine(*this, sessionID);
     
    512595void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, uint64_t contextId)
    513596{
    514     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     597    if (auto* networkStorageSession = storageSession(sessionID))
    515598        networkStorageSession->setPrevalentDomainsToBlockCookiesFor(domainsToBlock);
    516599    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateBlockCookies(contextId), 0);
     
    546629void NetworkProcess::setAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, uint64_t contextId)
    547630{
    548     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     631    if (auto* networkStorageSession = storageSession(sessionID))
    549632        networkStorageSession->setAgeCapForClientSideCookies(seconds);
    550633    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetAgeCapForClientSideCookies(contextId), 0);
     
    757840void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
    758841{
    759     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     842    if (auto* networkStorageSession = storageSession(sessionID))
    760843        parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessOperationResult(networkStorageSession->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID), contextId), 0);
    761844    else
     
    765848void NetworkProcess::getAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
    766849{
    767     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     850    if (auto* networkStorageSession = storageSession(sessionID))
    768851        parentProcessConnection()->send(Messages::NetworkProcessProxy::AllStorageAccessEntriesResult(networkStorageSession->getAllStorageAccessEntries(), contextId), 0);
    769852    else
     
    795878{
    796879    bool isStorageGranted = false;
    797     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) {
     880    if (auto* networkStorageSession = storageSession(sessionID)) {
    798881        networkStorageSession->grantStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID);
    799882        ASSERT(networkStorageSession->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID));
     
    844927void NetworkProcess::removeAllStorageAccess(PAL::SessionID sessionID, uint64_t contextId)
    845928{
    846     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     929    if (auto* networkStorageSession = storageSession(sessionID))
    847930        networkStorageSession->removeAllStorageAccess();
    848931    else
     
    853936void NetworkProcess::removePrevalentDomains(PAL::SessionID sessionID, const Vector<String>& domains)
    854937{
    855     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     938    if (auto* networkStorageSession = storageSession(sessionID))
    856939        networkStorageSession->removePrevalentDomains(domains);
    857940}
     
    859942void NetworkProcess::setCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId)
    860943{
    861     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     944    if (auto* networkStorageSession = storageSession(sessionID))
    862945        networkStorageSession->setCacheMaxAgeCapForPrevalentResources(Seconds { seconds });
    863946    else
     
    9371020void NetworkProcess::resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, uint64_t contextId)
    9381021{
    939     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1022    if (auto* networkStorageSession = storageSession(sessionID))
    9401023        networkStorageSession->resetCacheMaxAgeCapForPrevalentResources();
    9411024    else
     
    10141097
    10151098    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
    1016         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1099        if (auto* networkStorageSession = storageSession(sessionID))
    10171100            networkStorageSession->getHostnamesWithCookies(callbackAggregator->m_websiteData.hostNamesWithCookies);
    10181101    }
    10191102
    10201103    if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
    1021         if (NetworkStorageSession::storageSession(sessionID))
    1022             callbackAggregator->m_websiteData.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials();
     1104        if (storageSession(sessionID))
     1105            callbackAggregator->m_websiteData.originsWithCredentials = storageSession(sessionID)->credentialStorage().originsWithCredentials();
    10231106    }
    10241107
     
    10311114#if PLATFORM(COCOA)
    10321115    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1033         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1116        if (auto* networkStorageSession = storageSession(sessionID))
    10341117            getHostNamesWithHSTSCache(*networkStorageSession, callbackAggregator->m_websiteData.hostNamesWithHSTSCache);
    10351118    }
     
    10701153#if PLATFORM(COCOA)
    10711154    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1072         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1155        if (auto* networkStorageSession = storageSession(sessionID))
    10731156            clearHSTSCache(*networkStorageSession, modifiedSince);
    10741157    }
     
    10761159
    10771160    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
    1078         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1161        if (auto* networkStorageSession = storageSession(sessionID))
    10791162            networkStorageSession->deleteAllCookiesModifiedSince(modifiedSince);
    10801163    }
    10811164
    10821165    if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
    1083         if (NetworkStorageSession::storageSession(sessionID))
    1084             NetworkStorageSession::storageSession(sessionID)->credentialStorage().clearCredentials();
     1166        if (auto* session = storageSession(sessionID))
     1167            session->credentialStorage().clearCredentials();
    10851168    }
    10861169
     
    11501233{
    11511234    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
    1152         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1235        if (auto* networkStorageSession = storageSession(sessionID))
    11531236            networkStorageSession->deleteCookiesForHostnames(cookieHostNames);
    11541237    }
     
    11561239#if PLATFORM(COCOA)
    11571240    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1158         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1241        if (auto* networkStorageSession = storageSession(sessionID))
    11591242            deleteHSTSCacheForHostNames(*networkStorageSession, HSTSCacheHostNames);
    11601243    }
     
    12541337    Vector<String> hostnamesWithCookiesToDelete;
    12551338    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
    1256         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) {
     1339        if (auto* networkStorageSession = storageSession(sessionID)) {
    12571340            networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies);
    12581341            hostnamesWithCookiesToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithCookies);
     
    12641347#if PLATFORM(COCOA)
    12651348    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1266         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) {
     1349        if (auto* networkStorageSession = storageSession(sessionID)) {
    12671350            getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache);
    12681351            hostnamesWithHSTSToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithHSTSCache);
     
    12751358    // FIXME: No API to delete credentials by origin
    12761359    if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
    1277         if (NetworkStorageSession::storageSession(sessionID))
    1278             websiteDataStore.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials();
     1360        if (storageSession(sessionID))
     1361            websiteDataStore.originsWithCredentials = storageSession(sessionID)->credentialStorage().originsWithCredentials();
    12791362    }
    12801363    */
     
    13861469    Vector<String> hostnamesWithCookiesToDelete;
    13871470    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
    1388         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1471        if (auto* networkStorageSession = storageSession(sessionID))
    13891472            networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies);
    13901473    }
     
    13931476#if PLATFORM(COCOA)
    13941477    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1395         if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1478        if (auto* networkStorageSession = storageSession(sessionID))
    13961479            getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache);
    13971480    }
     
    13991482
    14001483    if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
    1401         if (NetworkStorageSession::storageSession(sessionID))
    1402             websiteDataStore.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials();
     1484        if (auto* networkStorageSession = storageSession(sessionID))
     1485            websiteDataStore.originsWithCredentials = networkStorageSession->credentialStorage().originsWithCredentials();
    14031486    }
    14041487   
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r240243 r240292  
    4747#include <wtf/WeakPtr.h>
    4848
     49#if PLATFORM(COCOA)
     50typedef struct OpaqueCFHTTPCookieStorage*  CFHTTPCookieStorageRef;
     51#endif
     52
    4953namespace IPC {
    5054class FormDataReference;
     
    133137    void destroySession(const PAL::SessionID&);
    134138   
     139    void forEachNetworkStorageSession(const Function<void(WebCore::NetworkStorageSession&)>&);
     140    WebCore::NetworkStorageSession* storageSession(const PAL::SessionID&) const;
     141    WebCore::NetworkStorageSession& defaultStorageSession() const;
     142    void switchToNewTestingSession();
     143#if PLATFORM(COCOA)
     144    void ensureSession(const PAL::SessionID&, const String& identifier, RetainPtr<CFHTTPCookieStorageRef>&&);
     145#else
     146    void ensureSession(const PAL::SessionID&, const String& identifier);
     147#endif
     148
    135149    bool canHandleHTTPSServerTrustEvaluation() const { return m_canHandleHTTPSServerTrustEvaluation; }
    136150
     
    427441    HashMap<PAL::SessionID, Vector<CacheStorageParametersCallback>> m_cacheStorageParametersCallbacks;
    428442    HashMap<PAL::SessionID, Ref<NetworkSession>> m_networkSessions;
     443    HashMap<PAL::SessionID, std::unique_ptr<WebCore::NetworkStorageSession>> m_networkStorageSessions;
     444    mutable std::unique_ptr<WebCore::NetworkStorageSession> m_defaultNetworkStorageSession;
    429445
    430446#if PLATFORM(COCOA)
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r240089 r240292  
    610610   
    611611    if (!existingCacheEntryMatchesNewResponse) {
    612         if (auto networkStorageSession = WebCore::NetworkStorageSession::storageSession(sessionID()))
     612        if (auto* networkStorageSession = m_connection->networkProcess().storageSession(sessionID()))
    613613            return networkStorageSession->maxAgeCacheCap(request);
    614614    }
     
    971971    ASSERT(shouldLogCookieInformation(m_connection, sessionID()));
    972972
    973     auto networkStorageSession = WebCore::NetworkStorageSession::storageSession(sessionID());
     973    auto* networkStorageSession = m_connection->networkProcess().storageSession(sessionID());
    974974    ASSERT(networkStorageSession);
    975975
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r240243 r240292  
    6161NetworkStorageSession& NetworkSession::networkStorageSession() const
    6262{
    63     auto* storageSession = NetworkStorageSession::storageSession(m_sessionID);
     63    auto* storageSession = m_networkProcess->storageSession(m_sessionID);
    6464    RELEASE_ASSERT(storageSession);
    6565    return *storageSession;
  • trunk/Source/WebKit/NetworkProcess/NetworkStorageSessionProvider.h

    r240117 r240292  
    4646    {
    4747        if (m_networkProcess)
    48             return WebCore::NetworkStorageSession::storageSession(m_sessionID);
     48            return m_networkProcess->storageSession(m_sessionID);
    4949        return nullptr;
    5050    }
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp

    r239974 r240292  
    3131#include "NetworkCacheStatistics.h"
    3232#include "NetworkCacheStorage.h"
     33#include "NetworkProcess.h"
    3334#include <WebCore/CacheValidation.h>
    3435#include <WebCore/FileSystem.h>
     
    185186}
    186187
    187 static UseDecision makeUseDecision(const Entry& entry, const WebCore::ResourceRequest& request)
     188static UseDecision makeUseDecision(NetworkProcess& networkProcess, const Entry& entry, const WebCore::ResourceRequest& request)
    188189{
    189190    // The request is conditional so we force revalidation from the network. We merely check the disk cache
     
    192193        return UseDecision::Validate;
    193194
    194     if (!WebCore::verifyVaryingRequestHeaders(WebCore::NetworkStorageSession::defaultStorageSession(), entry.varyingRequestHeaders(), request))
     195    if (!WebCore::verifyVaryingRequestHeaders(networkProcess.defaultStorageSession(), entry.varyingRequestHeaders(), request))
    195196        return UseDecision::NoDueToVaryingHeaderMismatch;
    196197
     
    306307#if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
    307308    if (canUseSpeculativeRevalidation && m_speculativeLoadManager->canRetrieve(storageKey, request, frameID)) {
    308         m_speculativeLoadManager->retrieve(storageKey, [request, completionHandler = WTFMove(completionHandler), info = WTFMove(info)](std::unique_ptr<Entry> entry) mutable {
     309        m_speculativeLoadManager->retrieve(storageKey, [networkProcess = makeRef(networkProcess()), request, completionHandler = WTFMove(completionHandler), info = WTFMove(info)](std::unique_ptr<Entry> entry) mutable {
    309310            info.wasSpeculativeLoad = true;
    310             if (entry && WebCore::verifyVaryingRequestHeaders(WebCore::NetworkStorageSession::defaultStorageSession(), entry->varyingRequestHeaders(), request))
     311            if (entry && WebCore::verifyVaryingRequestHeaders(networkProcess->defaultStorageSession(), entry->varyingRequestHeaders(), request))
    311312                completeRetrieve(WTFMove(completionHandler), WTFMove(entry), info);
    312313            else
     
    334335        auto entry = Entry::decodeStorageRecord(*record);
    335336
    336         auto useDecision = entry ? makeUseDecision(*entry, request) : UseDecision::NoDueToDecodeFailure;
     337        auto useDecision = entry ? makeUseDecision(networkProcess(), *entry, request) : UseDecision::NoDueToDecodeFailure;
    337338        switch (useDecision) {
    338339        case UseDecision::Use:
     
    365366std::unique_ptr<Entry> Cache::makeEntry(const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response, RefPtr<WebCore::SharedBuffer>&& responseData)
    366367{
    367     return std::make_unique<Entry>(makeCacheKey(request), response, WTFMove(responseData), WebCore::collectVaryingRequestHeaders(WebCore::NetworkStorageSession::defaultStorageSession(), request, response));
     368    return std::make_unique<Entry>(makeCacheKey(request), response, WTFMove(responseData), WebCore::collectVaryingRequestHeaders(networkProcess().defaultStorageSession(), request, response));
    368369}
    369370
    370371std::unique_ptr<Entry> Cache::makeRedirectEntry(const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& redirectRequest)
    371372{
    372     return std::make_unique<Entry>(makeCacheKey(request), response, redirectRequest, WebCore::collectVaryingRequestHeaders(WebCore::NetworkStorageSession::defaultStorageSession(), request, response));
     373    return std::make_unique<Entry>(makeCacheKey(request), response, redirectRequest, WebCore::collectVaryingRequestHeaders(networkProcess().defaultStorageSession(), request, response));
    373374}
    374375
     
    454455    WebCore::updateResponseHeadersAfterRevalidation(response, validatingResponse);
    455456
    456     auto updateEntry = std::make_unique<Entry>(existingEntry.key(), response, existingEntry.buffer(), WebCore::collectVaryingRequestHeaders(WebCore::NetworkStorageSession::defaultStorageSession(), originalRequest, response));
     457    auto updateEntry = std::make_unique<Entry>(existingEntry.key(), response, existingEntry.buffer(), WebCore::collectVaryingRequestHeaders(networkProcess().defaultStorageSession(), originalRequest, response));
    457458    auto updateRecord = updateEntry->encodeAsStorageRecord();
    458459
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp

    r239815 r240292  
    7575    Optional<Seconds> maxAgeCap;
    7676#if ENABLE(RESOURCE_LOAD_STATISTICS)
    77     if (auto networkStorageSession = WebCore::NetworkStorageSession::storageSession(PAL::SessionID::defaultSessionID()))
     77    if (auto* networkStorageSession = m_cache->networkProcess().storageSession(PAL::SessionID::defaultSessionID()))
    7878        maxAgeCap = networkStorageSession->maxAgeCacheCap(request);
    7979#endif
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm

    r239815 r240292  
    232232#if HAVE(FOUNDATION_WITH_SAVE_COOKIES_WITH_COMPLETION_HANDLER)
    233233    RefPtr<CallbackAggregator> callbackAggregator = CallbackAggregator::create(WTFMove(completionHander));
    234     WebCore::NetworkStorageSession::forEach([&] (auto& networkStorageSession) {
     234    forEachNetworkStorageSession([&] (auto& networkStorageSession) {
    235235        saveCookies(networkStorageSession.nsCookieStorage(), [callbackAggregator] { });
    236236    });
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

    r240243 r240292  
    448448        bool shouldIgnoreHSTS = false;
    449449#if HAVE(CFNETWORK_WITH_IGNORE_HSTS) && ENABLE(RESOURCE_LOAD_STATISTICS)       
    450         shouldIgnoreHSTS = schemeWasUpgradedDueToDynamicHSTS(request) && WebCore::NetworkStorageSession::storageSession(_session->sessionID())->shouldBlockCookies(request, networkDataTask->frameID(), networkDataTask->pageID());
     450        shouldIgnoreHSTS = schemeWasUpgradedDueToDynamicHSTS(request) && _session->networkProcess().storageSession(_session->sessionID())->shouldBlockCookies(request, networkDataTask->frameID(), networkDataTask->pageID());
    451451        if (shouldIgnoreHSTS) {
    452452            request = downgradeRequest(request);
     
    481481        bool shouldIgnoreHSTS = false;
    482482#if HAVE(CFNETWORK_WITH_IGNORE_HSTS) && ENABLE(RESOURCE_LOAD_STATISTICS)
    483         shouldIgnoreHSTS = schemeWasUpgradedDueToDynamicHSTS(request) && WebCore::NetworkStorageSession::storageSession(_session->sessionID())->shouldBlockCookies(request, networkDataTask->frameID(), networkDataTask->pageID());
     483        shouldIgnoreHSTS = schemeWasUpgradedDueToDynamicHSTS(request) && _session->networkProcess().storageSession(_session->sessionID())->shouldBlockCookies(request, networkDataTask->frameID(), networkDataTask->pageID());
    484484        if (shouldIgnoreHSTS) {
    485485            request = downgradeRequest(request);
     
    552552        auto completionHandlerCopy = Block_copy(completionHandler);
    553553        auto sessionID = _session->sessionID();
    554         auto challengeCompletionHandler = [completionHandlerCopy, sessionID, authenticationChallenge, taskIdentifier, partition = networkDataTask->partition()](WebKit::AuthenticationChallengeDisposition disposition, const WebCore::Credential& credential)
     554        auto challengeCompletionHandler = [networkProcess = makeRef(_session->networkProcess()), completionHandlerCopy, sessionID, authenticationChallenge, taskIdentifier, partition = networkDataTask->partition()](WebKit::AuthenticationChallengeDisposition disposition, const WebCore::Credential& credential)
    555555        {
    556556#if !LOG_DISABLED
     
    569569                if (authenticationChallenge.failureResponse().httpStatusCode() == 401)
    570570                    urlToStore = authenticationChallenge.failureResponse().url();
    571                 if (auto storageSession = WebCore::NetworkStorageSession::storageSession(sessionID))
     571                if (auto storageSession = networkProcess->storageSession(sessionID))
    572572                    storageSession->credentialStorage().set(partition, nonPersistentCredential, authenticationChallenge.protectionSpace(), urlToStore);
    573573                else
     
    917917#endif
    918918
    919     auto* storageSession = WebCore::NetworkStorageSession::storageSession(parameters.sessionID);
     919    auto* storageSession = networkProcess.storageSession(parameters.sessionID);
    920920    RELEASE_ASSERT(storageSession);
    921921
  • trunk/Source/WebKit/NetworkProcess/curl/RemoteNetworkingContextCurl.cpp

    r239815 r240292  
    3939{
    4040    auto sessionID = parameters.networkSessionParameters.sessionID;
    41     if (NetworkStorageSession::storageSession(sessionID))
     41    if (networkProcess.storageSession(sessionID))
    4242        return;
    4343
    44     NetworkStorageSession::ensureSession(sessionID, String::number(sessionID.sessionID()));
     44    networkProcess.ensureSession(sessionID, String::number(sessionID.sessionID()));
    4545    networkProcess.setSession(sessionID, NetworkSession::create(networkProcess, WTFMove(parameters.networkSessionParameters)));
    4646}
  • trunk/Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm

    r239815 r240292  
    4545{
    4646    auto sessionID = parameters.networkSessionParameters.sessionID;
    47     if (NetworkStorageSession::storageSession(sessionID))
     47    if (networkProcess.storageSession(sessionID))
    4848        return;
    4949
     
    5959        uiProcessCookieStorage = cookieStorageFromIdentifyingData(parameters.uiProcessCookieStorageIdentifier);
    6060
    61     NetworkStorageSession::ensureSession(sessionID, base + '.' + String::number(sessionID.sessionID()), WTFMove(uiProcessCookieStorage));
     61    networkProcess.ensureSession(sessionID, base + '.' + String::number(sessionID.sessionID()), WTFMove(uiProcessCookieStorage));
    6262
    63     auto* session = NetworkStorageSession::storageSession(sessionID);
     63    auto* session = networkProcess.storageSession(sessionID);
    6464    for (const auto& cookie : parameters.pendingCookies)
    6565        session->setCookie(cookie);
  • trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessMainSoup.cpp

    r219290 r240292  
    3838    void platformFinalize() override
    3939    {
    40         WebCore::NetworkStorageSession::defaultStorageSession().clearSoupNetworkSessionAndCookieStorage();
    4140    }
    4241};
  • trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp

    r239740 r240292  
    9696    auto acceptLanguages = buildAcceptLanguages(languages);
    9797    SoupNetworkSession::setInitialAcceptLanguages(acceptLanguages);
    98     NetworkStorageSession::forEach([&acceptLanguages](const WebCore::NetworkStorageSession& session) {
     98    forEachNetworkStorageSession([&acceptLanguages](const auto& session) {
    9999        if (auto* soupSession = session.soupNetworkSession())
    100100            soupSession->setAcceptLanguages(acceptLanguages);
     
    169169{
    170170    SoupNetworkSession::setProxySettings(settings);
    171     NetworkStorageSession::forEach([](const NetworkStorageSession& session) {
     171    forEachNetworkStorageSession([](const auto& session) {
    172172        if (auto* soupSession = session.soupNetworkSession())
    173173            soupSession->setupProxy();
  • trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp

    r240019 r240292  
    4747NetworkSessionSoup::~NetworkSessionSoup()
    4848{
    49     if (auto* storageSession = NetworkStorageSession::storageSession(m_sessionID))
     49    if (auto* storageSession = networkProcess().storageSession(m_sessionID))
    5050        storageSession->setCookieObserverHandler(nullptr);
    5151}
  • trunk/Source/WebKit/NetworkProcess/soup/RemoteNetworkingContextSoup.cpp

    r239815 r240292  
    3939{
    4040    auto sessionID = parameters.networkSessionParameters.sessionID;
    41     if (NetworkStorageSession::storageSession(sessionID))
     41    if (networkProcess.storageSession(sessionID))
    4242        return;
    4343
    44     NetworkStorageSession::ensureSession(sessionID, String::number(sessionID.sessionID()));
     44    networkProcess.ensureSession(sessionID, String::number(sessionID.sessionID()));
    4545    networkProcess.setSession(sessionID, NetworkSession::create(networkProcess, WTFMove(parameters.networkSessionParameters)));
    4646}
  • trunk/Source/WebKit/SourcesCocoa.txt

    r240288 r240292  
    256256UIProcess/API/Cocoa/APIAttachmentCocoa.mm
    257257UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm
     258UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm
    258259UIProcess/API/Cocoa/APISerializedScriptValueCocoa.mm
    259260UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm
  • trunk/Source/WebKit/UIProcess/API/APIHTTPCookieStore.cpp

    r232522 r240292  
    5050    ASSERT(!m_observedCookieManagerProxy);
    5151    ASSERT(!m_cookieManagerProxyObserver);
    52     ASSERT(!m_observingUIProcessCookies);
    5352
    5453    unregisterForNewProcessPoolNotifications();
    5554}
    5655
    57 void HTTPCookieStore::cookies(Function<void(const Vector<WebCore::Cookie>&)>&& completionHandler)
     56void HTTPCookieStore::cookies(CompletionHandler<void(const Vector<WebCore::Cookie>&)>&& completionHandler)
    5857{
    5958    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
     
    6160        Vector<WebCore::Cookie> allCookies;
    6261        if (m_owningDataStore->sessionID() == PAL::SessionID::defaultSessionID())
    63             allCookies = WebCore::NetworkStorageSession::defaultStorageSession().getAllCookies();
     62            allCookies = getAllDefaultUIProcessCookieStoreCookies();
    6463        allCookies.appendVector(m_owningDataStore->pendingCookies());
    6564
    66         callOnMainThread([completionHandler = WTFMove(completionHandler), allCookies]() {
     65        callOnMainThread([completionHandler = WTFMove(completionHandler), allCookies] () mutable {
    6766            completionHandler(allCookies);
    6867        });
     
    7170
    7271    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
    73     cookieManager->getAllCookies(m_owningDataStore->sessionID(), [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](const Vector<WebCore::Cookie>& cookies, CallbackBase::Error error) {
     72    cookieManager->getAllCookies(m_owningDataStore->sessionID(), [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)] (const Vector<WebCore::Cookie>& cookies, CallbackBase::Error error) mutable {
    7473        completionHandler(cookies);
    7574    });
    7675}
    7776
    78 void HTTPCookieStore::setCookie(const WebCore::Cookie& cookie, Function<void ()>&& completionHandler)
     77void HTTPCookieStore::setCookie(const WebCore::Cookie& cookie, CompletionHandler<void()>&& completionHandler)
    7978{
    8079    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
     
    8281        // FIXME: pendingCookies used for defaultSession because session cookies cannot be propagated to Network Process with uiProcessCookieStorageIdentifier.
    8382        if (m_owningDataStore->sessionID() == PAL::SessionID::defaultSessionID() && !cookie.session)
    84             WebCore::NetworkStorageSession::defaultStorageSession().setCookie(cookie);
     83            setCookieInDefaultUIProcessCookieStore(cookie);
    8584        else
    8685            m_owningDataStore->addPendingCookie(cookie);
    8786
    88         callOnMainThread([completionHandler = WTFMove(completionHandler)]() {
     87        callOnMainThread([completionHandler = WTFMove(completionHandler)] () mutable {
    8988            completionHandler();
    9089        });
     
    9392
    9493    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
    95     cookieManager->setCookie(m_owningDataStore->sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
     94    cookieManager->setCookie(m_owningDataStore->sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)] (CallbackBase::Error error) mutable {
    9695        completionHandler();
    9796    });
    9897}
    9998
    100 void HTTPCookieStore::deleteCookie(const WebCore::Cookie& cookie, Function<void ()>&& completionHandler)
     99void HTTPCookieStore::deleteCookie(const WebCore::Cookie& cookie, CompletionHandler<void()>&& completionHandler)
    101100{
    102101    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
    103102    if (!pool) {
    104103        if (m_owningDataStore->sessionID() == PAL::SessionID::defaultSessionID() && !cookie.session)
    105             WebCore::NetworkStorageSession::defaultStorageSession().deleteCookie(cookie);
     104            deleteCookieFromDefaultUIProcessCookieStore(cookie);
    106105        else
    107106            m_owningDataStore->removePendingCookie(cookie);
    108107
    109         callOnMainThread([completionHandler = WTFMove(completionHandler)]() {
     108        callOnMainThread([completionHandler = WTFMove(completionHandler)] () mutable {
    110109            completionHandler();
    111110        });
     
    114113
    115114    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
    116     cookieManager->deleteCookie(m_owningDataStore->sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
     115    cookieManager->deleteCookie(m_owningDataStore->sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) mutable {
    117116        completionHandler();
    118117    });
     
    157156
    158157        // Listen for cookie notifications in the UIProcess in the meantime.
    159         WebCore::startObservingCookieChanges(WebCore::NetworkStorageSession::defaultStorageSession(), [this] () {
     158        startObservingChangesToDefaultUIProcessCookieStore([this] () {
    160159            cookiesDidChange();
    161160        });
    162161
    163162        m_observingUIProcessCookies = true;
    164 
    165163        return;
    166164    }
     
    181179
    182180    if (m_observingUIProcessCookies)
    183         WebCore::stopObservingCookieChanges(WebCore::NetworkStorageSession::defaultStorageSession());
     181        stopObservingChangesToDefaultUIProcessCookieStore();
    184182
    185183    if (m_processPoolCreationListenerIdentifier)
     
    222220        // Now that an associated process pool exists, we need to flush the UI process cookie store
    223221        // to make sure any changes are reflected within the new process pool.
    224         WebCore::NetworkStorageSession::defaultStorageSession().flushCookieStore();
     222        flushDefaultUIProcessCookieStore();
    225223        newProcessPool.ensureNetworkProcess();
    226224
     
    241239}
    242240
     241#if !PLATFORM(COCOA)
     242void HTTPCookieStore::flushDefaultUIProcessCookieStore() { }
     243Vector<WebCore::Cookie> HTTPCookieStore::getAllDefaultUIProcessCookieStoreCookies() { return { }; }
     244void HTTPCookieStore::setCookieInDefaultUIProcessCookieStore(const WebCore::Cookie&) { }
     245void HTTPCookieStore::deleteCookieFromDefaultUIProcessCookieStore(const WebCore::Cookie&) { }
     246void HTTPCookieStore::startObservingChangesToDefaultUIProcessCookieStore(Function<void()>&&) { }
     247void HTTPCookieStore::stopObservingChangesToDefaultUIProcessCookieStore() { }
     248#endif
     249   
    243250} // namespace API
  • trunk/Source/WebKit/UIProcess/API/APIHTTPCookieStore.h

    r238771 r240292  
    2929#include "HTTPCookieAcceptPolicy.h"
    3030#include <WebCore/Cookie.h>
     31#include <wtf/CompletionHandler.h>
    3132#include <wtf/Forward.h>
    32 #include <wtf/Function.h>
    3333#include <wtf/HashSet.h>
    3434
    3535namespace WebCore {
    3636struct Cookie;
     37class CookieStorageObserver;
    3738}
    3839
     
    5657    virtual ~HTTPCookieStore();
    5758
    58     void cookies(Function<void (const Vector<WebCore::Cookie>&)>&& completionHandler);
    59     void setCookie(const WebCore::Cookie&, Function<void ()>&& completionHandler);
    60     void deleteCookie(const WebCore::Cookie&, Function<void ()>&& completionHandler);
     59    void cookies(CompletionHandler<void(const Vector<WebCore::Cookie>&)>&&);
     60    void setCookie(const WebCore::Cookie&, CompletionHandler<void()>&&);
     61    void deleteCookie(const WebCore::Cookie&, CompletionHandler<void()>&&);
    6162
    6263    class Observer {
     
    7879    void unregisterForNewProcessPoolNotifications();
    7980
     81    static void flushDefaultUIProcessCookieStore();
     82    static Vector<WebCore::Cookie> getAllDefaultUIProcessCookieStoreCookies();
     83    static void setCookieInDefaultUIProcessCookieStore(const WebCore::Cookie&);
     84    static void deleteCookieFromDefaultUIProcessCookieStore(const WebCore::Cookie&);
     85    void startObservingChangesToDefaultUIProcessCookieStore(Function<void()>&&);
     86    void stopObservingChangesToDefaultUIProcessCookieStore();
     87   
    8088    Ref<WebKit::WebsiteDataStore> m_owningDataStore;
    8189    HashSet<Observer*> m_observers;
     
    8694
    8795    uint64_t m_processPoolCreationListenerIdentifier { 0 };
     96    RefPtr<WebCore::CookieStorageObserver> m_defaultUIProcessObserver;
    8897};
    8998
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r240243 r240292  
    16301630void WebProcessPool::clearCachedCredentials()
    16311631{
    1632     sendToAllProcesses(Messages::WebProcess::ClearCachedCredentials());
    16331632    if (m_networkProcess)
    16341633        m_networkProcess->send(Messages::NetworkProcess::ClearCachedCredentials(), 0);
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r240288 r240292  
    34553455                5CA26D7F217ABBB600F97A35 /* WKSafeBrowsingWarning.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKSafeBrowsingWarning.mm; sourceTree = "<group>"; };
    34563456                5CA26D80217ABBB600F97A35 /* WKSafeBrowsingWarning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKSafeBrowsingWarning.h; sourceTree = "<group>"; };
     3457                5CA46E7A21F1A23900CE86B4 /* APIHTTPCookieStoreCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = APIHTTPCookieStoreCocoa.mm; path = UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm; sourceTree = SOURCE_ROOT; };
    34573458                5CA98549210BEB5A0057EB6B /* SafeBrowsingWarning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SafeBrowsingWarning.h; sourceTree = "<group>"; };
    34583459                5CA9854B210BEB730057EB6B /* SafeBrowsingWarningCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SafeBrowsingWarningCocoa.mm; sourceTree = "<group>"; };
     
    60756076                                F41056612130699A0092281D /* APIAttachmentCocoa.mm */,
    60766077                                7CEFA9601AC0999300B910FD /* APIContentRuleListStoreCocoa.mm */,
     6078                                5CA46E7A21F1A23900CE86B4 /* APIHTTPCookieStoreCocoa.mm */,
    60776079                                FED3C1DA1B447AE800E0EB7F /* APISerializedScriptValueCocoa.mm */,
    60786080                                1A3635AB1A3145E500ED6197 /* APIWebsiteDataStoreCocoa.mm */,
  • trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp

    r240237 r240292  
    16031603        return false;
    16041604
    1605     String partitionName = contentDocument->topDocument().domainForCachePartition();
    1606     Credential credential = NetworkStorageSession::defaultStorageSession().credentialStorage().get(partitionName, protectionSpace);
    1607     if (credential.isEmpty())
    1608         credential = NetworkStorageSession::defaultStorageSession().credentialStorage().getFromPersistentStorage(protectionSpace);
    1609 
     1605    auto credential = CredentialStorage::getFromPersistentStorage(protectionSpace);
    16101606    if (!credential.hasPassword())
    16111607        return false;
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/curl/WebFrameNetworkingContext.cpp

    r239815 r240292  
    3939using namespace WebCore;
    4040
    41 void WebFrameNetworkingContext::ensureWebsiteDataStoreSession(WebsiteDataStoreParameters&& parameters)
     41void WebFrameNetworkingContext::ensureWebsiteDataStoreSession(WebsiteDataStoreParameters&&)
    4242{
    43     auto sessionID = parameters.networkSessionParameters.sessionID;
    44     ASSERT(isMainThread());
    45     ASSERT(sessionID.isEphemeral());
    46 
    47     if (NetworkStorageSession::storageSession(sessionID))
    48         return;
    49 
    50     // FIXME: Implement to ensure a data storage session.
    5143}
    5244
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp

    r239815 r240292  
    4242using namespace WebCore;
    4343
    44 void WebFrameNetworkingContext::ensureWebsiteDataStoreSession(WebsiteDataStoreParameters&& parameters)
     44void WebFrameNetworkingContext::ensureWebsiteDataStoreSession(WebsiteDataStoreParameters&&)
    4545{
    46     auto sessionID = parameters.networkSessionParameters.sessionID;
    47     ASSERT(RunLoop::isMain());
    48 
    49     if (NetworkStorageSession::storageSession(sessionID))
    50         return;
    51 
    52     NetworkStorageSession::ensureSession(sessionID, String::number(sessionID.sessionID()));
    5346}
    5447
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r240243 r240292  
    579579}
    580580
    581 void WebProcess::clearCachedCredentials()
    582 {
    583     NetworkStorageSession::defaultStorageSession().credentialStorage().clearCredentials();
    584 }
    585 
    586581WebPage* WebProcess::focusedWebPage() const
    587582{   
     
    13001295        CrossOriginPreflightResultCache::singleton().clear();
    13011296    }
    1302 
    1303     if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
    1304         if (WebCore::NetworkStorageSession::storageSession(sessionID))
    1305             NetworkStorageSession::storageSession(sessionID)->credentialStorage().clearCredentials();
    1306     }
    13071297}
    13081298
  • trunk/Source/WebKit/WebProcess/WebProcess.h

    r239835 r240292  
    267267    void processSuspensionCleanupTimerFired();
    268268
    269     void clearCachedCredentials();
    270 
    271269    void platformTerminate();
    272270
  • trunk/Source/WebKit/WebProcess/WebProcess.messages.in

    r239737 r240292  
    5151    UserPreferredLanguagesChanged(Vector<String> languages)
    5252    FullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled)
    53 
    54     ClearCachedCredentials()
    5553
    5654    # Plug-ins.
  • trunk/Source/WebKit/WebProcess/soup/WebProcessSoup.cpp

    r239671 r240292  
    6565{
    6666    WebCore::SoupNetworkSession::setProxySettings(settings);
    67     WebCore::NetworkStorageSession::forEach([](const WebCore::NetworkStorageSession& session) {
    68         if (auto* soupSession = session.soupNetworkSession())
    69             soupSession->setupProxy();
    70     });
    7167}
    7268
  • trunk/Source/WebKitLegacy/CMakeLists.txt

    r229048 r240292  
    1313    Storage/WebStorageNamespaceProvider.cpp
    1414
     15    WebCoreSupport/NetworkStorageSessionMap.cpp
    1516    WebCoreSupport/WebResourceLoadScheduler.cpp
    1617    WebCoreSupport/WebViewGroup.cpp
  • trunk/Source/WebKitLegacy/ChangeLog

    r240237 r240292  
     12019-01-22  Alex Christensen  <achristensen@webkit.org>
     2
     3        Move NetworkStorageSession ownership to NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=193580
     5
     6        Reviewed by Geoff Garen.
     7
     8        * WebCoreSupport/NetworkStorageSessionMap.cpp: Added.
     9        (defaultNetworkStorageSession):
     10        (globalSessionMap):
     11        (NetworkStorageSessionMap::storageSession):
     12        (NetworkStorageSessionMap::defaultStorageSession):
     13        (NetworkStorageSessionMap::switchToNewTestingSession):
     14        (NetworkStorageSessionMap::ensureSession):
     15        (NetworkStorageSessionMap::destroySession):
     16        * WebCoreSupport/NetworkStorageSessionMap.h: Added.
     17        * WebCoreSupport/PageStorageSessionProvider.h:
     18        * WebKitLegacy.xcodeproj/project.pbxproj:
     19
    1202019-01-15  Darin Adler  <darin@apple.com>
    221
  • trunk/Source/WebKitLegacy/WebCoreSupport/PageStorageSessionProvider.h

    r240117 r240292  
    2626#pragma once
    2727
     28#include "NetworkStorageSessionMap.h"
    2829#include <WebCore/NetworkStorageSession.h>
    2930#include <WebCore/Page.h>
     
    3839    {
    3940        if (m_page)
    40             return WebCore::NetworkStorageSession::storageSession(m_page->sessionID());
     41            return NetworkStorageSessionMap::storageSession(m_page->sessionID());
    4142        return nullptr;
    4243    }
  • trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj

    r240190 r240292  
    149149                598ADA461202275000ABAE4E /* WebDeviceOrientationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 598ADA451202275000ABAE4E /* WebDeviceOrientationProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
    150150                5C9EF2F521F061BE003BDC56 /* PageStorageSessionProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9EF2F421F061BE003BDC56 /* PageStorageSessionProvider.h */; };
     151                5CA46E7821F1451D00CE86B4 /* NetworkStorageSessionMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CA46E7621F1451D00CE86B4 /* NetworkStorageSessionMap.h */; };
     152                5CA46E7921F1451D00CE86B4 /* NetworkStorageSessionMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CA46E7721F1451D00CE86B4 /* NetworkStorageSessionMap.cpp */; };
    151153                5CE44F4A206D70EA003EFD01 /* PingHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE44F49206D70E9003EFD01 /* PingHandle.h */; };
    152154                5D7BF8140C2A1D90008CE06D /* WebInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D7BF8120C2A1D90008CE06D /* WebInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    991993                598ADA451202275000ABAE4E /* WebDeviceOrientationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDeviceOrientationProvider.h; sourceTree = "<group>"; };
    992994                5C9EF2F421F061BE003BDC56 /* PageStorageSessionProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PageStorageSessionProvider.h; path = WebCoreSupport/PageStorageSessionProvider.h; sourceTree = SOURCE_ROOT; };
     995                5CA46E7621F1451D00CE86B4 /* NetworkStorageSessionMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkStorageSessionMap.h; path = WebCoreSupport/NetworkStorageSessionMap.h; sourceTree = SOURCE_ROOT; };
     996                5CA46E7721F1451D00CE86B4 /* NetworkStorageSessionMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkStorageSessionMap.cpp; path = WebCoreSupport/NetworkStorageSessionMap.cpp; sourceTree = SOURCE_ROOT; };
    993997                5CE44F49206D70E9003EFD01 /* PingHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PingHandle.h; path = WebCoreSupport/PingHandle.h; sourceTree = SOURCE_ROOT; };
    994998                5D7BF8120C2A1D90008CE06D /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; };
     
    25672571                                B82958D1132707D0000D0E79 /* CorrectionPanel.h */,
    25682572                                B82958D2132707D0000D0E79 /* CorrectionPanel.mm */,
     2573                                5CA46E7721F1451D00CE86B4 /* NetworkStorageSessionMap.cpp */,
     2574                                5CA46E7621F1451D00CE86B4 /* NetworkStorageSessionMap.h */,
    25692575                                5C9EF2F421F061BE003BDC56 /* PageStorageSessionProvider.h */,
    25702576                                5CE44F49206D70E9003EFD01 /* PingHandle.h */,
     
    29452951                                1AAF5CEC0EDDE1FE008D883D /* NetscapePluginHostProxy.h in Headers */,
    29462952                                1AAF5CEE0EDDE1FE008D883D /* NetscapePluginInstanceProxy.h in Headers */,
     2953                                5CA46E7821F1451D00CE86B4 /* NetworkStorageSessionMap.h in Headers */,
    29472954                                E1531BD82187B954002E3F81 /* NSURLDownloadSPI.h in Headers */,
    29482955                                93D4379B1D57ABEF00AB85EA /* ObjCEventListener.h in Headers */,
     
    35313538                                1AAF5CED0EDDE1FE008D883D /* NetscapePluginHostProxy.mm in Sources */,
    35323539                                1AAF5CEF0EDDE1FE008D883D /* NetscapePluginInstanceProxy.mm in Sources */,
     3540                                5CA46E7921F1451D00CE86B4 /* NetworkStorageSessionMap.cpp in Sources */,
    35333541                                939810DD0824BF01008DF038 /* npapi.mm in Sources */,
    35343542                                93D4379C1D57ABEF00AB85EA /* ObjCEventListener.mm in Sources */,
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r240285 r240292  
     12019-01-22  Alex Christensen  <achristensen@webkit.org>
     2
     3        Move NetworkStorageSession ownership to NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=193580
     5
     6        Reviewed by Geoff Garen.
     7
     8        * Misc/WebCache.mm:
     9        (+[WebCache clearCachedCredentials]):
     10        * Misc/WebDownload.mm:
     11        (-[WebDownloadInternal download:didReceiveAuthenticationChallenge:]):
     12        * Plugins/WebBaseNetscapePluginView.mm:
     13        (WebKit::getAuthenticationInfo):
     14        * WebCoreSupport/WebFrameNetworkingContext.mm:
     15        (WebFrameNetworkingContext::ensurePrivateBrowsingSession):
     16        (WebFrameNetworkingContext::destroyPrivateBrowsingSession):
     17        (WebFrameNetworkingContext::storageSession const):
     18        * WebView/WebPreferences.mm:
     19        (+[WebPreferences _switchNetworkLoaderToNewTestingSession]):
     20        (+[WebPreferences _clearNetworkLoaderSession]):
     21        (+[WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:]):
     22
    1232019-01-22  Daniel Bates  <dabates@apple.com>
    224
  • trunk/Source/WebKitLegacy/mac/Misc/WebCache.mm

    r240117 r240292  
    2626#import "WebCache.h"
    2727
     28#import "NetworkStorageSessionMap.h"
    2829#import "WebApplicationCacheInternal.h"
    2930#import "WebNSObjectExtras.h"
     
    5556    WebCore::NetworkStorageSession* storageSession() const final
    5657    {
    57         return &WebCore::NetworkStorageSession::defaultStorageSession();
     58        return &NetworkStorageSessionMap::defaultStorageSession();
    5859    }
    5960};
     
    224225{
    225226    [WebView _makeAllWebViewsPerformSelector:@selector(_clearCredentials)];
    226     WebCore::NetworkStorageSession::defaultStorageSession().credentialStorage().clearCredentials();
     227    NetworkStorageSessionMap::defaultStorageSession().credentialStorage().clearCredentials();
    227228}
    228229
  • trunk/Source/WebKitLegacy/mac/Misc/WebDownload.mm

    r240031 r240292  
    2929#import <WebKitLegacy/WebDownload.h>
    3030
     31#import "NetworkStorageSessionMap.h"
     32#import "WebTypesInternal.h"
    3133#import <Foundation/NSURLAuthenticationChallenge.h>
    3234#import <WebCore/AuthenticationMac.h>
     
    3840#import <pal/spi/cocoa/NSURLDownloadSPI.h>
    3941#import <wtf/Assertions.h>
    40 
    41 #import "WebTypesInternal.h"
    4242
    4343using namespace WebCore;
     
    9696    // Try previously stored credential first.
    9797    if (![challenge previousFailureCount]) {
    98         NSURLCredential *credential = NetworkStorageSession::defaultStorageSession().credentialStorage().get(emptyString(), ProtectionSpace([challenge protectionSpace])).nsCredential();
     98        NSURLCredential *credential = NetworkStorageSessionMap::defaultStorageSession().credentialStorage().get(emptyString(), ProtectionSpace([challenge protectionSpace])).nsCredential();
    9999        if (credential) {
    100100            [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
  • trunk/Source/WebKitLegacy/mac/Plugins/WebBaseNetscapePluginView.mm

    r240031 r240292  
    3131#import "WebBaseNetscapePluginView.h"
    3232
     33#import "NetworkStorageSessionMap.h"
    3334#import "WebFrameInternal.h"
    3435#import "WebKitLogging.h"
     
    873874    RetainPtr<NSURLProtectionSpace> protectionSpace = adoptNS([[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:realm authenticationMethod:authenticationMethod]);
    874875   
    875     NSURLCredential *credential = WebCore::NetworkStorageSession::defaultStorageSession().credentialStorage().get(emptyString(), ProtectionSpace(protectionSpace.get())).nsCredential();
     876    NSURLCredential *credential = NetworkStorageSessionMap::defaultStorageSession().credentialStorage().get(emptyString(), ProtectionSpace(protectionSpace.get())).nsCredential();
    876877    if (!credential)
    877878        credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:protectionSpace.get()];
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameNetworkingContext.mm

    r239737 r240292  
    2626#import "WebFrameNetworkingContext.h"
    2727
     28#import "NetworkStorageSessionMap.h"
    2829#import "WebFrameInternal.h"
    2930#import "WebViewPrivate.h"
     
    4748{
    4849    ASSERT(isMainThread());
    49     NetworkStorageSession::ensureSession(PAL::SessionID::legacyPrivateSessionID(), [[NSBundle mainBundle] bundleIdentifier]);
    50     return *NetworkStorageSession::storageSession(PAL::SessionID::legacyPrivateSessionID());
     50    NetworkStorageSessionMap::ensureSession(PAL::SessionID::legacyPrivateSessionID(), [[NSBundle mainBundle] bundleIdentifier]);
     51    return *NetworkStorageSessionMap::storageSession(PAL::SessionID::legacyPrivateSessionID());
    5152}
    5253
     
    5455{
    5556    ASSERT(isMainThread());
    56     NetworkStorageSession::destroySession(PAL::SessionID::legacyPrivateSessionID());
     57    NetworkStorageSessionMap::destroySession(PAL::SessionID::legacyPrivateSessionID());
    5758}
    5859
     
    9596    ASSERT(isMainThread());
    9697    if (frame() && frame()->page() && frame()->page()->sessionID().isEphemeral()) {
    97         if (auto* session = NetworkStorageSession::storageSession(PAL::SessionID::legacyPrivateSessionID()))
     98        if (auto* session = NetworkStorageSessionMap::storageSession(PAL::SessionID::legacyPrivateSessionID()))
    9899            return session;
    99100        // Some requests may still be coming shortly before WebCore updates the session ID and after WebKit destroys the private browsing session.
    100101        LOG_ERROR("Invalid session ID. Please file a bug unless you just disabled private browsing, in which case it's an expected race.");
    101102    }
    102     return &NetworkStorageSession::defaultStorageSession();
     103    return &NetworkStorageSessionMap::defaultStorageSession();
    103104}
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm

    r240251 r240292  
    3131#import "WebPreferenceKeysPrivate.h"
    3232
     33#import "NetworkStorageSessionMap.h"
    3334#import "WebApplicationCache.h"
    3435#import "WebFrameNetworkingContext.h"
     
    18781879    WebThreadLock();
    18791880#endif
    1880     NetworkStorageSession::switchToNewTestingSession();
     1881    NetworkStorageSessionMap::switchToNewTestingSession();
    18811882}
    18821883
    18831884+ (void)_clearNetworkLoaderSession
    18841885{
    1885     NetworkStorageSession::defaultStorageSession().deleteAllCookies();
     1886    NetworkStorageSessionMap::defaultStorageSession().deleteAllCookies();
    18861887}
    18871888
    18881889+ (void)_setCurrentNetworkLoaderSessionCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
    18891890{
    1890     RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage();
    1891     ASSERT(cookieStorage); // Will fail when NetworkStorageSession::switchToNewTestingSession() was not called beforehand.
     1891    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSessionMap::defaultStorageSession().cookieStorage();
     1892    ASSERT(cookieStorage); // Will fail when NetworkStorageSessionMap::switchToNewTestingSession() was not called beforehand.
    18921893    CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
    18931894}
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r240237 r240292  
     12019-01-22  Alex Christensen  <achristensen@webkit.org>
     2
     3        Move NetworkStorageSession ownership to NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=193580
     5
     6        Reviewed by Geoff Garen.
     7
     8        * WebCoreSupport/WebFrameNetworkingContext.cpp:
     9        (WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts):
     10        (WebFrameNetworkingContext::ensurePrivateBrowsingSession):
     11        (WebFrameNetworkingContext::destroyPrivateBrowsingSession):
     12        (WebFrameNetworkingContext::storageSession const):
     13        * WebDownloadCFNet.cpp:
     14        (WebDownload::didReceiveAuthenticationChallenge):
     15        * WebPreferences.cpp:
     16        (WebPreferences::clearNetworkLoaderSession):
     17        (WebPreferences::switchNetworkLoaderToNewTestingSession):
     18
    1192019-01-15  Darin Adler  <darin@apple.com>
    220
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameNetworkingContext.cpp

    r239737 r240292  
    2626#include "WebFrameNetworkingContext.h"
    2727
     28#include "NetworkStorageSessionMap.h"
    2829#include "WebView.h"
    2930#include <WebCore/FrameLoader.h>
     
    5152void WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts(WebKitCookieStorageAcceptPolicy policy)
    5253{
    53     if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage())
     54    if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSessionMap::defaultStorageSession().cookieStorage())
    5455        CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
    5556
    56     if (auto privateSession = NetworkStorageSession::storageSession(PAL::SessionID::legacyPrivateSessionID()))
     57    if (auto privateSession = NetworkStorageSessionMap::storageSession(PAL::SessionID::legacyPrivateSessionID()))
    5758        CFHTTPCookieStorageSetCookieAcceptPolicy(privateSession->cookieStorage().get(), policy);
    5859}
     
    7172    ASSERT(isMainThread());
    7273
    73     if (auto privateSession = NetworkStorageSession::storageSession(PAL::SessionID::legacyPrivateSessionID()))
     74    if (auto privateSession = NetworkStorageSessionMap::storageSession(PAL::SessionID::legacyPrivateSessionID()))
    7475        return *privateSession;
    7576
     
    8283        base = identifierBase();
    8384
    84     NetworkStorageSession::ensureSession(PAL::SessionID::legacyPrivateSessionID(), base);
     85    NetworkStorageSessionMap::ensureSession(PAL::SessionID::legacyPrivateSessionID(), base);
    8586
    8687#endif
    87     return *NetworkStorageSession::storageSession(PAL::SessionID::legacyPrivateSessionID());
     88    return *NetworkStorageSessionMap::storageSession(PAL::SessionID::legacyPrivateSessionID());
    8889}
    8990
     
    9293    ASSERT(isMainThread());
    9394
    94     NetworkStorageSession::destroySession(PAL::SessionID::legacyPrivateSessionID());
     95    NetworkStorageSessionMap::destroySession(PAL::SessionID::legacyPrivateSessionID());
    9596}
    9697
     
    105106
    106107    if (frame() && frame()->page()->usesEphemeralSession())
    107         return NetworkStorageSession::storageSession(PAL::SessionID::legacyPrivateSessionID());
     108        return NetworkStorageSessionMap::storageSession(PAL::SessionID::legacyPrivateSessionID());
    108109
    109     return &NetworkStorageSession::defaultStorageSession();
     110    return &NetworkStorageSessionMap::defaultStorageSession();
    110111}
  • trunk/Source/WebKitLegacy/win/WebDownloadCFNet.cpp

    r240031 r240292  
    2929#include "DefaultDownloadDelegate.h"
    3030#include "MarshallingHelpers.h"
     31#include "NetworkStorageSessionMap.h"
    3132#include "WebError.h"
    3233#include "WebKit.h"
     
    377378    // Try previously stored credential first.
    378379    if (!CFURLAuthChallengeGetPreviousFailureCount(challenge)) {
    379         Credential credential = WebCore::NetworkStorageSession::defaultStorageSession().credentialStorage().get(emptyString(), core(CFURLAuthChallengeGetProtectionSpace(challenge)));
     380        Credential credential = NetworkStorageSessionMap::defaultStorageSession().credentialStorage().get(emptyString(), core(CFURLAuthChallengeGetProtectionSpace(challenge)));
    380381        if (!credential.isEmpty()) {
    381382            RetainPtr<CFURLCredentialRef> cfCredential = adoptCF(createCF(credential));
  • trunk/Source/WebKitLegacy/win/WebPreferences.cpp

    r238501 r240292  
    2828#include "WebPreferences.h"
    2929
     30#include "NetworkStorageSessionMap.h"
    3031#include "WebNotificationCenter.h"
    3132#include "WebPreferenceKeysPrivate.h"
     
    21192120HRESULT WebPreferences::clearNetworkLoaderSession()
    21202121{
    2121     NetworkStorageSession::defaultStorageSession().deleteAllCookies();
     2122    NetworkStorageSessionMap::defaultStorageSession().deleteAllCookies();
    21222123    return S_OK;
    21232124}
     
    21252126HRESULT WebPreferences::switchNetworkLoaderToNewTestingSession()
    21262127{
    2127     NetworkStorageSession::switchToNewTestingSession();
     2128    NetworkStorageSessionMap::switchToNewTestingSession();
    21282129    return S_OK;
    21292130}
Note: See TracChangeset for help on using the changeset viewer.