ThreadableLoader.h [plain text]
#pragma once
#include "ResourceLoaderOptions.h"
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
#include <wtf/text/AtomicString.h>
namespace WebCore {
class ResourceError;
class ResourceRequest;
class ResourceResponse;
class ScriptExecutionContext;
class ThreadableLoaderClient;
enum PreflightPolicy {
ConsiderPreflight,
ForcePreflight,
PreventPreflight
};
enum class ContentSecurityPolicyEnforcement {
DoNotEnforce,
EnforceChildSrcDirective,
EnforceConnectSrcDirective,
EnforceScriptSrcDirective,
};
enum class ResponseFilteringPolicy {
Enable,
Disable,
};
struct ThreadableLoaderOptions : ResourceLoaderOptions {
ThreadableLoaderOptions();
ThreadableLoaderOptions(const ResourceLoaderOptions&, PreflightPolicy, ContentSecurityPolicyEnforcement, String&& initiator, ResponseFilteringPolicy);
~ThreadableLoaderOptions();
ThreadableLoaderOptions isolatedCopy() const;
PreflightPolicy preflightPolicy { ConsiderPreflight };
ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement { ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective };
String initiator; ResponseFilteringPolicy filteringPolicy { ResponseFilteringPolicy::Disable };
};
class ThreadableLoader {
WTF_MAKE_NONCOPYABLE(ThreadableLoader);
public:
static void loadResourceSynchronously(ScriptExecutionContext&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
static RefPtr<ThreadableLoader> create(ScriptExecutionContext&, ThreadableLoaderClient&, ResourceRequest&&, const ThreadableLoaderOptions&, String&& referrer = String());
virtual void cancel() = 0;
void ref() { refThreadableLoader(); }
void deref() { derefThreadableLoader(); }
static void logError(ScriptExecutionContext&, const ResourceError&, const String&);
protected:
ThreadableLoader() { }
virtual ~ThreadableLoader() { }
virtual void refThreadableLoader() = 0;
virtual void derefThreadableLoader() = 0;
};
}