Skip to content
Permalink
Browse files
Unreviewed, reverting r267608.
Caused API test failures

Reverted changeset:

"Move NetworkProcessProxy ownership from WebProcessPool to
WebsiteDataStore"
https://bugs.webkit.org/show_bug.cgi?id=216041
https://trac.webkit.org/changeset/267608


Canonical link: https://commits.webkit.org/229790@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267618 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
achristensen07 committed Sep 26, 2020
1 parent 06f38cc commit 3c91176f811350dec1e1136523a87b10278eaecf
Show file tree
Hide file tree
Showing 87 changed files with 1,918 additions and 1,049 deletions.
@@ -1,3 +1,16 @@
2020-09-25 Alex Christensen <achristensen@webkit.org>

Unreviewed, reverting r267608.

Caused API test failures

Reverted changeset:

"Move NetworkProcessProxy ownership from WebProcessPool to
WebsiteDataStore"
https://bugs.webkit.org/show_bug.cgi?id=216041
https://trac.webkit.org/changeset/267608

2020-09-25 Tim Horton <timothy_horton@apple.com>

Crunchyroll playback controls do not work on iPad with trackpad
@@ -32,7 +32,6 @@
#include "WebCoreArgumentCoders.h"
#include <WebCore/Cookie.h>
#include <WebCore/CookieStorage.h>
#include <WebCore/HTTPCookieAcceptPolicy.h>
#include <WebCore/NetworkStorageSession.h>
#include <wtf/MainThread.h>
#include <wtf/URL.h>
@@ -144,18 +143,15 @@ void WebCookieManager::stopObservingCookieChanges(PAL::SessionID sessionID)

void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
{
platformSetHTTPCookieAcceptPolicy(policy, [policy, process = makeRef(m_process), completionHandler = WTFMove(completionHandler)] () mutable {
process->cookieAcceptPolicyChanged(policy);
completionHandler();
});
platformSetHTTPCookieAcceptPolicy(policy);
m_process.cookieAcceptPolicyChanged(policy);

completionHandler();
}

void WebCookieManager::getHTTPCookieAcceptPolicy(PAL::SessionID sessionID, CompletionHandler<void(HTTPCookieAcceptPolicy)>&& completionHandler)
void WebCookieManager::getHTTPCookieAcceptPolicy(CompletionHandler<void(HTTPCookieAcceptPolicy)>&& completionHandler)
{
if (auto* storageSession = m_process.storageSession(sessionID))
completionHandler(storageSession->cookieAcceptPolicy());
else
completionHandler(HTTPCookieAcceptPolicy::Never);
completionHandler(m_process.defaultStorageSession().cookieAcceptPolicy());
}

} // namespace WebKit
@@ -37,8 +37,6 @@
#include "SoupCookiePersistentStorageType.h"
#endif

OBJC_CLASS NSHTTPCookieStorage;

namespace WebCore {
struct Cookie;
enum class HTTPCookieAcceptPolicy : uint8_t;
@@ -81,17 +79,13 @@ class WebCookieManager : public NetworkProcessSupplement, public IPC::MessageRec
void getAllCookies(PAL::SessionID, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&&);
void getCookies(PAL::SessionID, const URL&, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&&);

void platformSetHTTPCookieAcceptPolicy(WebCore::HTTPCookieAcceptPolicy, CompletionHandler<void()>&&);
void getHTTPCookieAcceptPolicy(PAL::SessionID, CompletionHandler<void(WebCore::HTTPCookieAcceptPolicy)>&&);
void platformSetHTTPCookieAcceptPolicy(WebCore::HTTPCookieAcceptPolicy);
void getHTTPCookieAcceptPolicy(CompletionHandler<void(WebCore::HTTPCookieAcceptPolicy)>&&);

void startObservingCookieChanges(PAL::SessionID);
void stopObservingCookieChanges(PAL::SessionID);

NetworkProcess& m_process;
};

