#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 WebCore {
class AuthenticationChallenge;
class ResourceError;
class ResourceResponse;
}
namespace WebKit {
class WebContext;
class WebData;
class DownloadProxy : public APIObject {
public:
static const Type APIType = TypeDownload;
static PassRefPtr<DownloadProxy> create(WebContext*);
~DownloadProxy();
uint64_t downloadID() const { return m_downloadID; }
const WebCore::ResourceRequest& request() const { return m_request; }
WebData* resumeData() const { return m_resumeData.get(); }
void cancel();
void invalidate();
void processDidClose();
void didReceiveDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
CoreIPC::SyncReplyMode didReceiveSyncDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
private:
explicit DownloadProxy(WebContext*);
virtual Type type() const { return APIType; }
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 CoreIPC::DataReference& resumeData);
void didCancel(const CoreIPC::DataReference& resumeData);
WebContext* m_webContext;
uint64_t m_downloadID;
RefPtr<WebData> m_resumeData;
WebCore::ResourceRequest m_request;
};
}
#endif // DownloadProxy_h