NetworkStorageSession.h [plain text]
#pragma once
#include "CredentialStorage.h"
#include "SessionID.h"
#include <wtf/text/WTFString.h>
#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
#include "CFNetworkSPI.h"
#include <wtf/RetainPtr.h>
#endif
#if USE(SOUP)
#include <wtf/Function.h>
#include <wtf/glib/GRefPtr.h>
#endif
namespace WebCore {
class NetworkingContext;
class ResourceRequest;
class SoupNetworkSession;
class NetworkStorageSession {
WTF_MAKE_NONCOPYABLE(NetworkStorageSession); WTF_MAKE_FAST_ALLOCATED;
public:
WEBCORE_EXPORT static NetworkStorageSession& defaultStorageSession();
WEBCORE_EXPORT static NetworkStorageSession* storageSession(SessionID);
WEBCORE_EXPORT static void ensurePrivateBrowsingSession(SessionID, const String& identifierBase = String());
WEBCORE_EXPORT static void destroySession(SessionID);
WEBCORE_EXPORT static void forEach(std::function<void(const WebCore::NetworkStorageSession&)>);
WEBCORE_EXPORT static void switchToNewTestingSession();
SessionID sessionID() const { return m_sessionID; }
CredentialStorage& credentialStorage() { return m_credentialStorage; }
#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
NetworkStorageSession(SessionID, RetainPtr<CFURLStorageSessionRef>);
CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
WEBCORE_EXPORT RetainPtr<CFHTTPCookieStorageRef> cookieStorage() const;
WEBCORE_EXPORT static void setCookieStoragePartitioningEnabled(bool);
#elif USE(SOUP)
NetworkStorageSession(SessionID, std::unique_ptr<SoupNetworkSession>);
~NetworkStorageSession();
SoupNetworkSession& soupNetworkSession() const;
void getCredentialFromPersistentStorage(const ProtectionSpace&, Function<void (Credential&&)> completionHandler);
void saveCredentialToPersistentStorage(const ProtectionSpace&, const Credential&);
#else
NetworkStorageSession(SessionID, NetworkingContext*);
~NetworkStorageSession();
NetworkingContext* context() const;
#endif
private:
static HashMap<SessionID, std::unique_ptr<NetworkStorageSession>>& globalSessionMap();
SessionID m_sessionID;
#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
RetainPtr<CFURLStorageSessionRef> m_platformSession;
#elif USE(SOUP)
std::unique_ptr<SoupNetworkSession> m_session;
#if USE(LIBSECRET)
Function<void (Credential&&)> m_persisentStorageCompletionHandler;
GRefPtr<GCancellable> m_persisentStorageCancellable;
#endif
#else
RefPtr<NetworkingContext> m_context;
#endif
CredentialStorage m_credentialStorage;
};
WEBCORE_EXPORT String cookieStoragePartition(const ResourceRequest&);
String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource);
}