#if PLATFORM(COCOA)
void saveCookies(NSHTTPCookieStorage *, CompletionHandler<void()>&&);
#endif

} // namespace WebKit
@@ -36,7 +36,7 @@ messages -> WebCookieManager NotRefCounted {
void DeleteAllCookiesModifiedSince(PAL::SessionID sessionID, WallTime time) -> () Async

void SetHTTPCookieAcceptPolicy(enum:uint8_t WebCore::HTTPCookieAcceptPolicy policy) -> () Async
void GetHTTPCookieAcceptPolicy(PAL::SessionID sessionID) -> (enum:uint8_t WebCore::HTTPCookieAcceptPolicy policy) Async
void GetHTTPCookieAcceptPolicy() -> (enum:uint8_t WebCore::HTTPCookieAcceptPolicy policy) Async

void StartObservingCookieChanges(PAL::SessionID sessionID)
void StopObservingCookieChanges(PAL::SessionID sessionID)
@@ -34,7 +34,7 @@ namespace WebKit {

using namespace WebCore;

void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
{
CookieAcceptPolicy curlPolicy = CookieAcceptPolicy::OnlyFromMainDocumentDomain;
switch (policy) {
@@ -55,7 +55,6 @@ void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy
m_process.forEachNetworkStorageSession([curlPolicy] (const auto& networkStorageSession) {
networkStorageSession.setCookieAcceptPolicy(curlPolicy);
});
completionHandler();
}

} // namespace WebKit
@@ -31,7 +31,6 @@
#import <WebCore/HTTPCookieAcceptPolicy.h>
#import <WebCore/NetworkStorageSession.h>
#import <pal/spi/cf/CFNetworkSPI.h>
#import <wtf/CallbackAggregator.h>
#import <wtf/ProcessPrivilege.h>

namespace WebKit {
@@ -54,19 +53,15 @@ static CFHTTPCookieStorageAcceptPolicy toCFHTTPCookieStorageAcceptPolicy(HTTPCoo
return CFHTTPCookieStorageAcceptPolicyAlways;
}

void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
{
ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));

auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:static_cast<NSHTTPCookieAcceptPolicy>(policy)];
saveCookies([NSHTTPCookieStorage sharedHTTPCookieStorage], [callbackAggregator] { });

m_process.forEachNetworkStorageSession([&] (const auto& networkStorageSession) {
if (auto cookieStorage = networkStorageSession.cookieStorage())
CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), toCFHTTPCookieStorageAcceptPolicy(policy));
if (auto *storage = networkStorageSession.nsCookieStorage())
saveCookies(storage, [callbackAggregator] { });
});
}

