Unreviewed, rolling out r201967, r201968, and r201972.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jun 2016 20:05:55 +0000 (20:05 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jun 2016 20:05:55 +0000 (20:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158665

Caused flaky failures on IndexedDB tests (Requested by ap on
#webkit).

Reverted changesets:

"Vary:Cookie validation doesn't work in private browsing"
https://bugs.webkit.org/show_bug.cgi?id=158616
http://trac.webkit.org/changeset/201967

"Build fix."
http://trac.webkit.org/changeset/201968

"WinCairo build fix attempt."
http://trac.webkit.org/changeset/201972

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt
LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/network/CacheValidation.cpp
Source/WebCore/platform/network/NetworkStorageSession.cpp [deleted file]
Source/WebCore/platform/network/NetworkStorageSession.h
Source/WebCore/platform/network/NetworkStorageSessionStub.cpp
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp

index 3ac0592..b0829ec 100644 (file)
@@ -1,3 +1,23 @@
+2016-06-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r201967, r201968, and r201972.
+        https://bugs.webkit.org/show_bug.cgi?id=158665
+
+        Caused flaky failures on IndexedDB tests (Requested by ap on
+        #webkit).
+
+        Reverted changesets:
+
+        "Vary:Cookie validation doesn't work in private browsing"
+        https://bugs.webkit.org/show_bug.cgi?id=158616
+        http://trac.webkit.org/changeset/201967
+
+        "Build fix."
+        http://trac.webkit.org/changeset/201968
+
+        "WinCairo build fix attempt."
+        http://trac.webkit.org/changeset/201972
+
 2016-06-11  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Deleting a CSSOM style rule invalidates any previously-added FontFaces
 2016-06-11  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Deleting a CSSOM style rule invalidates any previously-added FontFaces
index d53649c..8ee540c 100644 (file)
@@ -1,9 +1,8 @@
-Test that Vary: Cookie in response is handled by caches.
+Test that Vary: Cookie in response is handled by the disk cache.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-Testing disk cache
 Setting cookie and loading
 response headers: {"Cache-control":"max-age=100"}
 response source: Network
 Setting cookie and loading
 response headers: {"Cache-control":"max-age=100"}
 response source: Network
@@ -32,64 +31,6 @@ response source: Disk cache
 response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
 response source: Disk cache
 
 response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
 response source: Disk cache
 
-Testing memory cache
-Setting cookie and loading
-response headers: {"Cache-control":"max-age=100"}
-response source: Network
-
-response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
-response source: Network
-
-Loading again
-response headers: {"Cache-control":"max-age=100"}
-response source: Memory cache
-
-response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
-response source: Memory cache
-
-Changing cookie and loading
-response headers: {"Cache-control":"max-age=100"}
-response source: Memory cache
-
-response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
-response source: Network
-
-Loading again
-response headers: {"Cache-control":"max-age=100"}
-response source: Memory cache
-
-response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
-response source: Memory cache
-
-Testing memory cache in private browsing
-Setting cookie and loading
-response headers: {"Cache-control":"max-age=100"}
-response source: Network
-
-response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
-response source: Network
-
-Loading again
-response headers: {"Cache-control":"max-age=100"}
-response source: Memory cache
-
-response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
-response source: Memory cache
-
-Changing cookie and loading
-response headers: {"Cache-control":"max-age=100"}
-response source: Memory cache
-
-response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
-response source: Network
-
-Loading again
-response headers: {"Cache-control":"max-age=100"}
-response source: Memory cache
-
-response headers: {"Vary":"Cookie","Cache-control":"max-age=100"}
-response source: Memory cache
-
 PASS successfullyParsed is true
 
 TEST COMPLETE
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 4da9fe4..b9c72ea 100644 (file)
@@ -3,48 +3,32 @@
 <body>
 <script>
 
 <body>
 <script>
 
+var tests =
+[
+  { responseHeaders: {'Cache-control': 'max-age=100'} },
+  { responseHeaders: {'Vary': 'Cookie', 'Cache-control': 'max-age=100'} },
+];
 
 
-description("Test that Vary: Cookie in response is handled by caches.");
+description("Test that Vary: Cookie in response is handled by the disk cache.");
 
 
-function testCookies(testDiskCache, completionHandler)
-{
-    var tests = [
-      { responseHeaders: {'Cache-control': 'max-age=100'} },
-      { responseHeaders: {'Vary': 'Cookie', 'Cache-control': 'max-age=100'} },
-    ];
-
-    var options = { "ClearMemoryCache" : testDiskCache };
-    debug("Setting cookie and loading");
-    document.cookie = "cookie=" + Math.floor((Math.random() * 1000000000000));
-    loadResourcesWithOptions(tests, options, function () {
+debug("Setting cookie and loading");
+document.cookie = "cookie=value";
+loadResources(tests, function () {
+    printResults(tests);
+    debug("Loading again");
+    loadResources(tests, function () {
         printResults(tests);
         printResults(tests);
-        debug("Loading again");
-        loadResourcesWithOptions(tests, options, function () {
+        debug("Changing cookie and loading");
+        document.cookie = "cookie=othervalue";
+        loadResources(tests, function () {
             printResults(tests);
             printResults(tests);
-            debug("Changing cookie and loading");
-            document.cookie = "cookie" + Math.floor((Math.random() * 1000000000000));
-            loadResourcesWithOptions(tests, options, function () {
-                printResults(tests);
-                debug("Loading again");
-                loadResourcesWithOptions(tests, options, function () {
-                   printResults(tests);
-                   completionHandler();
-                });
+            debug("Loading again");
+            loadResources(tests, function () {
+               printResults(tests);
+               finishJSTest();
             });
         });
     });
             });
         });
     });
-}
-
-debug("Testing disk cache");
-testCookies(true, function () {
-    debug("Testing memory cache");
-    testCookies(false, function () {
-        debug("Testing memory cache in private browsing");
-        testRunner.setPrivateBrowsingEnabled(true);
-        testCookies(false, function () {
-            finishJSTest();
-        });
-    });
 });
 
 </script>
 });
 
 </script>
index a711ce4..d8a2a12 100644 (file)
@@ -2342,7 +2342,6 @@ set(WebCore_SOURCES
     platform/network/HTTPParsers.cpp
     platform/network/MIMEHeader.cpp
     platform/network/NetworkStateNotifier.cpp
     platform/network/HTTPParsers.cpp
     platform/network/MIMEHeader.cpp
     platform/network/NetworkStateNotifier.cpp
-    platform/network/NetworkStorageSession.cpp
     platform/network/ParsedContentRange.cpp
     platform/network/ParsedContentType.cpp
     platform/network/ProtectionSpaceBase.cpp
     platform/network/ParsedContentRange.cpp
     platform/network/ParsedContentType.cpp
     platform/network/ProtectionSpaceBase.cpp
index 37118bf..656bef1 100644 (file)
@@ -1,3 +1,23 @@
+2016-06-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r201967, r201968, and r201972.
+        https://bugs.webkit.org/show_bug.cgi?id=158665
+
+        Caused flaky failures on IndexedDB tests (Requested by ap on
+        #webkit).
+
+        Reverted changesets:
+
+        "Vary:Cookie validation doesn't work in private browsing"
+        https://bugs.webkit.org/show_bug.cgi?id=158616
+        http://trac.webkit.org/changeset/201967
+
+        "Build fix."
+        http://trac.webkit.org/changeset/201968
+
+        "WinCairo build fix attempt."
+        http://trac.webkit.org/changeset/201972
+
 2016-06-11  Konstantin Tokarev  <annulen@yandex.ru>
 
         Fixed compilation of LocaleICU with ENABLE(DATE_AND_TIME_INPUT_TYPES)
 2016-06-11  Konstantin Tokarev  <annulen@yandex.ru>
 
         Fixed compilation of LocaleICU with ENABLE(DATE_AND_TIME_INPUT_TYPES)
index 50de301..fb7aab8 100644 (file)
                E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */; };
                E4F9EEF2156D9FFA00D23E7E /* StyleSheetContents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */; };
                E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */; };
                E4F9EEF2156D9FFA00D23E7E /* StyleSheetContents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */; };
                E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               E4FD02041D0AF2C100D8E57E /* NetworkStorageSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4FD02031D0AF2C100D8E57E /* NetworkStorageSession.cpp */; };
                E51A81DF17298D7700BFCA61 /* JSPerformance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */; };
                E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E526AF3E1727F8F200E41781 /* Performance.cpp */; };
                E55F497A151B888000BB67DB /* LengthFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E55F4979151B888000BB67DB /* LengthFunctions.cpp */; };
                E51A81DF17298D7700BFCA61 /* JSPerformance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */; };
                E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E526AF3E1727F8F200E41781 /* Performance.cpp */; };
                E55F497A151B888000BB67DB /* LengthFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E55F4979151B888000BB67DB /* LengthFunctions.cpp */; };
                E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFunctions.h; sourceTree = "<group>"; };
                E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSheetContents.cpp; sourceTree = "<group>"; };
                E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSheetContents.h; sourceTree = "<group>"; };
                E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFunctions.h; sourceTree = "<group>"; };
                E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSheetContents.cpp; sourceTree = "<group>"; };
                E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSheetContents.h; sourceTree = "<group>"; };
