#ifndef DownloadProxy_h
#define DownloadProxy_h
#include "APIObject.h"
#include "Connection.h"
#include "SandboxExtension.h"
#include <WebCore/ResourceRequest.h>
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
namespace API {
class Data;
}
namespace WebCore {
class AuthenticationChallenge;
class ResourceError;
class ResourceResponse;
}
namespace WebKit {
class DownloadProxyMap;
class WebContext;
class WebPageProxy;
class DownloadProxy : public API::ObjectImpl<API::Object::Type::Download>, public IPC::MessageReceiver {
public:
static PassRefPtr<DownloadProxy> create(DownloadProxyMap&, WebContext&);
~DownloadProxy();
uint64_t downloadID() const { return m_downloadID; }
const WebCore::ResourceRequest& request() const { return m_request; }
API::Data* resumeData() const { return m_resumeData.get(); }
void cancel();
void invalidate();
void processDidClose();
void didReceiveDownloadProxyMessage(IPC::Connection*, IPC::MessageDecoder&);
void didReceiveSyncDownloadProxyMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
private:
explicit DownloadProxy(DownloadProxyMap&, WebContext&);
virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
virtual void didReceiveSyncMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
void didStart(const WebCore::ResourceRequest&);
void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&, uint64_t challengeID);
void didReceiveResponse(const WebCore::ResourceResponse&);
void didReceiveData(uint64_t length);
void shouldDecodeSourceDataOfMIMEType(const String& mimeType, bool& result);
void decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle);
void didCreateDestination(const String& path);
void didFinish();
void didFail(const WebCore::ResourceError&, const IPC::DataReference& resumeData);
void didCancel(const IPC::DataReference& resumeData);
DownloadProxyMap& m_downloadProxyMap;
RefPtr<WebContext> m_webContext;
uint64_t m_downloadID;
RefPtr<API::Data> m_resumeData;
WebCore::ResourceRequest m_request;
};
}
#endif // DownloadProxy_h