NetworkStorageSession.h [plain text]
#ifndef NetworkStorageSession_h
#define NetworkStorageSession_h
#include "CredentialStorage.h"
#include "SessionID.h"
#include <wtf/text/WTFString.h>
#if PLATFORM(COCOA) || USE(CFNETWORK)
#include "CFNetworkSPI.h"
#include <wtf/RetainPtr.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 std::unique_ptr<NetworkStorageSession> createPrivateBrowsingSession(SessionID, const String& identifierBase = String());
WEBCORE_EXPORT static void switchToNewTestingSession();
SessionID sessionID() const { return m_sessionID; }
CredentialStorage& credentialStorage() { return m_credentialStorage; }
#if PLATFORM(COCOA) || USE(CFNETWORK)
NetworkStorageSession(SessionID, RetainPtr<CFURLStorageSessionRef>);
CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
WEBCORE_EXPORT RetainPtr<CFHTTPCookieStorageRef> cookieStorage() const;
#elif USE(SOUP)
NetworkStorageSession(SessionID, std::unique_ptr<SoupNetworkSession>);
~NetworkStorageSession();
SoupNetworkSession& soupNetworkSession() const;
void setSoupNetworkSession(std::unique_ptr<SoupNetworkSession>);
#else
NetworkStorageSession(SessionID, NetworkingContext*);
~NetworkStorageSession();
NetworkingContext* context() const;
#endif
private:
SessionID m_sessionID;
#if PLATFORM(COCOA) || USE(CFNETWORK)
RetainPtr<CFURLStorageSessionRef> m_platformSession;
#elif USE(SOUP)
std::unique_ptr<SoupNetworkSession> m_session;
#else
RefPtr<NetworkingContext> m_context;
#endif
CredentialStorage m_credentialStorage;
};
WEBCORE_EXPORT String cookieStoragePartition(const ResourceRequest&);
String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource);
}
#endif // NetworkStorageSession_h