-               E4FD02031D0AF2C100D8E57E /* NetworkStorageSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkStorageSession.cpp; sourceTree = "<group>"; };
                E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformance.cpp; sourceTree = "<group>"; };
                E526AF3E1727F8F200E41781 /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = "<group>"; };
                E55F4979151B888000BB67DB /* LengthFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthFunctions.cpp; sourceTree = "<group>"; };
                E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformance.cpp; sourceTree = "<group>"; };
                E526AF3E1727F8F200E41781 /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = "<group>"; };
                E55F4979151B888000BB67DB /* LengthFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthFunctions.cpp; sourceTree = "<group>"; };
                                628D214B12131ED10055DCFC /* NetworkingContext.h */,
                                1A7FA61A0DDA3BBE0028F8A5 /* NetworkStateNotifier.cpp */,
                                1A7FA6180DDA3B3A0028F8A5 /* NetworkStateNotifier.h */,
                                628D214B12131ED10055DCFC /* NetworkingContext.h */,
                                1A7FA61A0DDA3BBE0028F8A5 /* NetworkStateNotifier.cpp */,
                                1A7FA6180DDA3B3A0028F8A5 /* NetworkStateNotifier.h */,
-                               E4FD02031D0AF2C100D8E57E /* NetworkStorageSession.cpp */,
                                E13EF3421684ECF40034C83F /* NetworkStorageSession.h */,
                                CDCD41E51C3DDB0900965D99 /* ParsedContentRange.cpp */,
                                CDCD41E61C3DDB0900965D99 /* ParsedContentRange.h */,
                                E13EF3421684ECF40034C83F /* NetworkStorageSession.h */,
                                CDCD41E51C3DDB0900965D99 /* ParsedContentRange.cpp */,
                                CDCD41E61C3DDB0900965D99 /* ParsedContentRange.h */,
                                A55639D21C6F09E700806D8E /* WorkerConsoleClient.cpp in Sources */,
                                A3E2643014748991005A8588 /* WorkerEventQueue.cpp in Sources */,
                                2E4346480F546A8200B0F1BA /* WorkerGlobalScope.cpp in Sources */,
                                A55639D21C6F09E700806D8E /* WorkerConsoleClient.cpp in Sources */,
                                A3E2643014748991005A8588 /* WorkerEventQueue.cpp in Sources */,
                                2E4346480F546A8200B0F1BA /* WorkerGlobalScope.cpp in Sources */,