@@ -37,12 +37,11 @@
namespace WebKit {
using namespace WebCore;

void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
{
m_process.forEachNetworkStorageSession([policy] (auto& session) {
session.setCookieAcceptPolicy(policy);
});
completionHandler();
}

void WebCookieManager::setCookiePersistentStorage(PAL::SessionID sessionID, const String& storagePath, SoupCookiePersistentStorageType storageType)
@@ -173,7 +173,6 @@ NetworkProcess::NetworkProcess(AuxiliaryProcessInitializationParameters&& parame
#endif

#if USE(SOUP)
// FIXME: Do not use the default session ID.
DNSResolveQueueSoup::setGlobalDefaultSoupSessionAccessor([this]() -> SoupSession* {
return static_cast<NetworkSessionSoup&>(*networkSession(PAL::SessionID::defaultSessionID())).soupSession();
});
@@ -348,6 +347,30 @@ void NetworkProcess::initializeNetworkProcess(NetworkProcessCreationParameters&&

setAdClickAttributionDebugMode(parameters.enableAdClickAttributionDebugMode);

SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsParameters.directoryExtensionHandle);

auto sessionID = parameters.defaultDataStoreParameters.networkSessionParameters.sessionID;
setSession(sessionID, NetworkSession::create(*this, WTFMove(parameters.defaultDataStoreParameters.networkSessionParameters)));

SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.cacheStorageDirectoryExtensionHandle);
addSessionStorageQuotaManager(sessionID, parameters.defaultDataStoreParameters.perOriginStorageQuota, parameters.defaultDataStoreParameters.perThirdPartyOriginStorageQuota, parameters.defaultDataStoreParameters.cacheStorageDirectory, parameters.defaultDataStoreParameters.cacheStorageDirectoryExtensionHandle);

#if ENABLE(INDEXED_DATABASE)
addIndexedDatabaseSession(sessionID, parameters.defaultDataStoreParameters.indexedDatabaseDirectory, parameters.defaultDataStoreParameters.indexedDatabaseDirectoryExtensionHandle);
#endif

#if ENABLE(SERVICE_WORKER)
bool serviceWorkerProcessTerminationDelayEnabled = true;
addServiceWorkerSession(PAL::SessionID::defaultSessionID(), serviceWorkerProcessTerminationDelayEnabled, WTFMove(parameters.serviceWorkerRegistrationDirectory), parameters.serviceWorkerRegistrationDirectoryExtensionHandle);
#endif

m_storageManagerSet->add(sessionID, parameters.defaultDataStoreParameters.localStorageDirectory, parameters.defaultDataStoreParameters.localStorageDirectoryExtensionHandle);

auto* defaultSession = networkSession(PAL::SessionID::defaultSessionID());
auto* defaultStorageSession = defaultSession->networkStorageSession();
for (const auto& cookie : parameters.defaultDataStoreParameters.pendingCookies)
defaultStorageSession->setCookie(cookie);

for (auto& supplement : m_supplements.values())
supplement->initialize(parameters);

@@ -482,6 +505,8 @@ void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, bool shouldU
void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, bool shouldUseTestingNetworkSession, const String& identifierBase)
#endif
{
ASSERT(sessionID != PAL::SessionID::defaultSessionID());

auto addResult = m_networkStorageSessions.add(sessionID, nullptr);
if (!addResult.isNewEntry)
return;
@@ -496,7 +521,7 @@ void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, bool shouldU
RetainPtr<CFStringRef> cfIdentifier = makeString(identifierBase, ".PrivateBrowsing.", createCanonicalUUIDString()).createCFString();
if (sessionID.isEphemeral())
storageSession = adoptCF(createPrivateStorageSession(cfIdentifier.get()));
else if (sessionID != PAL::SessionID::defaultSessionID())
else
storageSession = WebCore::NetworkStorageSession::createCFStorageSessionForIdentifier(cfIdentifier.get());

if (NetworkStorageSession::processMayUseCookieAPI()) {
@@ -519,11 +544,21 @@ void NetworkProcess::cookieAcceptPolicyChanged(HTTPCookieAcceptPolicy newPolicy)

WebCore::NetworkStorageSession* NetworkProcess::storageSession(const PAL::SessionID& sessionID) const
{
if (sessionID == PAL::SessionID::defaultSessionID())
return &defaultStorageSession();
return m_networkStorageSessions.get(sessionID);
}

WebCore::NetworkStorageSession& NetworkProcess::defaultStorageSession() const
{
if (!m_defaultNetworkStorageSession)
m_defaultNetworkStorageSession = platformCreateDefaultStorageSession();
return *m_defaultNetworkStorageSession;
}

void NetworkProcess::forEachNetworkStorageSession(const Function<void(WebCore::NetworkStorageSession&)>& functor)
{
functor(defaultStorageSession());
for (auto& storageSession : m_networkStorageSessions.values())
functor(*storageSession);
}
@@ -170,6 +170,7 @@ class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client,

void forEachNetworkStorageSession(const Function<void(WebCore::NetworkStorageSession&)>&);
WebCore::NetworkStorageSession* storageSession(const PAL::SessionID&) const;
WebCore::NetworkStorageSession& defaultStorageSession() const;
std::unique_ptr<WebCore::NetworkStorageSession> newTestingSession(const PAL::SessionID&);
#if PLATFORM(COCOA)
void ensureSession(const PAL::SessionID&, bool shouldUseTestingNetworkSession, const String& identifier, RetainPtr<CFHTTPCookieStorageRef>&&);
@@ -374,6 +375,7 @@ class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client,

private:
void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&);
std::unique_ptr<WebCore::NetworkStorageSession> platformCreateDefaultStorageSession() const;

void didReceiveNetworkProcessMessage(IPC::Connection&, IPC::Decoder&);

@@ -542,6 +544,7 @@ class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client,

HashMap<PAL::SessionID, std::unique_ptr<NetworkSession>> m_networkSessions;
HashMap<PAL::SessionID, std::unique_ptr<WebCore::NetworkStorageSession>> m_networkStorageSessions;
mutable std::unique_ptr<WebCore::NetworkStorageSession> m_defaultNetworkStorageSession;

RefPtr<StorageManagerSet> m_storageManagerSet;

@@ -55,6 +55,7 @@ void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const
encoder << uiProcessSDKVersion;
IPC::encode(encoder, networkATSContext.get());
#endif
encoder << defaultDataStoreParameters;
#if USE(SOUP)
encoder << cookieAcceptPolicy;
encoder << languages;
@@ -65,6 +66,9 @@ void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const
encoder << urlSchemesRegisteredAsLocal;
encoder << urlSchemesRegisteredAsNoAccess;

#if ENABLE(SERVICE_WORKER)
encoder << serviceWorkerRegistrationDirectory << serviceWorkerRegistrationDirectoryExtensionHandle << shouldDisableServiceWorkerProcessTerminationDelay;
#endif
encoder << shouldEnableITPDatabase;
encoder << enableAdClickAttributionDebugMode;
}
@@ -110,6 +114,12 @@ bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProc
return false;
#endif

Optional<WebsiteDataStoreParameters> defaultDataStoreParameters;
decoder >> defaultDataStoreParameters;
if (!defaultDataStoreParameters)
return false;
result.defaultDataStoreParameters = WTFMove(*defaultDataStoreParameters);

