Skip to content
Permalink
Browse files
REGRESSION(r267763): [SOUP] After network process crash, all cookies …
…are lost until browser is restarted

https://bugs.webkit.org/show_bug.cgi?id=228128

Reviewed by Adrian Perez de Castro.

Cookies configuration is no longer stored to be sent again to the new network process after a crash.

* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::encode const): Encode cookieAcceptPolicy.
(WebKit::NetworkSessionCreationParameters::decode): Decode cookieAcceptPolicy.
* NetworkProcess/NetworkSessionCreationParameters.h: Add cookieAcceptPolicy.
* NetworkProcess/soup/NetworkSessionSoup.cpp:
(WebKit::NetworkSessionSoup::NetworkSessionSoup): Set cookie accept policy on NetworkStorageSession.
* UIProcess/API/glib/WebKitCookieManager.cpp:
(webkit_cookie_manager_set_persistent_storage): Use WebsiteDataStore API to cache the given values.
(webkit_cookie_manager_set_accept_policy): Ditto.
* UIProcess/WebCookieManagerProxy.h:
* UIProcess/WebsiteData/WebsiteDataStore.h:
* UIProcess/WebsiteData/soup/WebsiteDataStoreSoup.cpp:
(WebKit::WebsiteDataStore::platformSetNetworkParameters): Set cached cookie settings to network session parameters.
(WebKit::WebsiteDataStore::setCookiePersistentStorage): Cache the given value and notify the cookie manager.
(WebKit::WebsiteDataStore::setHTTPCookieAcceptPolicy): Ditto.
* UIProcess/soup/WebCookieManagerProxySoup.cpp:
(WebKit::WebCookieManagerProxy::getCookiePersistentStorage const): Deleted.

Canonical link: https://commits.webkit.org/239838@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280128 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Jul 21, 2021
1 parent 41d205c commit 12d00c369b5f2fbef9406abfcb8dbe29a0090131
Showing 9 changed files with 72 additions and 19 deletions.
@@ -1,3 +1,30 @@
2021-07-21 Carlos Garcia Campos <cgarcia@igalia.com>

REGRESSION(r267763): [SOUP] After network process crash, all cookies are lost until browser is restarted
https://bugs.webkit.org/show_bug.cgi?id=228128

Reviewed by Adrian Perez de Castro.

Cookies configuration is no longer stored to be sent again to the new network process after a crash.

* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::encode const): Encode cookieAcceptPolicy.
(WebKit::NetworkSessionCreationParameters::decode): Decode cookieAcceptPolicy.
* NetworkProcess/NetworkSessionCreationParameters.h: Add cookieAcceptPolicy.
* NetworkProcess/soup/NetworkSessionSoup.cpp:
(WebKit::NetworkSessionSoup::NetworkSessionSoup): Set cookie accept policy on NetworkStorageSession.
* UIProcess/API/glib/WebKitCookieManager.cpp:
(webkit_cookie_manager_set_persistent_storage): Use WebsiteDataStore API to cache the given values.
(webkit_cookie_manager_set_accept_policy): Ditto.
* UIProcess/WebCookieManagerProxy.h:
* UIProcess/WebsiteData/WebsiteDataStore.h:
* UIProcess/WebsiteData/soup/WebsiteDataStoreSoup.cpp:
(WebKit::WebsiteDataStore::platformSetNetworkParameters): Set cached cookie settings to network session parameters.
(WebKit::WebsiteDataStore::setCookiePersistentStorage): Cache the given value and notify the cookie manager.
(WebKit::WebsiteDataStore::setHTTPCookieAcceptPolicy): Ditto.
* UIProcess/soup/WebCookieManagerProxySoup.cpp:
(WebKit::WebCookieManagerProxy::getCookiePersistentStorage const): Deleted.

2021-07-20 Wenson Hsieh <wenson_hsieh@apple.com>

[iOS] Add SPI for internal clients to consult whether or not viewport quirks should be enabled
@@ -64,6 +64,7 @@ void NetworkSessionCreationParameters::encode(IPC::Encoder& encoder) const
encoder << persistentCredentialStorageEnabled;
encoder << ignoreTLSErrors;
encoder << proxySettings;
encoder << cookieAcceptPolicy;
#endif
#if USE(CURL)
encoder << cookiePersistentStorageFile;
@@ -189,6 +190,11 @@ std::optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters
decoder >> proxySettings;
if (!proxySettings)
return std::nullopt;