-                               E4FD02041D0AF2C100D8E57E /* NetworkStorageSession.cpp in Sources */,
                                418C395A1C8DD6990051C8A3 /* WorkerGlobalScopeFetch.cpp in Sources */,
                                5185FCB31BB4C4E80012898F /* WorkerGlobalScopeIndexedDatabase.cpp in Sources */,
                                97F8E665151D4A4B00D2D181 /* WorkerGlobalScopeNotifications.cpp in Sources */,
                                418C395A1C8DD6990051C8A3 /* WorkerGlobalScopeFetch.cpp in Sources */,
                                5185FCB31BB4C4E80012898F /* WorkerGlobalScopeIndexedDatabase.cpp in Sources */,
                                97F8E665151D4A4B00D2D181 /* WorkerGlobalScopeNotifications.cpp in Sources */,
index 99a1ead..07ee84a 100644 (file)
@@ -338,7 +338,11 @@ static String headerValueForVary(const ResourceRequest& request, const String& h
     // We could fetch the cookie when making the request but that seems overkill as the case is very rare and it
     // is a blocking operation. This should be sufficient to cover reasonable cases.
     if (headerName == httpHeaderNameString(HTTPHeaderName::Cookie)) {
     // We could fetch the cookie when making the request but that seems overkill as the case is very rare and it
     // is a blocking operation. This should be sufficient to cover reasonable cases.
     if (headerName == httpHeaderNameString(HTTPHeaderName::Cookie)) {
-        auto& session = NetworkStorageSession::forSessionID(sessionID);
+        if (sessionID != SessionID::defaultSessionID()) {
+            // FIXME: Don't know how to get the cookie. There should be a global way to get NetworkStorageSession from sessionID.
+            return "";
+        }
+        auto& session = NetworkStorageSession::defaultStorageSession();
         auto* cookieStrategy = platformStrategies() ? platformStrategies()->cookiesStrategy() : nullptr;
         if (!cookieStrategy)
             return cookieRequestHeaderFieldValue(session, request.firstPartyForCookies(), request.url());
         auto* cookieStrategy = platformStrategies() ? platformStrategies()->cookiesStrategy() : nullptr;
         if (!cookieStrategy)
             return cookieRequestHeaderFieldValue(session, request.firstPartyForCookies(), request.url());
@@ -370,6 +374,10 @@ bool verifyVaryingRequestHeaders(const Vector<std::pair<String, String>>& varyin
         // FIXME: Vary: * in response would ideally trigger a cache delete instead of a store.
         if (varyingRequestHeader.first == "*")
             return false;
         // FIXME: Vary: * in response would ideally trigger a cache delete instead of a store.
         if (varyingRequestHeader.first == "*")
             return false;
+        if (sessionID != SessionID::defaultSessionID() && varyingRequestHeader.first == httpHeaderNameString(HTTPHeaderName::Cookie)) {
+            // FIXME: See the comment in headerValueForVary.
+            return false;
+        }
         String headerValue = headerValueForVary(request, varyingRequestHeader.first, sessionID);
         if (headerValue != varyingRequestHeader.second)
             return false;
         String headerValue = headerValueForVary(request, varyingRequestHeader.first, sessionID);
         if (headerValue != varyingRequestHeader.second)
             return false;
diff --git a/Source/WebCore/platform/network/NetworkStorageSession.cpp b/Source/WebCore/platform/network/NetworkStorageSession.cpp
deleted file mode 100644 (file)
index 7cc1b7e..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NetworkStorageSession.h"
-
-#include "NetworkingContext.h"
-#include <wtf/HashMap.h>
-#include <wtf/MainThread.h>
-#include <wtf/NeverDestroyed.h>
-
-#if USE(SOUP)
-#include "SoupNetworkSession.h"
-#endif
-
-namespace WebCore {
-
-static std::unique_ptr<NetworkStorageSession>& defaultSession()
-{
-    ASSERT(isMainThread());
-    static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
-    return session;
-}
-
-static HashMap<SessionID, NetworkStorageSession*>& sessionsMap()
-{
-    static NeverDestroyed<HashMap<SessionID, NetworkStorageSession*>> map;
-    return map;
-}
-
-NetworkStorageSession::NetworkStorageSession(SessionID sessionID)
-    : m_sessionID(sessionID)
-{
-    if (sessionID == SessionID::defaultSessionID())
-        return;
-    ASSERT(!sessionsMap().contains(sessionID));
-    sessionsMap().add(sessionID, this);
-}
-
-NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
-{
-    if (!defaultSession())
-        defaultSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), nullptr);
-    return *defaultSession();
-}
-
-NetworkStorageSession::~NetworkStorageSession()
-{
-    if (m_sessionID == SessionID::defaultSessionID())
-        return;
-    ASSERT(sessionsMap().contains(m_sessionID));
-    sessionsMap().remove(m_sessionID);
-}
-
-NetworkStorageSession& NetworkStorageSession::forSessionID(SessionID sessionID)
-{
-    if (sessionID == SessionID::defaultSessionID())
-        return defaultStorageSession();
-
-    ASSERT(sessionsMap().contains(sessionID));
-    return *sessionsMap().get(sessionID);
-}
-
-void NetworkStorageSession::replaceDefaultSession(std::unique_ptr<NetworkStorageSession> newDefaultSession)
-{
-    defaultSession() = WTFMove(newDefaultSession);
-}
-
-};
index a7d203a..fc45e32 100644 (file)
@@ -37,6 +37,7 @@
 
 namespace WebCore {
 
 
 namespace WebCore {
 
+class NetworkingContext;
 class ResourceRequest;
 class SoupNetworkSession;
 
 class ResourceRequest;
 class SoupNetworkSession;
 
@@ -48,35 +49,29 @@ public:
 
     WEBCORE_EXPORT static void switchToNewTestingSession();
 
 
     WEBCORE_EXPORT static void switchToNewTestingSession();
 
-    static NetworkStorageSession& forSessionID(SessionID);
-
-    WEBCORE_EXPORT ~NetworkStorageSession();
-
     SessionID sessionID() const { return m_sessionID; }
     CredentialStorage& credentialStorage() { return m_credentialStorage; }
 
 #if PLATFORM(COCOA) || USE(CFNETWORK)
     SessionID sessionID() const { return m_sessionID; }
     CredentialStorage& credentialStorage() { return m_credentialStorage; }
 
 #if PLATFORM(COCOA) || USE(CFNETWORK)
-    NetworkStorageSession(SessionID, RetainPtr<CFURLStorageSessionRef>&&);
+    NetworkStorageSession(SessionID, RetainPtr<CFURLStorageSessionRef>);
 
     // May be null, in which case a Foundation default should be used.
     CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
     WEBCORE_EXPORT RetainPtr<CFHTTPCookieStorageRef> cookieStorage() const;
 #elif USE(SOUP)
     NetworkStorageSession(SessionID, std::unique_ptr<SoupNetworkSession>);
 
     // May be null, in which case a Foundation default should be used.
     CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
     WEBCORE_EXPORT RetainPtr<CFHTTPCookieStorageRef> cookieStorage() const;
 #elif USE(SOUP)
     NetworkStorageSession(SessionID, std::unique_ptr<SoupNetworkSession>);
+    ~NetworkStorageSession();
 
     SoupNetworkSession& soupNetworkSession() const;
     void setSoupNetworkSession(std::unique_ptr<SoupNetworkSession>);
 #else
     NetworkStorageSession(SessionID, NetworkingContext*);
 
     SoupNetworkSession& soupNetworkSession() const;
     void setSoupNetworkSession(std::unique_ptr<SoupNetworkSession>);
 #else
     NetworkStorageSession(SessionID, NetworkingContext*);
+    ~NetworkStorageSession();
 
     NetworkingContext* context() const;
 #endif
 
 private:
 
     NetworkingContext* context() const;
 #endif
 
 private:
-    explicit NetworkStorageSession(SessionID);
-
-    static void replaceDefaultSession(std::unique_ptr<NetworkStorageSession>);
-
     SessionID m_sessionID;
 
 #if PLATFORM(COCOA) || USE(CFNETWORK)
     SessionID m_sessionID;
 
 #if PLATFORM(COCOA) || USE(CFNETWORK)
index 36c69c6..5925c4d 100644 (file)
 namespace WebCore {
 
 NetworkStorageSession::NetworkStorageSession(SessionID sessionID, NetworkingContext* context)
 namespace WebCore {
 
 NetworkStorageSession::NetworkStorageSession(SessionID sessionID, NetworkingContext* context)
-    : NetworkStorageSession(sessionID)
+    : m_sessionID(sessionID)
+    , m_context(context)
+{
+}
+
+NetworkStorageSession::~NetworkStorageSession()
 {
 {
-    m_context = context;
 }
 
 NetworkingContext* NetworkStorageSession::context() const
 }
 
 NetworkingContext* NetworkStorageSession::context() const
@@ -51,6 +55,19 @@ std::unique_ptr<NetworkStorageSession> NetworkStorageSession::createPrivateBrows
     return nullptr;
 }
 
     return nullptr;
 }
 
+static std::unique_ptr<NetworkStorageSession>& defaultSession()
+{
+    static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
+    return session;
+}
+
+NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
+{
+    if (!defaultSession())
+        defaultSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), nullptr);
+    return *defaultSession();
+}
+
 void NetworkStorageSession::switchToNewTestingSession()
 {
 }
 void NetworkStorageSession::switchToNewTestingSession()
 {
 }
index f3517cd..279d331 100644 (file)
 
 namespace WebCore {
 
 
 namespace WebCore {
 
-NetworkStorageSession::NetworkStorageSession(SessionID sessionID, RetainPtr<CFURLStorageSessionRef>&& platformSession)
-    : NetworkStorageSession(sessionID)
+NetworkStorageSession::NetworkStorageSession(SessionID sessionID, RetainPtr<CFURLStorageSessionRef> platformSession)
+    : m_sessionID(sessionID)
+    , m_platformSession(platformSession)
 {
 {
-    m_platformSession = WTFMove(platformSession);
+}
+
+static std::unique_ptr<NetworkStorageSession>& defaultNetworkStorageSession()
+{
+    ASSERT(isMainThread());
+    static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
+    return session;
 }
 
 void NetworkStorageSession::switchToNewTestingSession()
 }
 
 void NetworkStorageSession::switchToNewTestingSession()
@@ -52,12 +59,19 @@ void NetworkStorageSession::switchToNewTestingSession()
     // 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>).
     String sessionName = String::format("WebKit Test-%u", static_cast<uint32_t>(getCurrentProcessID()));
 #if PLATFORM(COCOA)
     // 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>).
     String sessionName = String::format("WebKit Test-%u", static_cast<uint32_t>(getCurrentProcessID()));
 #if PLATFORM(COCOA)
-    replaceDefaultSession(std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get()))));
+    defaultNetworkStorageSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get())));
 #else
 #else
