ResourceErrorBase.h [plain text]
#pragma once
#include <wtf/URL.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class ResourceError;
WEBCORE_EXPORT extern const char* const errorDomainWebKitInternal; WEBCORE_EXPORT extern const char* const errorDomainWebKitServiceWorker;
class ResourceErrorBase {
public:
ResourceError isolatedCopy() const;
const String& domain() const { lazyInit(); return m_domain; }
int errorCode() const { lazyInit(); return m_errorCode; }
const URL& failingURL() const { lazyInit(); return m_failingURL; }
const String& localizedDescription() const { lazyInit(); return m_localizedDescription; }
enum class Type : uint8_t {
Null,
General,
AccessControl,
Cancellation,
Timeout
};
bool isNull() const { return m_type == Type::Null; }
bool isGeneral() const { return m_type == Type::General; }
bool isAccessControl() const { return m_type == Type::AccessControl; }
bool isCancellation() const { return m_type == Type::Cancellation; }
bool isTimeout() const { return m_type == Type::Timeout; }
static bool compare(const ResourceError&, const ResourceError&);
WEBCORE_EXPORT void setType(Type);
Type type() const { return m_type; }
protected:
ResourceErrorBase(Type type) : m_type(type) { }
ResourceErrorBase(const String& domain, int errorCode, const URL& failingURL, const String& localizedDescription, Type type)
: m_domain(domain)
, m_failingURL(failingURL)
, m_localizedDescription(localizedDescription)
, m_errorCode(errorCode)
, m_type(type)
{
}
WEBCORE_EXPORT void lazyInit() const;
void platformLazyInit() {}
static bool platformCompare(const ResourceError&, const ResourceError&) { return true; }
String m_domain;
URL m_failingURL;
String m_localizedDescription;
int m_errorCode { 0 };
Type m_type { Type::General };
private:
const ResourceError& asResourceError() const;
};
inline bool operator==(const ResourceError& a, const ResourceError& b) { return ResourceErrorBase::compare(a, b); }
inline bool operator!=(const ResourceError& a, const ResourceError& b) { return !(a == b); }
}