Minor improvements to NetworkProcess
authormcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2019 19:18:59 +0000 (19:18 +0000)
committermcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2019 19:18:59 +0000 (19:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193708

Reviewed by Alex Christensen.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::switchToNewTestingSession): Fix a spelling error.
(WebKit::NetworkProcess::ensureSession): Add useful assertion.
(WebKit::NetworkProcess::defaultStorageSession const): Split into platform functions.
(WebKit::NetworkProcess::destroySession): Add useful assertion.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const):
* NetworkProcess/curl/NetworkProcessCurl.cpp:
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const):
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const):

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

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
Source/WebKit/NetworkProcess/curl/NetworkProcessCurl.cpp
Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp

index fae3d60..a5e2060 100644 (file)
@@ -1,3 +1,23 @@
+2019-01-23  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        Minor improvements to NetworkProcess
+        https://bugs.webkit.org/show_bug.cgi?id=193708
+
+        Reviewed by Alex Christensen.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::switchToNewTestingSession): Fix a spelling error.
+        (WebKit::NetworkProcess::ensureSession): Add useful assertion.
+        (WebKit::NetworkProcess::defaultStorageSession const): Split into platform functions.
+        (WebKit::NetworkProcess::destroySession): Add useful assertion.
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::NetworkProcess::platformCreateDefaultStorageSession const):
+        * NetworkProcess/curl/NetworkProcessCurl.cpp:
+        (WebKit::NetworkProcess::platformCreateDefaultStorageSession const):
+        * NetworkProcess/soup/NetworkProcessSoup.cpp:
+        (WebKit::NetworkProcess::platformCreateDefaultStorageSession const):
+
 2019-01-23  Daniel Bates  <dabates@apple.com>
 
         Fix the Apple Internal build. See <rdar://problem/47486758>.
index 6072011..48cfcd2 100644 (file)
@@ -475,7 +475,7 @@ void NetworkProcess::addWebsiteDataStore(WebsiteDataStoreParameters&& parameters
 void NetworkProcess::switchToNewTestingSession()
 {
 #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>).
+    // Session name should be short enough for shared memory region name to be under the limit, otherwise sandbox rules won't work (see <rdar://problem/13642852>).
     String sessionName = String::format("WebKit Test-%u", static_cast<uint32_t>(getCurrentProcessID()));
 
     auto session = adoptCF(WebCore::createPrivateStorageSession(sessionName.createCFString().get()));
@@ -499,6 +499,8 @@ void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, const String
 void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, const String& identifierBase)
 #endif
 {
+    ASSERT(sessionID != PAL::SessionID::defaultSessionID());
+
     auto addResult = m_networkStorageSessions.add(sessionID, nullptr);
     if (!addResult.isNewEntry)
         return;
@@ -532,19 +534,8 @@ WebCore::NetworkStorageSession* NetworkProcess::storageSession(const PAL::Sessio
 
 WebCore::NetworkStorageSession& NetworkProcess::defaultStorageSession() const
 {
-    if (m_defaultNetworkStorageSession)
-      return *m_defaultNetworkStorageSession;
-
-#if PLATFORM(COCOA)
-    m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID());
-#elif USE(SOUP)
-    m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID(), std::make_unique<SoupNetworkSession>(PAL::SessionID::defaultSessionID()));
-#elif USE(CURL)
-    m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID(), CurlContext::singleton());
-#else
-#error Implement me
-#endif
-
+    if (!m_defaultNetworkStorageSession)
+        m_defaultNetworkStorageSession = platformCreateDefaultStorageSession();
     return *m_defaultNetworkStorageSession;
 }
 
@@ -567,6 +558,8 @@ void NetworkProcess::setSession(const PAL::SessionID& sessionID, Ref<NetworkSess
 
 void NetworkProcess::destroySession(const PAL::SessionID& sessionID)
 {
+    ASSERT(sessionID != PAL::SessionID::defaultSessionID());
+
     if (auto session = m_networkSessions.take(sessionID))
         session->get().invalidateAndCancel();
     m_networkStorageSessions.remove(sessionID);
index afbebbd..b4753a0 100644 (file)
@@ -289,6 +289,7 @@ private:
     NetworkProcess();
 
     void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&);
+    std::unique_ptr<WebCore::NetworkStorageSession> platformCreateDefaultStorageSession() const;
 
     void terminate() override;
     void platformTerminate();
index 839b4a5..c306cce 100644 (file)
@@ -130,6 +130,11 @@ void NetworkProcess::platformInitializeNetworkProcessCocoa(const NetworkProcessC
     [NSURLCache setSharedURLCache:urlCache.get()];
 }
 
+std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const
+{
+    return std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID());
+}
+
 RetainPtr<CFDataRef> NetworkProcess::sourceApplicationAuditData() const
 {
 #if USE(SOURCE_APPLICATION_AUDIT_DATA)
index ab00a8c..fd5d6e5 100644 (file)
@@ -39,6 +39,11 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
 {
 }
 
+std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const
+{
+    return std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID(), CurlContext::singleton());
+}
+
 void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host)
 {
     notImplemented();
index 37bd6c2..acb92c6 100644 (file)
@@ -132,6 +132,11 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
     setIgnoreTLSErrors(parameters.ignoreTLSErrors);
 }
 
+std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const
+{
+    return std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID(), std::make_unique<SoupNetworkSession>(PAL::SessionID::defaultSessionID()));
+}
+
 void NetworkProcess::setIgnoreTLSErrors(bool ignoreTLSErrors)
 {
     SoupNetworkSession::setShouldIgnoreTLSErrors(ignoreTLSErrors);