#if USE(SOUP)
if (!decoder.decode(result.cookieAcceptPolicy))
return false;
@@ -126,6 +136,20 @@ bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProc
if (!decoder.decode(result.urlSchemesRegisteredAsNoAccess))
return false;

#if ENABLE(SERVICE_WORKER)
if (!decoder.decode(result.serviceWorkerRegistrationDirectory))
return false;

Optional<SandboxExtension::Handle> serviceWorkerRegistrationDirectoryExtensionHandle;
decoder >> serviceWorkerRegistrationDirectoryExtensionHandle;
if (!serviceWorkerRegistrationDirectoryExtensionHandle)
return false;
result.serviceWorkerRegistrationDirectoryExtensionHandle = WTFMove(*serviceWorkerRegistrationDirectoryExtensionHandle);

if (!decoder.decode(result.shouldDisableServiceWorkerProcessTerminationDelay))
return false;
#endif

if (!decoder.decode(result.shouldEnableITPDatabase))
return false;

@@ -27,6 +27,7 @@

#include "CacheModel.h"
#include "SandboxExtension.h"
#include "WebsiteDataStoreParameters.h"
#include <WebCore/Cookie.h>
#include <wtf/ProcessID.h>
#include <wtf/Vector.h>
@@ -69,6 +70,8 @@ struct NetworkProcessCreationParameters {
RetainPtr<CFDataRef> networkATSContext;
#endif

WebsiteDataStoreParameters defaultDataStoreParameters;

#if USE(SOUP)
WebCore::HTTPCookieAcceptPolicy cookieAcceptPolicy { WebCore::HTTPCookieAcceptPolicy::AlwaysAccept };
Vector<String> languages;
@@ -79,6 +82,11 @@ struct NetworkProcessCreationParameters {
Vector<String> urlSchemesRegisteredAsLocal;
Vector<String> urlSchemesRegisteredAsNoAccess;

#if ENABLE(SERVICE_WORKER)
String serviceWorkerRegistrationDirectory;
SandboxExtension::Handle serviceWorkerRegistrationDirectoryExtensionHandle;
bool shouldDisableServiceWorkerProcessTerminationDelay { false };
#endif
bool shouldEnableITPDatabase { false };
bool enableAdClickAttributionDebugMode { false };
};
@@ -214,8 +214,7 @@ void LocalStorageDatabase::clear()

void LocalStorageDatabase::close()
{
if (m_isClosed)
return;
ASSERT(!m_isClosed);
m_isClosed = true;

if (m_didScheduleDatabaseUpdate) {
@@ -33,7 +33,6 @@
#import "NetworkResourceLoader.h"
#import "NetworkSessionCocoa.h"
#import "SandboxExtension.h"
#import "WebCookieManager.h"
#import <WebCore/NetworkStorageSession.h>
#import <WebCore/PublicSuffix.h>
#import <WebCore/ResourceRequestCFNet.h>
@@ -79,6 +78,9 @@ static void initializeNetworkSettings()
SandboxExtension::consumePermanently(parameters.cookieStorageDirectoryExtensionHandle);
SandboxExtension::consumePermanently(parameters.containerCachesDirectoryExtensionHandle);
SandboxExtension::consumePermanently(parameters.parentBundleDirectoryExtensionHandle);
#if ENABLE(INDEXED_DATABASE)
SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.indexedDatabaseTempBlobDirectoryExtensionHandle);
#endif
#endif

_CFNetworkSetATSContext(parameters.networkATSContext.get());
@@ -103,6 +105,11 @@ static void initializeNetworkSettings()
[NSURLCache setSharedURLCache:urlCache.get()];
}

std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const
{
return makeUnique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID());
}

RetainPtr<CFDataRef> NetworkProcess::sourceApplicationAuditData() const
{
#if USE(SOURCE_APPLICATION_AUDIT_DATA)
@@ -214,7 +221,7 @@ static void filterPreloadHSTSEntry(const void* key, const void* value, void* con
platformFlushCookies(sessionID, WTFMove(completionHandler));
}

void saveCookies(NSHTTPCookieStorage *cookieStorage, CompletionHandler<void()>&& completionHandler)
static void saveCookies(NSHTTPCookieStorage *cookieStorage, CompletionHandler<void()>&& completionHandler)
{
ASSERT(RunLoop::isMain());
ASSERT(cookieStorage);
@@ -39,6 +39,11 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
{
}

std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const
{
return makeUnique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID());
}

void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host)
{
notImplemented();

0 comments on commit 3c91176

Please sign in to comment.