-    replaceDefaultSession(std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get(), defaultStorageSession().platformSession()))));
+    defaultNetworkStorageSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get(), defaultNetworkStorageSession()->platformSession())));
 #endif
 }
 
 #endif
 }
 
+NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
+{
+    if (!defaultNetworkStorageSession())
+        defaultNetworkStorageSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), nullptr);
+    return *defaultNetworkStorageSession();
+}
+
 std::unique_ptr<NetworkStorageSession> NetworkStorageSession::createPrivateBrowsingSession(SessionID sessionID, const String& identifierBase)
 {
     RetainPtr<CFStringRef> cfIdentifier = String(identifierBase + ".PrivateBrowsing").createCFString();
 std::unique_ptr<NetworkStorageSession> NetworkStorageSession::createPrivateBrowsingSession(SessionID sessionID, const String& identifierBase)
 {
     RetainPtr<CFStringRef> cfIdentifier = String(identifierBase + ".PrivateBrowsing").createCFString();
@@ -65,7 +79,7 @@ std::unique_ptr<NetworkStorageSession> NetworkStorageSession::createPrivateBrows
 #if PLATFORM(COCOA)
     auto session = std::make_unique<NetworkStorageSession>(sessionID, adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get())));
 #else
 #if PLATFORM(COCOA)
     auto session = std::make_unique<NetworkStorageSession>(sessionID, adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get())));
 #else
