ResourceResponse.h [plain text]
#ifndef ResourceResponse_h
#define ResourceResponse_h
#include "ResourceResponseBase.h"
#include <wtf/RetainPtr.h>
#if USE(CFNETWORK)
typedef struct _CFURLResponse* CFURLResponseRef;
#endif
OBJC_CLASS NSURLResponse;
namespace WebCore {
class ResourceResponse : public ResourceResponseBase {
public:
ResourceResponse()
: m_initLevel(AllFields)
, m_platformResponseIsUpToDate(true)
{
}
#if USE(CFNETWORK)
ResourceResponse(CFURLResponseRef cfResponse)
: m_initLevel(Uninitialized)
, m_platformResponseIsUpToDate(true)
, m_cfResponse(cfResponse)
{
m_isNull = !cfResponse;
}
#if PLATFORM(COCOA)
WEBCORE_EXPORT ResourceResponse(NSURLResponse *);
#endif
#else
ResourceResponse(NSURLResponse *nsResponse)
: m_initLevel(Uninitialized)
, m_platformResponseIsUpToDate(true)
, m_nsResponse(nsResponse)
{
m_isNull = !nsResponse;
}
#endif
ResourceResponse(const URL& url, const String& mimeType, long long expectedLength, const String& textEncodingName)
: ResourceResponseBase(url, mimeType, expectedLength, textEncodingName)
, m_initLevel(AllFields)
, m_platformResponseIsUpToDate(false)
{
}
unsigned memoryUsage() const
{
return 3800;
}
#if USE(CFNETWORK)
WEBCORE_EXPORT CFURLResponseRef cfURLResponse() const;
#endif
#if PLATFORM(COCOA)
WEBCORE_EXPORT NSURLResponse *nsURLResponse() const;
#endif
bool platformResponseIsUpToDate() const { return m_platformResponseIsUpToDate; }
private:
friend class ResourceResponseBase;
void platformLazyInit(InitLevel);
String platformSuggestedFilename() const;
CertificateInfo platformCertificateInfo() const;
std::unique_ptr<CrossThreadResourceResponseData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceResponseData> data) const { return data; }
void doPlatformAdopt(std::unique_ptr<CrossThreadResourceResponseData>) { }
#if PLATFORM(COCOA)
void initNSURLResponse() const;
#endif
static bool platformCompare(const ResourceResponse& a, const ResourceResponse& b);
unsigned m_initLevel : 3;
bool m_platformResponseIsUpToDate : 1;
#if USE(CFNETWORK)
mutable RetainPtr<CFURLResponseRef> m_cfResponse;
#endif
#if PLATFORM(COCOA)
mutable RetainPtr<NSURLResponse> m_nsResponse;
#endif
};
struct CrossThreadResourceResponseData : public CrossThreadResourceResponseDataBase {
};
}
#endif // ResourceResponse_h