NetworkDataTaskCocoa.h [plain text]
#pragma once
#if USE(NETWORK_SESSION)
#include "NetworkDataTask.h"
#include "NetworkLoadParameters.h"
#include <WebCore/NetworkLoadMetrics.h>
#include <wtf/RetainPtr.h>
OBJC_CLASS NSHTTPCookieStorage;
OBJC_CLASS NSURLSessionDataTask;
namespace WebKit {
class NetworkSessionCocoa;
class NetworkDataTaskCocoa final : public NetworkDataTask {
friend class NetworkSessionCocoa;
public:
static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, uint64_t frameID, uint64_t pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation)
{
return adoptRef(*new NetworkDataTaskCocoa(session, client, request, frameID, pageID, storedCredentialsPolicy, shouldContentSniff, shouldContentEncodingSniff, shouldClearReferrerOnHTTPSToHTTPRedirect, shouldPreconnectOnly, dataTaskIsForMainFrameNavigation));
}
~NetworkDataTaskCocoa();
typedef uint64_t TaskIdentifier;
void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend);
void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&);
void didReceiveData(Ref<WebCore::SharedBuffer>&&);
void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&);
void transferSandboxExtensionToDownload(Download&);
void suspend() override;
void cancel() override;
void resume() override;
void invalidateAndCancel() override { }
NetworkDataTask::State state() const override;
void setPendingDownloadLocation(const String&, SandboxExtension::Handle&&, bool ) override;
String suggestedFilename() const override;
WebCore::NetworkLoadMetrics& networkLoadMetrics() { return m_networkLoadMetrics; }
uint64_t frameID() const { return m_frameID; };
uint64_t pageID() const { return m_pageID; };
private:
NetworkDataTaskCocoa(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, uint64_t frameID, uint64_t pageID, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly, bool dataTaskIsForMainFrameNavigation);
bool tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&);
void applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(NSURLRequest*&, bool shouldContentSniff, bool shouldContentEncodingSniff);
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
static NSHTTPCookieStorage *statelessCookieStorage();
void applyCookieBlockingPolicy(bool shouldBlock);
void applyCookiePartitioningPolicy(const String& requiredStoragePartition, const String& currentStoragePartition);
#endif
RefPtr<SandboxExtension> m_sandboxExtension;
RetainPtr<NSURLSessionDataTask> m_task;
WebCore::NetworkLoadMetrics m_networkLoadMetrics;
uint64_t m_frameID;
uint64_t m_pageID;
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
bool m_hasBeenSetToUseStatelessCookieStorage { false };
#endif
};
WebCore::Credential serverTrustCredential(const WebCore::AuthenticationChallenge&);
}
#endif // USE(NETWORK_SESSION)