#pragma once
#include "ResourceErrorBase.h"
#include <wtf/RetainPtr.h>
#if USE(CFNETWORK)
#include <CoreFoundation/CFStream.h>
#endif
#if PLATFORM(WIN)
#include <windows.h>
#include <wincrypt.h> // windows.h must be included before wincrypt.h.
#endif
#if PLATFORM(COCOA)
OBJC_CLASS NSError;
#endif
namespace WebCore {
class ResourceError : public ResourceErrorBase {
public:
ResourceError(Type type = Type::Null)
: ResourceErrorBase(type)
, m_dataIsUpToDate(true)
{
}
ResourceError(const String& domain, int errorCode, const URL& failingURL, const String& localizedDescription, Type type = Type::General)
: ResourceErrorBase(domain, errorCode, failingURL, localizedDescription, type)
, m_dataIsUpToDate(true)
{
}
WEBCORE_EXPORT ResourceError(CFErrorRef error);
WEBCORE_EXPORT CFErrorRef cfError() const;
WEBCORE_EXPORT operator CFErrorRef() const;
#if USE(CFNETWORK)
#if PLATFORM(WIN)
ResourceError(const String& domain, int errorCode, const URL& failingURL, const String& localizedDescription, CFDataRef certificate);
PCCERT_CONTEXT certificate() const;
void setCertificate(CFDataRef);
#endif
ResourceError(CFStreamError error);
CFStreamError cfStreamError() const;
operator CFStreamError() const;
#endif
#if PLATFORM(COCOA)
WEBCORE_EXPORT ResourceError(NSError *);
WEBCORE_EXPORT NSError *nsError() const;
WEBCORE_EXPORT operator NSError *() const;
#endif
static bool platformCompare(const ResourceError& a, const ResourceError& b);
private:
friend class ResourceErrorBase;
void platformLazyInit();
void doPlatformIsolatedCopy(const ResourceError&);
bool m_dataIsUpToDate;
#if USE(CFNETWORK)
mutable RetainPtr<CFErrorRef> m_platformError;
#if PLATFORM(COCOA)
mutable RetainPtr<NSError> m_platformNSError;
#endif
#if PLATFORM(WIN)
RetainPtr<CFDataRef> m_certificate;
#endif
#else
mutable RetainPtr<NSError> m_platformError;
#endif
};
}