std::optional<WebCore::HTTPCookieAcceptPolicy> cookieAcceptPolicy;
decoder >> cookieAcceptPolicy;
if (!cookieAcceptPolicy)
return std::nullopt;
#endif

#if USE(CURL)
@@ -318,6 +324,7 @@ std::optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters
, WTFMove(*persistentCredentialStorageEnabled)
, WTFMove(*ignoreTLSErrors)
, WTFMove(*proxySettings)
, WTFMove(*cookieAcceptPolicy)
#endif
#if USE(CURL)
, WTFMove(*cookiePersistentStorageFile)
@@ -33,6 +33,7 @@

#if USE(SOUP)
#include "SoupCookiePersistentStorageType.h"
#include <WebCore/HTTPCookieAcceptPolicy.h>
#include <WebCore/SoupNetworkProxySettings.h>
#endif

@@ -77,6 +78,7 @@ struct NetworkSessionCreationParameters {
bool persistentCredentialStorageEnabled { true };
bool ignoreTLSErrors { false };
WebCore::SoupNetworkProxySettings proxySettings;
WebCore::HTTPCookieAcceptPolicy cookieAcceptPolicy { WebCore::HTTPCookieAcceptPolicy::ExclusivelyFromMainDocumentDomain };
#endif
#if USE(CURL)
String cookiePersistentStorageFile;
@@ -47,6 +47,8 @@ NetworkSessionSoup::NetworkSessionSoup(NetworkProcess& networkProcess, NetworkSe
auto* storageSession = networkStorageSession();
ASSERT(storageSession);

storageSession->setCookieAcceptPolicy(parameters.cookieAcceptPolicy);

setIgnoreTLSErrors(parameters.ignoreTLSErrors);

if (parameters.proxySettings.mode != SoupNetworkProxySettings::Mode::Default)
@@ -194,7 +194,8 @@ void webkit_cookie_manager_set_persistent_storage(WebKitCookieManager* manager,
if (sessionID.isEphemeral())
return;

manager->priv->cookieManager().setCookiePersistentStorage(sessionID, String::fromUTF8(filename), toSoupCookiePersistentStorageType(storage));
auto& websiteDataStore = webkitWebsiteDataManagerGetDataStore(manager->priv->dataManager);
websiteDataStore.setCookiePersistentStorage(String::fromUTF8(filename), toSoupCookiePersistentStorageType(storage));
}

/**
@@ -212,7 +213,8 @@ void webkit_cookie_manager_set_accept_policy(WebKitCookieManager* manager, WebKi
{
g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager));

manager->priv->cookieManager().setHTTPCookieAcceptPolicy(manager->priv->sessionID(), toHTTPCookieAcceptPolicy(policy), []() { });
auto& websiteDataStore = webkitWebsiteDataManagerGetDataStore(manager->priv->dataManager);
websiteDataStore.setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
}

/**
@@ -87,7 +87,6 @@ class WebCookieManagerProxy : public IPC::MessageReceiver {

#if USE(SOUP)
void setCookiePersistentStorage(PAL::SessionID, const String& storagePath, SoupCookiePersistentStorageType);
void getCookiePersistentStorage(PAL::SessionID, String& storagePath, SoupCookiePersistentStorageType&) const;
#endif

private:
@@ -99,11 +98,6 @@ class WebCookieManagerProxy : public IPC::MessageReceiver {
HashMap<PAL::SessionID, WeakHashSet<Observer>> m_cookieObservers;

WeakPtr<NetworkProcessProxy> m_networkProcess;

#if USE(SOUP)
using CookiePersistentStorageMap = HashMap<PAL::SessionID, std::pair<String, SoupCookiePersistentStorageType>>;
CookiePersistentStorageMap m_cookiePersistentStorageMap;
#endif
};

} // namespace WebKit
@@ -62,6 +62,8 @@
#endif

#if USE(SOUP)
#include "SoupCookiePersistentStorageType.h"
#include <WebCore/HTTPCookieAcceptPolicy.h>
#include <WebCore/SoupNetworkProxySettings.h>
#endif

@@ -290,6 +292,8 @@ class WebsiteDataStore : public API::ObjectImpl<API::Object::Type::WebsiteDataSt
bool ignoreTLSErrors() const { return m_ignoreTLSErrors; }
void setNetworkProxySettings(WebCore::SoupNetworkProxySettings&&);
const WebCore::SoupNetworkProxySettings& networkProxySettings() const { return m_networkProxySettings; }
void setCookiePersistentStorage(const String&, SoupCookiePersistentStorageType);
void setHTTPCookieAcceptPolicy(WebCore::HTTPCookieAcceptPolicy);
#endif

static void allowWebsiteDataRecordsForAllOrigins();
@@ -433,6 +437,9 @@ class WebsiteDataStore : public API::ObjectImpl<API::Object::Type::WebsiteDataSt
bool m_persistentCredentialStorageEnabled { true };
bool m_ignoreTLSErrors { true };
WebCore::SoupNetworkProxySettings m_networkProxySettings;
String m_cookiePersistentStoragePath;
SoupCookiePersistentStorageType m_cookiePersistentStorageType { SoupCookiePersistentStorageType::SQLite };
WebCore::HTTPCookieAcceptPolicy m_cookieAcceptPolicy { WebCore::HTTPCookieAcceptPolicy::ExclusivelyFromMainDocumentDomain };
#endif

WeakHashSet<WebProcessProxy> m_processes;
@@ -41,8 +41,9 @@ void WebsiteDataStore::platformSetNetworkParameters(WebsiteDataStoreParameters&
networkSessionParameters.persistentCredentialStorageEnabled = m_persistentCredentialStorageEnabled;
networkSessionParameters.ignoreTLSErrors = m_ignoreTLSErrors;
networkSessionParameters.proxySettings = m_networkProxySettings;

networkProcess().cookieManager().getCookiePersistentStorage(m_sessionID, networkSessionParameters.cookiePersistentStoragePath, networkSessionParameters.cookiePersistentStorageType);
networkSessionParameters.cookiePersistentStoragePath = m_cookiePersistentStoragePath;
networkSessionParameters.cookiePersistentStorageType = m_cookiePersistentStorageType;
networkSessionParameters.cookieAcceptPolicy = m_cookieAcceptPolicy;
}

void WebsiteDataStore::setPersistentCredentialStorageEnabled(bool enabled)
@@ -72,4 +73,23 @@ void WebsiteDataStore::setNetworkProxySettings(WebCore::SoupNetworkProxySettings
networkProcess().send(Messages::NetworkProcess::SetNetworkProxySettings(m_sessionID, m_networkProxySettings), 0);
}

void WebsiteDataStore::setCookiePersistentStorage(const String& storagePath, SoupCookiePersistentStorageType storageType)
{
if (m_cookiePersistentStoragePath == storagePath && m_cookiePersistentStorageType == storageType)
return;

m_cookiePersistentStoragePath = storagePath;
m_cookiePersistentStorageType = storageType;
networkProcess().cookieManager().setCookiePersistentStorage(m_sessionID, m_cookiePersistentStoragePath, m_cookiePersistentStorageType);
}

void WebsiteDataStore::setHTTPCookieAcceptPolicy(WebCore::HTTPCookieAcceptPolicy policy)
{
if (m_cookieAcceptPolicy == policy)
return;

m_cookieAcceptPolicy = policy;
networkProcess().cookieManager().setHTTPCookieAcceptPolicy(m_sessionID, policy, [] { });
}

} // namespace WebKit
@@ -28,7 +28,6 @@

#include "NetworkProcessProxy.h"
#include "WebCookieManagerMessages.h"
#include "WebProcessPool.h"

namespace WebKit {

@@ -38,11 +37,4 @@ void WebCookieManagerProxy::setCookiePersistentStorage(PAL::SessionID sessionID,
m_networkProcess->send(Messages::WebCookieManager::SetCookiePersistentStorage(sessionID, storagePath, storageType), 0);
}

void WebCookieManagerProxy::getCookiePersistentStorage(PAL::SessionID sessionID, String& storagePath, SoupCookiePersistentStorageType& storageType) const
{
auto pair = m_cookiePersistentStorageMap.get(sessionID);
storagePath = pair.first;
storageType = pair.second;
}

}
} // namespace WebKit

0 comments on commit 12d00c3

Please sign in to comment.