Commit 273dca96 authored by tyoshino@chromium.org's avatar tyoshino@chromium.org

Refactor ThreadableLoaderOptions for readability

ThreadableLoaderOptions shouldn't derive from ResourceLoaderOptions.
ResourceLoaderOptions members are basically just passed through to
FetchRequest while items added by ThreadableLoaderOptions definition
are configuring how CORS, etc. are handled in ThreadableLoader.
Inheritance looks making things less readable to me.

Also, I'd like to make DocumentThreadbleLoader more readable by making
constant variables held by const members.

Items in ThreadableLoaderOptions that determines ThreadableLoader's
behavior could be held by DocumentThreadableLoader as a const member.
Items defined in ResourceLoaderOptions can be altered inside
DocumentThreadableLoader, but can still be held as a const member by
having members to hold overridden items.

BUG=377541

Review URL: https://codereview.chromium.org/301243015

git-svn-id: svn://svn.chromium.org/blink/trunk@175283 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6a8ecee9
......@@ -105,19 +105,20 @@ void FileReaderLoader::startInternal(ExecutionContext& executionContext, const S
request.setHTTPHeaderField("Range", AtomicString(String::format("bytes=%d-%d", m_rangeStart, m_rangeEnd)));
ThreadableLoaderOptions options;
options.sniffContent = DoNotSniffContent;
options.preflightPolicy = ConsiderPreflight;
options.allowCredentials = AllowStoredCredentials;
options.crossOriginRequestPolicy = DenyCrossOriginRequests;
// FIXME: Is there a directive to which this load should be subject?
options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPolicy;
// Use special initiator to hide the request from the inspector.
options.initiator = FetchInitiatorTypeNames::internal;
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = AllowStoredCredentials;
if (m_client)
m_loader = ThreadableLoader::create(executionContext, this, request, options);
m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions);
else
ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options);
ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions);
}
void FileReaderLoader::start(ExecutionContext* executionContext, PassRefPtr<BlobDataHandle> blobData)
......
......@@ -752,11 +752,13 @@ void InspectorResourceAgent::loadResourceForFrontend(ErrorString* errorString, c
}
ThreadableLoaderOptions options;
options.allowCredentials = AllowStoredCredentials;
options.crossOriginRequestPolicy = AllowCrossOriginRequests;
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = AllowStoredCredentials;
InspectorThreadableLoaderClient* inspectorThreadableLoaderClient = new InspectorThreadableLoaderClient(callback);
RefPtr<DocumentThreadableLoader> loader = DocumentThreadableLoader::create(*document, inspectorThreadableLoaderClient, request, options);
RefPtr<DocumentThreadableLoader> loader = DocumentThreadableLoader::create(*document, inspectorThreadableLoaderClient, request, options, resourceLoaderOptions);
if (!loader) {
inspectorThreadableLoaderClient->didFailLoaderCreation();
return;
......
......@@ -54,8 +54,8 @@ class ThreadableLoaderClient;
class DocumentThreadableLoader FINAL : public ThreadableLoader, private ResourceOwner<RawResource> {
WTF_MAKE_FAST_ALLOCATED;
public:
static void loadResourceSynchronously(Document&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
static PassRefPtr<DocumentThreadableLoader> create(Document&, ThreadableLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&);
static void loadResourceSynchronously(Document&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
static PassRefPtr<DocumentThreadableLoader> create(Document&, ThreadableLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
virtual ~DocumentThreadableLoader();
virtual void cancel() OVERRIDE;
......@@ -67,7 +67,7 @@ class DocumentThreadableLoader FINAL : public ThreadableLoader, private Resource
LoadAsynchronously
};
DocumentThreadableLoader(Document&, ThreadableLoaderClient*, BlockingBehavior, const ResourceRequest&, const ThreadableLoaderOptions&);
DocumentThreadableLoader(Document&, ThreadableLoaderClient*, BlockingBehavior, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
// RawResourceClient implementation
virtual void dataSent(Resource*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
......@@ -104,7 +104,13 @@ class DocumentThreadableLoader FINAL : public ThreadableLoader, private Resource
ThreadableLoaderClient* m_client;
Document& m_document;
ThreadableLoaderOptions m_options;
const ThreadableLoaderOptions m_options;
const ResourceLoaderOptions m_resourceLoaderOptions;
StoredCredentials m_allowCredentials;
RefPtr<SecurityOrigin> m_securityOrigin;
bool m_sameOriginRequest;
bool m_simpleRequest;
bool m_async;
......
......@@ -43,7 +43,7 @@
namespace WebCore {
PassRefPtr<ThreadableLoader> ThreadableLoader::create(ExecutionContext& context, ThreadableLoaderClient* client, const ResourceRequest& request, const ThreadableLoaderOptions& options)
PassRefPtr<ThreadableLoader> ThreadableLoader::create(ExecutionContext& context, ThreadableLoaderClient* client, const ResourceRequest& request, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions)
{
ASSERT(client);
......@@ -51,20 +51,20 @@ PassRefPtr<ThreadableLoader> ThreadableLoader::create(ExecutionContext& context,
WorkerGlobalScope& workerGlobalScope = toWorkerGlobalScope(context);
RefPtr<ThreadableLoaderClientWrapper> clientWrapper(ThreadableLoaderClientWrapper::create(client));
OwnPtr<ThreadableLoaderClient> clientBridge(WorkerLoaderClientBridge::create(clientWrapper, workerGlobalScope.thread()->workerLoaderProxy()));
return WorkerThreadableLoader::create(workerGlobalScope, clientWrapper, clientBridge.release(), request, options);
return WorkerThreadableLoader::create(workerGlobalScope, clientWrapper, clientBridge.release(), request, options, resourceLoaderOptions);
}
return DocumentThreadableLoader::create(toDocument(context), client, request, options);
return DocumentThreadableLoader::create(toDocument(context), client, request, options, resourceLoaderOptions);
}
void ThreadableLoader::loadResourceSynchronously(ExecutionContext& context, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options)
void ThreadableLoader::loadResourceSynchronously(ExecutionContext& context, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions)
{
if (context.isWorkerGlobalScope()) {
WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(context), request, client, options);
WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(context), request, client, options, resourceLoaderOptions);
return;
}
DocumentThreadableLoader::loadResourceSynchronously(toDocument(context), request, client, options);
DocumentThreadableLoader::loadResourceSynchronously(toDocument(context), request, client, options, resourceLoaderOptions);
}
} // namespace WebCore
......@@ -62,7 +62,7 @@ namespace WebCore {
DoNotEnforceContentSecurityPolicy,
};
struct ThreadableLoaderOptions : public ResourceLoaderOptions {
struct ThreadableLoaderOptions {
ThreadableLoaderOptions()
: preflightPolicy(ConsiderPreflight)
, crossOriginRequestPolicy(DenyCrossOriginRequests)
......@@ -81,8 +81,14 @@ namespace WebCore {
class ThreadableLoader : public RefCounted<ThreadableLoader> {
WTF_MAKE_NONCOPYABLE(ThreadableLoader);
public:
static void loadResourceSynchronously(ExecutionContext&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&);
// ThreadableLoaderOptions argument configures this ThreadableLoader's
// behavior.
//
// ResourceLoaderOptions argument will be passed to the FetchRequest
// that this ThreadableLoader creates. It can be altered e.g. when
// redirect happens.
static void loadResourceSynchronously(ExecutionContext&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
virtual void cancel() = 0;
......
......@@ -51,10 +51,10 @@
namespace WebCore {
WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalScope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<ThreadableLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableLoaderOptions& options)
WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalScope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<ThreadableLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions)
: m_workerGlobalScope(&workerGlobalScope)
, m_workerClientWrapper(clientWrapper)
, m_bridge(*(new MainThreadBridge(m_workerClientWrapper, clientBridge, workerGlobalScope.thread()->workerLoaderProxy(), request, options, workerGlobalScope.url().strippedForUseAsReferrer())))
, m_bridge(*(new MainThreadBridge(m_workerClientWrapper, clientBridge, workerGlobalScope.thread()->workerLoaderProxy(), request, options, resourceLoaderOptions, workerGlobalScope.url().strippedForUseAsReferrer())))
{
}
......@@ -63,7 +63,7 @@ WorkerThreadableLoader::~WorkerThreadableLoader()
m_bridge.destroy();
}
void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope& workerGlobalScope, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options)
void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope& workerGlobalScope, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions)
{
blink::WebWaitableEvent* shutdownEvent =
workerGlobalScope.thread()->shutdownEvent();
......@@ -80,7 +80,7 @@ void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope& worker
// This must be valid while loader is around.
WorkerLoaderClientBridgeSyncHelper* clientBridgePtr = clientBridge.get();
RefPtr<WorkerThreadableLoader> loader = WorkerThreadableLoader::create(workerGlobalScope, clientWrapper, clientBridge.release(), request, options);
RefPtr<WorkerThreadableLoader> loader = WorkerThreadableLoader::create(workerGlobalScope, clientWrapper, clientBridge.release(), request, options, resourceLoaderOptions);
blink::WebWaitableEvent* signalled;
{
......@@ -104,7 +104,10 @@ WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(
PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper,
PassOwnPtr<ThreadableLoaderClient> clientBridge,
WorkerLoaderProxy& loaderProxy,
const ResourceRequest& request, const ThreadableLoaderOptions& options, const String& outgoingReferrer)
const ResourceRequest& request,
const ThreadableLoaderOptions& options,
const ResourceLoaderOptions& resourceLoaderOptions,
const String& outgoingReferrer)
: m_clientBridge(clientBridge)
, m_workerClientWrapper(workerClientWrapper)
, m_loaderProxy(loaderProxy)
......@@ -112,23 +115,22 @@ WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(
ASSERT(m_workerClientWrapper.get());
ASSERT(m_clientBridge.get());
m_loaderProxy.postTaskToLoader(
createCallbackTask(&MainThreadBridge::mainThreadCreateLoader,
AllowCrossThreadAccess(this), request, options, outgoingReferrer));
createCallbackTask(&MainThreadBridge::mainThreadCreateLoader, AllowCrossThreadAccess(this), request, options, resourceLoaderOptions, outgoingReferrer));
}
WorkerThreadableLoader::MainThreadBridge::~MainThreadBridge()
{
}
void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionContext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceRequestData> requestData, ThreadableLoaderOptions options, const String& outgoingReferrer)
void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionContext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceRequestData> requestData, ThreadableLoaderOptions options, ResourceLoaderOptions resourceLoaderOptions, const String& outgoingReferrer)
{
ASSERT(isMainThread());
Document* document = toDocument(context);
OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData));
request->setHTTPReferrer(Referrer(outgoingReferrer, ReferrerPolicyDefault));
options.requestInitiatorContext = WorkerContext;
thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(*document, thisPtr, *request, options);
resourceLoaderOptions.requestInitiatorContext = WorkerContext;
thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(*document, thisPtr, *request, options, resourceLoaderOptions);
if (!thisPtr->m_mainThreadLoader) {
// DocumentThreadableLoader::create may return 0 when the document loader has been already changed.
thisPtr->didFail(ResourceError(errorDomainBlinkInternal, 0, request->url().string(), "Can't create DocumentThreadableLoader"));
......
......@@ -53,10 +53,10 @@ namespace WebCore {
class WorkerThreadableLoader FINAL : public ThreadableLoader {
WTF_MAKE_FAST_ALLOCATED;
public:
static void loadResourceSynchronously(WorkerGlobalScope&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
static PassRefPtr<WorkerThreadableLoader> create(WorkerGlobalScope& workerGlobalScope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<ThreadableLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableLoaderOptions& options)
static void loadResourceSynchronously(WorkerGlobalScope&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
static PassRefPtr<WorkerThreadableLoader> create(WorkerGlobalScope& workerGlobalScope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<ThreadableLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions)
{
return adoptRef(new WorkerThreadableLoader(workerGlobalScope, clientWrapper, clientBridge, request, options));
return adoptRef(new WorkerThreadableLoader(workerGlobalScope, clientWrapper, clientBridge, request, options, resourceLoaderOptions));
}
virtual ~WorkerThreadableLoader();
......@@ -88,7 +88,7 @@ namespace WebCore {
class MainThreadBridge FINAL : public ThreadableLoaderClient {
public:
// All executed on the worker context's thread.
MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnPtr<ThreadableLoaderClient>, WorkerLoaderProxy&, const ResourceRequest&, const ThreadableLoaderOptions&, const String& outgoingReferrer);
MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnPtr<ThreadableLoaderClient>, WorkerLoaderProxy&, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&, const String& outgoingReferrer);
void cancel();
void destroy();
......@@ -100,7 +100,7 @@ namespace WebCore {
static void mainThreadDestroy(ExecutionContext*, MainThreadBridge*);
virtual ~MainThreadBridge();
static void mainThreadCreateLoader(ExecutionContext*, MainThreadBridge*, PassOwnPtr<CrossThreadResourceRequestData>, ThreadableLoaderOptions, const String& outgoingReferrer);
static void mainThreadCreateLoader(ExecutionContext*, MainThreadBridge*, PassOwnPtr<CrossThreadResourceRequestData>, ThreadableLoaderOptions, ResourceLoaderOptions, const String& outgoingReferrer);
static void mainThreadCancel(ExecutionContext*, MainThreadBridge*);
virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse&) OVERRIDE;
......@@ -124,7 +124,7 @@ namespace WebCore {
WorkerLoaderProxy& m_loaderProxy;
};
WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const ThreadableLoaderOptions&);
WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper;
......
......@@ -137,16 +137,17 @@ void EventSource::connect()
SecurityOrigin* origin = executionContext.securityOrigin();
ThreadableLoaderOptions options;
options.sniffContent = DoNotSniffContent;
options.allowCredentials = (origin->canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
options.credentialsRequested = m_withCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentials;
options.preflightPolicy = PreventPreflight;
options.crossOriginRequestPolicy = UseAccessControl;
options.dataBufferingPolicy = DoNotBufferData;
options.securityOrigin = origin;
options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypassMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConnectSrcDirective;
m_loader = ThreadableLoader::create(executionContext, this, request, options);
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = (origin->canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
resourceLoaderOptions.credentialsRequested = m_withCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentials;
resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData;
resourceLoaderOptions.securityOrigin = origin;
m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions);
if (m_loader)
m_requestInFlight = true;
......
......@@ -64,12 +64,14 @@ void WorkerScriptLoader::loadSynchronously(ExecutionContext& executionContext, c
ASSERT_WITH_SECURITY_IMPLICATION(executionContext.isWorkerGlobalScope());
ThreadableLoaderOptions options;
options.allowCredentials = AllowStoredCredentials;
options.crossOriginRequestPolicy = crossOriginRequestPolicy;
// FIXME: Should we add EnforceScriptSrcDirective here?
options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPolicy;
WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(executionContext), *request, *this, options);
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = AllowStoredCredentials;
WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(executionContext), *request, *this, options, resourceLoaderOptions);
}
void WorkerScriptLoader::loadAsynchronously(ExecutionContext& executionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy, WorkerScriptLoaderClient* client)
......@@ -83,12 +85,14 @@ void WorkerScriptLoader::loadAsynchronously(ExecutionContext& executionContext,
return;
ThreadableLoaderOptions options;
options.allowCredentials = AllowStoredCredentials;
options.crossOriginRequestPolicy = crossOriginRequestPolicy;
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = AllowStoredCredentials;
// During create, callbacks may happen which remove the last reference to this object.
RefPtr<WorkerScriptLoader> protect(this);
m_threadableLoader = ThreadableLoader::create(executionContext, this, *request, options);
m_threadableLoader = ThreadableLoader::create(executionContext, this, *request, options, resourceLoaderOptions);
}
const KURL& WorkerScriptLoader::responseURL() const
......
......@@ -836,18 +836,19 @@ void XMLHttpRequest::createRequest(ExceptionState& exceptionState)
request.addHTTPHeaderFields(m_requestHeaders);
ThreadableLoaderOptions options;
options.sniffContent = DoNotSniffContent;
options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight;
options.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
options.credentialsRequested = m_includeCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentials;
options.crossOriginRequestPolicy = UseAccessControl;
options.securityOrigin = securityOrigin();
options.initiator = FetchInitiatorTypeNames::xmlhttprequest;
options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypassMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConnectSrcDirective;
// TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303.
options.mixedContentBlockingTreatment = TreatAsPassiveContent;
options.timeoutMilliseconds = m_timeoutMilliseconds;
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
resourceLoaderOptions.credentialsRequested = m_includeCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentials;
resourceLoaderOptions.securityOrigin = securityOrigin();
// TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303.
resourceLoaderOptions.mixedContentBlockingTreatment = TreatAsPassiveContent;
m_exceptionCode = 0;
m_error = false;
......@@ -860,7 +861,7 @@ void XMLHttpRequest::createRequest(ExceptionState& exceptionState)
// FIXME: Maybe we need to be able to send XMLHttpRequests from onunload, <http://bugs.webkit.org/show_bug.cgi?id=10904>.
// FIXME: Maybe create() can return null for other reasons too?
ASSERT(!m_loader);
m_loader = ThreadableLoader::create(executionContext, this, request, options);
m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions);
if (m_loader) {
// Neither this object nor the JavaScript wrapper should be deleted while
// a request is in progress because we need to keep the listeners alive,
......@@ -868,7 +869,7 @@ void XMLHttpRequest::createRequest(ExceptionState& exceptionState)
setPendingActivity(this);
}
} else {
ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options);
ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions);
}
if (!m_exceptionCode && m_error)
......
......@@ -51,6 +51,7 @@ namespace WebCore {
struct CrossThreadResourceResponseData;
struct CrossThreadResourceRequestData;
struct ThreadableLoaderOptions;
struct ResourceLoaderOptions;
template<typename T> struct CrossThreadCopierPassThrough {
typedef T Type;
......@@ -71,6 +72,9 @@ namespace WebCore {
template<> struct CrossThreadCopierBase<false, false, ThreadableLoaderOptions> : public CrossThreadCopierPassThrough<ThreadableLoaderOptions> {
};
template<> struct CrossThreadCopierBase<false, false, ResourceLoaderOptions> : public CrossThreadCopierPassThrough<ResourceLoaderOptions> {
};
template<> struct CrossThreadCopierBase<false, false, IntRect> : public CrossThreadCopierPassThrough<IntRect> {
};
......
......@@ -341,16 +341,18 @@ void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebUR
if (allowLoad) {
ThreadableLoaderOptions options;
options.sniffContent = m_options.sniffContent ? SniffContent : DoNotSniffContent;
options.allowCredentials = m_options.allowCredentials ? AllowStoredCredentials : DoNotAllowStoredCredentials;
options.preflightPolicy = static_cast<WebCore::PreflightPolicy>(m_options.preflightPolicy);
options.crossOriginRequestPolicy = static_cast<WebCore::CrossOriginRequestPolicy>(m_options.crossOriginRequestPolicy);
options.dataBufferingPolicy = DoNotBufferData;
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.sniffContent = m_options.sniffContent ? SniffContent : DoNotSniffContent;
resourceLoaderOptions.allowCredentials = m_options.allowCredentials ? AllowStoredCredentials : DoNotAllowStoredCredentials;
resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData;
const ResourceRequest& webcoreRequest = newRequest.toResourceRequest();
Document* webcoreDocument = m_frameImpl->frame()->document();
ASSERT(webcoreDocument);
m_loader = DocumentThreadableLoader::create(*webcoreDocument, m_clientAdapter.get(), webcoreRequest, options);
m_loader = DocumentThreadableLoader::create(*webcoreDocument, m_clientAdapter.get(), webcoreRequest, options, resourceLoaderOptions);
} else {
// FIXME: return meaningful error codes.
m_clientAdapter->setDelayedError(ResourceError());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment