Changeset 248010 in webkit
- Timestamp:
- Jul 30, 2019 9:31:05 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r248009 r248010 1 2019-07-24 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Move SoupNetworkSession ownership from NetworkStorageSession to NetworkSession 4 https://bugs.webkit.org/show_bug.cgi?id=200076 5 6 Reviewed by Michael Catanzaro. 7 8 Remove the SoupNetworkSession from NetworkStorageSession. 9 10 * platform/network/NetworkStorageSession.h: 11 (WebCore::NetworkStorageSession::cookieStorage const): Return the cookie jar. 12 * platform/network/StorageSessionProvider.h: 13 (WebCore::StorageSessionProvider::soupSession const): Temporary add this virtual method that is required by 14 SocketStreamHandleImplSoup. It will be removed once we switch to libsoup WebSockets API soon. 15 * platform/network/soup/DNSResolveQueueSoup.cpp: 16 (WebCore::globalDefaultSoupSessionAccessor): Rework the accessor to return the SoupSession directly since 17 that's what we really want. 18 (WebCore::DNSResolveQueueSoup::setGlobalDefaultSoupSessionAccessor): 19 (WebCore::DNSResolveQueueSoup::updateIsUsingProxy): 20 (WebCore::DNSResolveQueueSoup::platformResolve): 21 (WebCore::DNSResolveQueueSoup::resolve): 22 * platform/network/soup/DNSResolveQueueSoup.h: 23 * platform/network/soup/NetworkStorageSessionSoup.cpp: 24 (WebCore::NetworkStorageSession::NetworkStorageSession): Create and setup the default cookie jar. 25 (WebCore::NetworkStorageSession::~NetworkStorageSession): Only disconnect the cookie jar signals. 26 (WebCore::NetworkStorageSession::setCookieStorage): Update the cookie jar, now we know it's always a new one. 27 * platform/network/soup/SocketStreamHandleImplSoup.cpp: 28 (WebCore::SocketStreamHandleImpl::create): Use the new virtual method from StorageSessionProvider to get the SoupSession. 29 * platform/network/soup/SoupNetworkSession.cpp: 30 (WebCore::SoupNetworkSession::SoupNetworkSession): Remove the SoupCookieJar parameter. 31 * platform/network/soup/SoupNetworkSession.h: 32 1 33 2019-07-30 Michael Catanzaro <mcatanzaro@igalia.com> 2 34 -
trunk/Source/WebCore/platform/network/NetworkStorageSession.h
r245796 r248010 66 66 class NetworkingContext; 67 67 class ResourceRequest; 68 class SoupNetworkSession;69 68 70 69 struct Cookie; … … 98 97 WEBCORE_EXPORT static void setStorageAccessAPIEnabled(bool); 99 98 #elif USE(SOUP) 100 WEBCORE_EXPORT NetworkStorageSession(PAL::SessionID, std::unique_ptr<SoupNetworkSession>&&);99 WEBCORE_EXPORT explicit NetworkStorageSession(PAL::SessionID); 101 100 ~NetworkStorageSession(); 102 101 103 SoupNetworkSession& soupNetworkSession() const; 104 void clearSoupNetworkSession(); 105 SoupCookieJar* cookieStorage() const; 106 void setCookieStorage(SoupCookieJar*); 102 SoupCookieJar* cookieStorage() const { return m_cookieStorage.get(); } 103 void setCookieStorage(GRefPtr<SoupCookieJar>&&); 107 104 void setCookieObserverHandler(Function<void ()>&&); 108 105 void getCredentialFromPersistentStorage(const ProtectionSpace&, GCancellable*, Function<void (Credential&&)>&& completionHandler); … … 172 169 static void cookiesDidChange(NetworkStorageSession*); 173 170 174 mutable std::unique_ptr<SoupNetworkSession> m_session;171 GRefPtr<SoupCookieJar> m_cookieStorage; 175 172 Function<void ()> m_cookieObserverHandler; 176 173 #elif USE(CURL) -
trunk/Source/WebCore/platform/network/StorageSessionProvider.h
r240117 r248010 28 28 #include <wtf/ThreadSafeRefCounted.h> 29 29 30 #if USE(SOUP) 31 typedef struct _SoupSession SoupSession; 32 #endif 33 30 34 namespace PAL { 31 35 class SessionID; … … 40 44 virtual NetworkStorageSession* storageSession() const = 0; 41 45 46 #if USE(SOUP) 47 // FIXME: This is only required by SocketStreamHandleImplSoup, remove it when we switch to libsoup WebSockets API. 48 virtual SoupSession* soupSession() const { return nullptr; } 49 #endif 50 42 51 virtual ~StorageSessionProvider() { } 43 52 }; -
trunk/Source/WebCore/platform/network/soup/DNSResolveQueueSoup.cpp
r243163 r248010 30 30 #if USE(SOUP) 31 31 32 #include "NetworkStorageSession.h"33 #include "SoupNetworkSession.h"34 32 #include <libsoup/soup.h> 35 33 #include <wtf/CompletionHandler.h> … … 79 77 } 80 78 81 Function< NetworkStorageSession&()>& globalDefaultNetworkStorageSessionAccessor()82 { 83 static NeverDestroyed<Function< NetworkStorageSession&()>> accessor;79 Function<SoupSession*()>& globalDefaultSoupSessionAccessor() 80 { 81 static NeverDestroyed<Function<SoupSession*()>> accessor; 84 82 return accessor.get(); 85 83 } 86 84 87 void DNSResolveQueueSoup::setGlobalDefault NetworkStorageSessionAccessor(Function<NetworkStorageSession&()>&& accessor)88 { 89 globalDefault NetworkStorageSessionAccessor() = WTFMove(accessor);85 void DNSResolveQueueSoup::setGlobalDefaultSoupSessionAccessor(Function<SoupSession*()>&& accessor) 86 { 87 globalDefaultSoupSessionAccessor() = WTFMove(accessor); 90 88 } 91 89 … … 93 91 { 94 92 GRefPtr<GProxyResolver> resolver; 95 g_object_get(globalDefault NetworkStorageSessionAccessor()().soupNetworkSession().soupSession(), "proxy-resolver", &resolver.outPtr(), nullptr);93 g_object_get(globalDefaultSoupSessionAccessor()(), "proxy-resolver", &resolver.outPtr(), nullptr); 96 94 ASSERT(resolver); 97 95 … … 176 174 ASSERT(isMainThread()); 177 175 178 soup_session_prefetch_dns(globalDefault NetworkStorageSessionAccessor()().soupNetworkSession().soupSession(), hostname.utf8().data(), nullptr, resolvedCallback, nullptr);176 soup_session_prefetch_dns(globalDefaultSoupSessionAccessor()(), hostname.utf8().data(), nullptr, resolvedCallback, nullptr); 179 177 } 180 178 … … 185 183 auto address = adoptGRef(soup_address_new(hostname.utf8().data(), 0)); 186 184 auto cancellable = adoptGRef(g_cancellable_new()); 187 soup_address_resolve_async(address.get(), soup_session_get_async_context( WebCore::globalDefaultNetworkStorageSessionAccessor()().soupNetworkSession().soupSession()), cancellable.get(), resolvedWithObserverCallback, this);185 soup_address_resolve_async(address.get(), soup_session_get_async_context(globalDefaultSoupSessionAccessor()()), cancellable.get(), resolvedWithObserverCallback, this); 188 186 189 187 g_object_set_data(G_OBJECT(address.get()), "identifier", GUINT_TO_POINTER(identifier)); -
trunk/Source/WebCore/platform/network/soup/DNSResolveQueueSoup.h
r240292 r248010 31 31 #include <wtf/glib/GRefPtr.h> 32 32 33 typedef struct _SoupSession SoupSession; 34 33 35 namespace WebCore { 34 36 … … 40 42 41 43 DNSResolveQueueSoup() = default; 42 static void setGlobalDefault NetworkStorageSessionAccessor(Function<NetworkStorageSession&()>&&);44 static void setGlobalDefaultSoupSessionAccessor(Function<SoupSession*()>&&); 43 45 void resolve(const String& hostname, uint64_t identifier, DNSCompletionHandler&&) final; 44 46 void stopResolve(uint64_t identifier) final; -
trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
r246790 r248010 54 54 namespace WebCore { 55 55 56 NetworkStorageSession::NetworkStorageSession(PAL::SessionID sessionID , std::unique_ptr<SoupNetworkSession>&& session)56 NetworkStorageSession::NetworkStorageSession(PAL::SessionID sessionID) 57 57 : m_sessionID(sessionID) 58 , m_ session(WTFMove(session))59 { 60 ASSERT(m_session->cookieJar());61 g_signal_connect_swapped(m_ session->cookieJar(), "changed", G_CALLBACK(cookiesDidChange), this);58 , m_cookieStorage(adoptGRef(soup_cookie_jar_new())) 59 { 60 soup_cookie_jar_set_accept_policy(m_cookieStorage.get(), SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY); 61 g_signal_connect_swapped(m_cookieStorage.get(), "changed", G_CALLBACK(cookiesDidChange), this); 62 62 } 63 63 64 64 NetworkStorageSession::~NetworkStorageSession() 65 65 { 66 clearSoupNetworkSession(); 67 } 68 69 SoupNetworkSession& NetworkStorageSession::soupNetworkSession() const 70 { 71 ASSERT(m_session); 72 return *m_session.get(); 73 }; 74 75 void NetworkStorageSession::clearSoupNetworkSession() 76 { 77 if (m_session) { 78 ASSERT(m_session->cookieJar()); 79 g_signal_handlers_disconnect_matched(m_session->cookieJar(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); 80 } 81 82 m_session = nullptr; 83 m_cookieObserverHandler = nullptr; 66 g_signal_handlers_disconnect_matched(m_cookieStorage.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); 84 67 } 85 68 … … 90 73 } 91 74 92 SoupCookieJar* NetworkStorageSession::cookieStorage() const 93 { 94 ASSERT(m_session); 95 ASSERT(m_session->cookieJar()); 96 return m_session->cookieJar(); 97 } 98 99 void NetworkStorageSession::setCookieStorage(SoupCookieJar* jar) 100 { 101 ASSERT(jar); 102 ASSERT(m_session); 103 ASSERT(m_session->cookieJar()); 104 105 if (m_session->cookieJar() == jar) 106 return; 107 108 g_signal_handlers_disconnect_matched(m_session->cookieJar(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); 109 m_session->setCookieJar(jar); 110 g_signal_connect_swapped(m_session->cookieJar(), "changed", G_CALLBACK(cookiesDidChange), this); 75 void NetworkStorageSession::setCookieStorage(GRefPtr<SoupCookieJar>&& jar) 76 { 77 g_signal_handlers_disconnect_matched(m_cookieStorage.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); 78 m_cookieStorage = WTFMove(jar); 79 g_signal_connect_swapped(m_cookieStorage.get(), "changed", G_CALLBACK(cookiesDidChange), this); 111 80 } 112 81 -
trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp
r240340 r248010 37 37 #include "DeprecatedGlobalSettings.h" 38 38 #include "Logging.h" 39 #include "NetworkStorageSession.h"40 39 #include "ResourceError.h" 41 40 #include "SocketStreamError.h" 42 41 #include "SocketStreamHandleClient.h" 43 #include "SoupNetworkSession.h"44 42 #include "StorageSessionProvider.h" 45 43 #include "URLSoup.h" … … 88 86 89 87 #if SOUP_CHECK_VERSION(2, 61, 90) 90 auto* networkStorageSession = storageSessionProvider ? storageSessionProvider->storageSession() : nullptr;91 if (! networkStorageSession)88 auto* soupSession = storageSessionProvider ? storageSessionProvider->soupSession() : nullptr; 89 if (!soupSession) 92 90 return socket; 93 91 94 92 auto uri = urlToSoupURI(url); 95 93 Ref<SocketStreamHandle> protectedSocketStreamHandle = socket.copyRef(); 96 soup_session_connect_async( networkStorageSession->soupNetworkSession().soupSession(), uri.get(), socket->m_cancellable.get(),94 soup_session_connect_async(soupSession, uri.get(), socket->m_cancellable.get(), 97 95 url.protocolIs("wss") ? reinterpret_cast<SoupSessionConnectProgressCallback>(connectProgressCallback) : nullptr, 98 96 reinterpret_cast<GAsyncReadyCallback>(connectedCallback), &protectedSocketStreamHandle.leakRef()); -
trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp
r246677 r248010 107 107 } 108 108 109 SoupNetworkSession::SoupNetworkSession(PAL::SessionID sessionID , SoupCookieJar* cookieJar)109 SoupNetworkSession::SoupNetworkSession(PAL::SessionID sessionID) 110 110 : m_soupSession(adoptGRef(soup_session_new())) 111 111 { … … 117 117 static const int maxConnectionsPerHost = 6; 118 118 119 GRefPtr<SoupCookieJar> jar = cookieJar;120 if (!jar) {121 jar = adoptGRef(soup_cookie_jar_new());122 soup_cookie_jar_set_accept_policy(jar.get(), SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY);123 }124 125 119 g_object_set(m_soupSession.get(), 126 120 SOUP_SESSION_MAX_CONNS, maxConnections, … … 129 123 SOUP_SESSION_IDLE_TIMEOUT, 0, 130 124 SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_SNIFFER, 131 SOUP_SESSION_ADD_FEATURE, jar.get(),132 125 nullptr); 133 126 -
trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.h
r239427 r248010 50 50 WTF_MAKE_NONCOPYABLE(SoupNetworkSession); WTF_MAKE_FAST_ALLOCATED; 51 51 public: 52 explicit SoupNetworkSession(PAL::SessionID = PAL::SessionID::defaultSessionID(), SoupCookieJar* = nullptr);52 explicit SoupNetworkSession(PAL::SessionID); 53 53 ~SoupNetworkSession(); 54 54 -
trunk/Source/WebKit/ChangeLog
r248006 r248010 1 2019-07-24 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Move SoupNetworkSession ownership from NetworkStorageSession to NetworkSession 4 https://bugs.webkit.org/show_bug.cgi?id=200076 5 6 Reviewed by Michael Catanzaro. 7 8 NetworkStorageSession should only own the cookie jar, since it's the only thing it handles from the session. 9 10 * NetworkProcess/Cookies/soup/WebCookieManagerSoup.cpp: 11 (WebKit::WebCookieManager::setCookiePersistentStorage): Use the network session instead of the storage session 12 to set the peristent cookie storage. 13 * NetworkProcess/CustomProtocols/soup/LegacyCustomProtocolManagerSoup.cpp: 14 (WebKit::LegacyCustomProtocolManager::registerScheme): Iterate network sessions instead of storage sessions to 15 access the SoupNetworkSession. 16 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 17 (WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated): Use 18 NetworkProcess::forEachNetworkSession() to iterate network sessions. 19 * NetworkProcess/NetworkProcess.cpp: 20 (WebKit::NetworkProcess::lowMemoryHandler): Ditto. 21 (WebKit::NetworkProcess::forEachNetworkSession): Added to iterate network sessions intead of exposing the map 22 that is always used to iterate the sessions. 23 (WebKit::NetworkProcess::switchToNewTestingSession): Use the new NetworkStorageSession constructor API. 24 (WebKit::NetworkProcess::ensureSession): Ditto. 25 (WebKit::NetworkProcess::destroySession): Allow to destroy the default session for soup based ports. This is 26 only called right before process exit to ensure we don't leak network resources like the cookies database. 27 (WebKit::NetworkProcess::setResourceLoadStatisticsEnabled): Use NetworkProcess::forEachNetworkSession() to 28 iterate network sessions. 29 (WebKit::NetworkProcess::fetchWebsiteData): Ditto. 30 (WebKit::NetworkProcess::deleteWebsiteDataForOrigins): Ditto. 31 (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains): Ditto. 32 (WebKit::NetworkProcess::registrableDomainsWithWebsiteData): Ditto. 33 (WebKit::NetworkProcess::setCacheModel): Ditto. 34 (WebKit::NetworkProcess::actualPrepareToSuspend): Ditto. 35 (WebKit::NetworkProcess::resume): Ditto. 36 * NetworkProcess/NetworkProcess.h: 37 * NetworkProcess/NetworkStorageSessionProvider.h: 38 * NetworkProcess/cocoa/NetworkProcessCocoa.mm: 39 (WebKit::NetworkProcess::clearDiskCache): Ditto. 40 * NetworkProcess/ios/NetworkProcessIOS.mm: 41 (WebKit::NetworkProcess::clearCacheForAllOrigins): Ditto. 42 * NetworkProcess/soup/NetworkProcessMainSoup.cpp: Destroy the default session before process exists. 43 * NetworkProcess/soup/NetworkProcessSoup.cpp: 44 (WebKit::NetworkProcess::userPreferredLanguagesChanged): Iterate network sessions instead of storage sessions to 45 access the SoupNetworkSession. 46 (WebKit::NetworkProcess::platformCreateDefaultStorageSession const): Use the new NetworkStorageSession constructor API. 47 (WebKit::NetworkProcess::clearDiskCache): Use NetworkProcess::forEachNetworkSession() to iterate network sessions. 48 (WebKit::NetworkProcess::setNetworkProxySettings): Iterate network sessions instead of storage sessions to 49 access the SoupNetworkSession. 50 * NetworkProcess/soup/NetworkSessionSoup.cpp: 51 (WebKit::NetworkSessionSoup::NetworkSessionSoup): Create the SoupNetworkSession and setup cookies. 52 (WebKit::NetworkSessionSoup::soupSession const): Return the SoupSession of SoupNetworkSession. 53 (WebKit::NetworkSessionSoup::setCookiePersistentStorage): Setup a new cookie jar. 54 * NetworkProcess/soup/NetworkSessionSoup.h: 55 1 56 2019-07-30 Truitt Savell <tsavell@apple.com> 2 57 -
trunk/Source/WebKit/NetworkProcess/Cookies/soup/WebCookieManagerSoup.cpp
r247188 r248010 28 28 29 29 #include "NetworkProcess.h" 30 #include "NetworkSessionSoup.h" 30 31 #include "SoupCookiePersistentStorageType.h" 31 32 #include <WebCore/NetworkStorageSession.h> 32 33 #include <WebCore/SoupNetworkSession.h> 33 34 #include <libsoup/soup.h> 34 #include <wtf/glib/GRefPtr.h>35 #include <wtf/text/CString.h>36 35 37 36 namespace WebKit { … … 78 77 void WebCookieManager::setCookiePersistentStorage(PAL::SessionID sessionID, const String& storagePath, SoupCookiePersistentStorageType storageType) 79 78 { 80 GRefPtr<SoupCookieJar> jar; 81 switch (storageType) { 82 case SoupCookiePersistentStorageType::Text: 83 jar = adoptGRef(soup_cookie_jar_text_new(storagePath.utf8().data(), FALSE)); 84 break; 85 case SoupCookiePersistentStorageType::SQLite: 86 jar = adoptGRef(soup_cookie_jar_db_new(storagePath.utf8().data(), FALSE)); 87 break; 88 default: 89 ASSERT_NOT_REACHED(); 90 } 91 92 if (auto* storageSession = m_process.storageSession(sessionID)) { 93 soup_cookie_jar_set_accept_policy(jar.get(), soup_cookie_jar_get_accept_policy(storageSession->cookieStorage())); 94 storageSession->setCookieStorage(jar.get()); 95 } 79 if (auto* networkSession = m_process.networkSession(sessionID)) 80 static_cast<NetworkSessionSoup&>(*networkSession).setCookiePersistentStorage(storagePath, storageType); 96 81 } 97 82 -
trunk/Source/WebKit/NetworkProcess/CustomProtocols/soup/LegacyCustomProtocolManagerSoup.cpp
r240366 r248010 24 24 #include "LegacyCustomProtocolManagerMessages.h" 25 25 #include "NetworkProcess.h" 26 #include "NetworkSessionSoup.h" 26 27 #include "WebKitSoupRequestInputStream.h" 27 #include <WebCore/NetworkStorageSession.h>28 28 #include <WebCore/NotImplemented.h> 29 29 #include <WebCore/ResourceError.h> … … 103 103 ASSERT(genericRequestClass); 104 104 genericRequestClass->schemes = const_cast<const char**>(reinterpret_cast<char**>(m_registeredSchemes->pdata)); 105 lastCreatedNetworkProcess()->forEachNetworkS torageSession([](const auto& session) {106 s ession.soupNetworkSession().setupCustomProtocols();105 lastCreatedNetworkProcess()->forEachNetworkSession([](const auto& session) { 106 static_cast<const NetworkSessionSoup&>(session).soupNetworkSession().setupCustomProtocols(); 107 107 }); 108 108 } -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r247908 r248010 101 101 102 102 #if USE(SOUP) 103 #include "NetworkSessionSoup.h" 103 104 #include <WebCore/DNSResolveQueueSoup.h> 104 105 #include <WebCore/SoupNetworkSession.h> … … 152 153 153 154 #if USE(SOUP) 154 DNSResolveQueueSoup::setGlobalDefault NetworkStorageSessionAccessor([this]() -> NetworkStorageSession&{155 return defaultStorageSession();155 DNSResolveQueueSoup::setGlobalDefaultSoupSessionAccessor([this]() -> SoupSession* { 156 return static_cast<NetworkSessionSoup&>(*networkSession(PAL::SessionID::defaultSessionID())).soupSession(); 156 157 }); 157 158 #endif … … 275 276 WTF::releaseFastMallocFreeMemory(); 276 277 277 for (auto& networkSession : m_networkSessions.values()) 278 networkSession->clearPrefetchCache(); 278 forEachNetworkSession([](auto& networkSession) { 279 networkSession.clearPrefetchCache(); 280 }); 279 281 } 280 282 … … 487 489 } 488 490 491 void NetworkProcess::forEachNetworkSession(const Function<void(NetworkSession&)>& functor) 492 { 493 for (auto& session : m_networkSessions.values()) 494 functor(*session); 495 } 496 489 497 void NetworkProcess::switchToNewTestingSession() 490 498 { … … 503 511 504 512 m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID(), WTFMove(session), WTFMove(cookieStorage)); 505 #elif USE(SOUP) 506 m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID(), std::make_unique<WebCore::SoupNetworkSession>()); 507 #elif USE(CURL) 513 #elif USE(CURL) || USE(SOUP) 508 514 m_defaultNetworkStorageSession = std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID()); 509 515 #endif … … 537 543 538 544 addResult.iterator->value = std::make_unique<NetworkStorageSession>(sessionID, WTFMove(storageSession), WTFMove(cookieStorage)); 539 #elif USE(SOUP) 540 addResult.iterator->value = std::make_unique<NetworkStorageSession>(sessionID, std::make_unique<SoupNetworkSession>(sessionID)); 541 #elif USE(CURL) 545 #elif USE(CURL) || USE(SOUP) 542 546 addResult.iterator->value = std::make_unique<NetworkStorageSession>(sessionID); 543 547 #endif … … 595 599 return; 596 600 601 #if !USE(SOUP) 602 // Soup based ports destroy the default session right before the process exits to avoid leaking 603 // network resources like the cookies database. 597 604 ASSERT(sessionID != PAL::SessionID::defaultSessionID()); 605 #endif 598 606 599 607 if (auto session = m_networkSessions.take(sessionID)) … … 1147 1155 void NetworkProcess::setResourceLoadStatisticsEnabled(bool enabled) 1148 1156 { 1149 for (auto& networkSession : m_networkSessions.values()) 1150 networkSession->setResourceLoadStatisticsEnabled(enabled); 1157 forEachNetworkSession([enabled](auto& networkSession) { 1158 networkSession.setResourceLoadStatisticsEnabled(enabled); 1159 }); 1151 1160 } 1152 1161 … … 1360 1369 #endif 1361 1370 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1362 for (auto& session : networkSessions().values()) {1363 fetchDiskCacheEntries(session ->cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {1371 forEachNetworkSession([sessionID, fetchOptions, &callbackAggregator](auto& session) { 1372 fetchDiskCacheEntries(session.cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1364 1373 callbackAggregator->m_websiteData.entries.appendVector(entries); 1365 1374 }); 1366 } 1375 }); 1367 1376 } 1368 1377 } … … 1520 1529 1521 1530 if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) { 1522 for (auto& session : networkSessions().values()) 1523 clearDiskCacheEntries(session->cache(), originDatas, [clearTasksHandler = clearTasksHandler.copyRef()] { }); 1531 forEachNetworkSession([originDatas, &clearTasksHandler](auto& session) { 1532 clearDiskCacheEntries(session.cache(), originDatas, [clearTasksHandler = clearTasksHandler.copyRef()] { }); 1533 }); 1524 1534 } 1525 1535 … … 1755 1765 1756 1766 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1757 for (auto& session : networkSessions().values()) {1758 fetchDiskCacheEntries(session ->cache(), sessionID, fetchOptions, [domainsToDeleteAllButCookiesFor, callbackAggregator = callbackAggregator.copyRef(), session = makeWeakPtr(session.get())](auto entries) mutable {1767 forEachNetworkSession([sessionID, fetchOptions, &domainsToDeleteAllButCookiesFor, &callbackAggregator](auto& session) { 1768 fetchDiskCacheEntries(session.cache(), sessionID, fetchOptions, [domainsToDeleteAllButCookiesFor, callbackAggregator = callbackAggregator.copyRef(), session = makeWeakPtr(&session)](auto entries) mutable { 1759 1769 if (!session) 1760 1770 return; … … 1769 1779 clearDiskCacheEntries(session->cache(), entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { }); 1770 1780 }); 1771 } 1781 }); 1772 1782 } 1773 1783 … … 1891 1901 1892 1902 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1893 for (auto& session : networkSessions().values()) {1894 fetchDiskCacheEntries(session ->cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {1903 forEachNetworkSession([sessionID, fetchOptions, &callbackAggregator](auto& session) { 1904 fetchDiskCacheEntries(session.cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1895 1905 callbackAggregator->m_websiteData.entries.appendVector(entries); 1896 1906 }); 1897 } 1907 }); 1898 1908 } 1899 1909 } … … 1987 1997 calculateURLCacheSizes(cacheModel, diskFreeSize, urlCacheMemoryCapacity, urlCacheDiskCapacity); 1988 1998 } 1989 1990 for (auto& session : networkSessions().values()) {1991 if (auto* cache = session ->cache())1999 2000 forEachNetworkSession([urlCacheDiskCapacity](auto& session) { 2001 if (auto* cache = session.cache()) 1992 2002 cache->setCapacity(urlCacheDiskCapacity); 1993 } 2003 }); 1994 2004 } 1995 2005 … … 2085 2095 #endif 2086 2096 2087 for (auto& session : m_networkSessions) 2088 session.value->storageManager().suspend([callbackAggregator] { }); 2097 forEachNetworkSession([&callbackAggregator](auto& session) { 2098 session.storageManager().suspend([callbackAggregator] { }); 2099 }); 2089 2100 } 2090 2101 … … 2156 2167 #endif 2157 2168 2158 for (auto& session : m_networkSessions) 2159 session.value->storageManager().resume(); 2169 forEachNetworkSession([](auto& session) { 2170 session.storageManager().resume(); 2171 }); 2160 2172 } 2161 2173 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r247831 r248010 167 167 void destroySession(const PAL::SessionID&); 168 168 169 // Needed for test infrastructure 170 HashMap<PAL::SessionID, std::unique_ptr<NetworkSession>>& networkSessions() { return m_networkSessions; } 169 void forEachNetworkSession(const Function<void(NetworkSession&)>&); 171 170 172 171 void forEachNetworkStorageSession(const Function<void(WebCore::NetworkStorageSession&)>&); -
trunk/Source/WebKit/NetworkProcess/NetworkStorageSessionProvider.h
r240292 r248010 32 32 #include <wtf/WeakPtr.h> 33 33 34 #if USE(SOUP) 35 #include "NetworkSessionSoup.h" 36 #endif 37 34 38 namespace WebKit { 35 39 … … 50 54 } 51 55 56 #if USE(SOUP) 57 SoupSession* soupSession() const final 58 { 59 if (!m_networkProcess) 60 return nullptr; 61 62 if (auto* session = m_networkProcess->networkSession(m_sessionID)) 63 return static_cast<NetworkSessionSoup&>(*session).soupSession(); 64 65 return nullptr; 66 } 67 #endif 68 52 69 WeakPtr<NetworkProcess> m_networkProcess; 53 70 PAL::SessionID m_sessionID; -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r247567 r248010 200 200 dispatch_group_async(group, dispatch_get_main_queue(), makeBlockPtr([this, protectedThis = makeRef(*this), modifiedSince, completionHandler = WTFMove(completionHandler)] () mutable { 201 201 auto aggregator = CallbackAggregator::create(WTFMove(completionHandler)); 202 for (auto& session : networkSessions().values()) {203 if (auto* cache = session ->cache())202 forEachNetworkSession([modifiedSince, &aggregator](NetworkSession& session) { 203 if (auto* cache = session.cache()) 204 204 cache->clear(modifiedSince, [aggregator = aggregator.copyRef()] () { }); 205 } 205 }); 206 206 }).get()); 207 207 } -
trunk/Source/WebKit/NetworkProcess/ios/NetworkProcessIOS.mm
r247567 r248010 79 79 if (resourceCachesToClear == InMemoryResourceCachesOnly) 80 80 return; 81 for (auto& session : networkSessions().values()) {82 if (auto* cache = session ->cache())81 forEachNetworkSession([](NetworkSession& session) { 82 if (auto* cache = session.cache()) 83 83 cache->clear(); 84 } 84 }); 85 85 } 86 86 -
trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessMainSoup.cpp
r240683 r248010 42 42 // Needed to destroy the SoupSession and SoupCookieJar, e.g. to avoid 43 43 // leaking SQLite temporary journaling files. 44 globalNetworkProcess->de faultStorageSession().clearSoupNetworkSession();44 globalNetworkProcess->destroySession(PAL::SessionID::defaultSessionID()); 45 45 } 46 46 }; -
trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp
r247567 r248010 30 30 #include "NetworkCache.h" 31 31 #include "NetworkProcessCreationParameters.h" 32 #include "NetworkSession .h"32 #include "NetworkSessionSoup.h" 33 33 #include "ResourceCachesToClear.h" 34 34 #include "WebCookieManager.h" … … 100 100 auto acceptLanguages = buildAcceptLanguages(languages); 101 101 SoupNetworkSession::setInitialAcceptLanguages(acceptLanguages); 102 forEachNetworkS torageSession([&acceptLanguages](const auto& session) {103 s ession.soupNetworkSession().setAcceptLanguages(acceptLanguages);102 forEachNetworkSession([&acceptLanguages](const auto& session) { 103 static_cast<const NetworkSessionSoup&>(session).soupNetworkSession().setAcceptLanguages(acceptLanguages); 104 104 }); 105 105 } … … 134 134 std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const 135 135 { 136 return std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID() , std::make_unique<SoupNetworkSession>(PAL::SessionID::defaultSessionID()));136 return std::make_unique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID()); 137 137 } 138 138 … … 158 158 { 159 159 auto aggregator = CallbackAggregator::create(WTFMove(completionHandler)); 160 for (auto& session : networkSessions().values()) {161 if (auto* cache = session ->cache())160 forEachNetworkSession([modifiedSince, &aggregator](NetworkSession& session) { 161 if (auto* cache = session.cache()) 162 162 cache->clear(modifiedSince, [aggregator = aggregator.copyRef()] () { }); 163 } 163 }); 164 164 } 165 165 … … 172 172 { 173 173 SoupNetworkSession::setProxySettings(settings); 174 forEachNetworkS torageSession([](const auto& session) {175 s ession.soupNetworkSession().setupProxy();174 forEachNetworkSession([](const auto& session) { 175 static_cast<const NetworkSessionSoup&>(session).soupNetworkSession().setupProxy(); 176 176 }); 177 177 } -
trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp
r247567 r248010 42 42 NetworkSessionSoup::NetworkSessionSoup(NetworkProcess& networkProcess, NetworkSessionCreationParameters&& parameters) 43 43 : NetworkSession(networkProcess, parameters) 44 , m_networkSession(std::make_unique<SoupNetworkSession>(m_sessionID)) 44 45 { 45 networkStorageSession()->setCookieObserverHandler([this] { 46 auto* storageSession = networkStorageSession(); 47 ASSERT(storageSession); 48 49 if (!parameters.cookiePersistentStoragePath.isEmpty()) 50 setCookiePersistentStorage(parameters.cookiePersistentStoragePath, parameters.cookiePersistentStorageType); 51 else 52 m_networkSession->setCookieJar(storageSession->cookieStorage()); 53 54 storageSession->setCookieObserverHandler([this] { 46 55 this->networkProcess().supplement<WebCookieManager>()->notifyCookiesDidChange(m_sessionID); 47 56 }); 48 49 if (!parameters.cookiePersistentStoragePath.isEmpty())50 this->networkProcess().supplement<WebCookieManager>()->setCookiePersistentStorage(m_sessionID, parameters.cookiePersistentStoragePath, parameters.cookiePersistentStorageType);51 57 } 52 58 … … 59 65 SoupSession* NetworkSessionSoup::soupSession() const 60 66 { 61 return networkStorageSession()->soupNetworkSession().soupSession(); 67 return m_networkSession->soupSession(); 68 } 69 70 void NetworkSessionSoup::setCookiePersistentStorage(const String& storagePath, SoupCookiePersistentStorageType storageType) 71 { 72 auto* storageSession = networkStorageSession(); 73 if (!storageSession) 74 return; 75 76 GRefPtr<SoupCookieJar> jar; 77 switch (storageType) { 78 case SoupCookiePersistentStorageType::Text: 79 jar = adoptGRef(soup_cookie_jar_text_new(storagePath.utf8().data(), FALSE)); 80 break; 81 case SoupCookiePersistentStorageType::SQLite: 82 jar = adoptGRef(soup_cookie_jar_db_new(storagePath.utf8().data(), FALSE)); 83 break; 84 default: 85 ASSERT_NOT_REACHED(); 86 } 87 88 soup_cookie_jar_set_accept_policy(jar.get(), soup_cookie_jar_get_accept_policy(storageSession->cookieStorage())); 89 storageSession->setCookieStorage(WTFMove(jar)); 90 91 m_networkSession->setCookieJar(storageSession->cookieStorage()); 62 92 } 63 93 -
trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h
r247831 r248010 27 27 28 28 #include "NetworkSession.h" 29 #include "SoupCookiePersistentStorageType.h" 29 30 30 31 typedef struct _SoupSession SoupSession; 32 33 namespace WebCore { 34 class SoupNetworkSession; 35 } 31 36 32 37 namespace WebKit { … … 45 50 ~NetworkSessionSoup(); 46 51 52 WebCore::SoupNetworkSession& soupNetworkSession() const { return *m_networkSession; } 47 53 SoupSession* soupSession() const; 54 55 void setCookiePersistentStorage(const String& storagePath, SoupCookiePersistentStorageType); 48 56 49 57 private: 50 58 std::unique_ptr<WebSocketTask> createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) final; 51 59 void clearCredentials() final; 60 61 std::unique_ptr<WebCore::SoupNetworkSession> m_networkSession; 52 62 }; 53 63
Note: See TracChangeset
for help on using the changeset viewer.