#ifndef CachedScript_h
#define CachedScript_h
#include "CachedResource.h"
namespace WebCore {
class TextResourceDecoder;
class CachedScript final : public CachedResource {
public:
CachedScript(const ResourceRequest&, const String& charset, SessionID);
virtual ~CachedScript();
StringView script();
unsigned scriptHash();
String mimeType() const;
#if ENABLE(NOSNIFF)
bool mimeTypeAllowedByNosniff() const;
#endif
private:
bool mayTryReplaceEncodedData() const override { return true; }
bool shouldIgnoreHTTPStatusCodeErrors() const override;
void setEncoding(const String&) override;
String encoding() const override;
const TextResourceDecoder* textResourceDecoder() const override { return m_decoder.get(); }
void finishLoading(SharedBuffer*) override;
void destroyDecodedData() override;
String m_script;
unsigned m_scriptHash { 0 };
enum DecodingState { NeverDecoded, DataAndDecodedStringHaveSameBytes, DataAndDecodedStringHaveDifferentBytes };
DecodingState m_decodingState { NeverDecoded };
RefPtr<TextResourceDecoder> m_decoder;
};
}
SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedScript, CachedResource::Script)
#endif // CachedScript_h