-    auto session = std::make_unique<NetworkStorageSession>(sessionID, adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get(), defaultStorageSession().platformSession())));
+    auto session = std::make_unique<NetworkStorageSession>(sessionID, adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get(), defaultNetworkStorageSession()->platformSession())));
 #endif
 
     return session;
 #endif
 
     return session;
index b7034ed..dcda93b 100644 (file)
 namespace WebCore {
 
 NetworkStorageSession::NetworkStorageSession(SessionID sessionID, std::unique_ptr<SoupNetworkSession> session)
 namespace WebCore {
 
 NetworkStorageSession::NetworkStorageSession(SessionID sessionID, std::unique_ptr<SoupNetworkSession> session)
-    : NetworkStorageSession(sessionID)
+    : m_sessionID(sessionID)
+    , m_session(WTFMove(session))
 {
 {
-    m_session = WTFMove(session);
+}
+
+NetworkStorageSession::~NetworkStorageSession()
+{
+}
+
+static std::unique_ptr<NetworkStorageSession>& defaultSession()
+{
+    ASSERT(isMainThread());
+    static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
+    return session;
+}
+
+NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
+{
+    if (!defaultSession())
+        defaultSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), nullptr);
+    return *defaultSession();
 }
 
 std::unique_ptr<NetworkStorageSession> NetworkStorageSession::createPrivateBrowsingSession(SessionID sessionID, const String&)
 }
 
 std::unique_ptr<NetworkStorageSession> NetworkStorageSession::createPrivateBrowsingSession(SessionID sessionID, const String&)
@@ -50,7 +68,7 @@ std::unique_ptr<NetworkStorageSession> NetworkStorageSession::createPrivateBrows
 
 void NetworkStorageSession::switchToNewTestingSession()
 {
 
 void NetworkStorageSession::switchToNewTestingSession()
 {
-    replaceDefaultSession(std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), SoupNetworkSession::createTestingSession()));
+    defaultSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), SoupNetworkSession::createTestingSession());
 }
 
 SoupNetworkSession& NetworkStorageSession::soupNetworkSession() const
 }
 
 SoupNetworkSession& NetworkStorageSession::soupNetworkSession() const