Index: Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp |
diff --git a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp |
index bdd2f7a5b56d476c7315fdeef8b3cbdfaafab0cc..62fd8d693ffca2b7f78e146d8952dd673c365545 100644 |
--- a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp |
+++ b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp |
@@ -33,7 +33,9 @@ |
#include "bindings/core/v8/ScriptPromise.h" |
#include "bindings/core/v8/ScriptState.h" |
#include "bindings/core/v8/V8ThrowException.h" |
+#include "core/fetch/ResourceLoaderOptions.h" |
#include "core/inspector/ScriptCallStack.h" |
+#include "core/loader/ThreadableLoader.h" |
#include "core/workers/WorkerClients.h" |
#include "core/workers/WorkerThreadStartupData.h" |
#include "modules/CachePolyfill.h" |
@@ -48,7 +50,6 @@ |
#include "platform/network/ResourceRequest.h" |
#include "platform/weborigin/KURL.h" |
#include "public/platform/WebURL.h" |
-#include "public/platform/WebURLRequest.h" |
#include "wtf/CurrentTime.h" |
namespace WebCore { |
@@ -89,20 +90,58 @@ String ServiceWorkerGlobalScope::scope(ExecutionContext* context) |
ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, Request* request) |
{ |
- OwnPtr<ResourceRequest> resourceRequest(request->createResourceRequest()); |
- resourceRequest->setRequestContext(blink::WebURLRequest::RequestContextFetch); |
- return m_fetchManager->fetch(scriptState, resourceRequest.release()); |
+ if (!m_fetchManager) |
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("ServiceWorkerGlobalScope is shutting down.", scriptState->isolate())); |
+ // "Let |r| be the associated request of the result of invoking the initial |
+ // value of Request as constructor with |input| and |init| as arguments. If |
+ // this throws an exception, reject |p| with it." |
+ TrackExceptionState exceptionState; |
+ RefPtr<Request> r = Request::create(this, request, exceptionState); |
+ if (exceptionState.hadException()) |
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(exceptionState.message(), scriptState->isolate())); |
yhirano
2014/07/16 13:12:27
Please write FIXME. We should throw the caught err
horo
2014/07/18 09:12:18
Done.
|
+ return m_fetchManager->fetch(scriptState, r->request()); |
+} |
+ |
+ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, Request* request, const Dictionary& requestInit) |
+{ |
+ if (!m_fetchManager) |
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("ServiceWorkerGlobalScope is shutting down.", scriptState->isolate())); |
+ // "Let |r| be the associated request of the result of invoking the initial |
+ // value of Request as constructor with |input| and |init| as arguments. If |
+ // this throws an exception, reject |p| with it." |
+ TrackExceptionState exceptionState; |
+ RefPtr<Request> r = Request::create(this, request, requestInit, exceptionState); |
+ if (exceptionState.hadException()) |
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(exceptionState.message(), scriptState->isolate())); |
yhirano
2014/07/16 13:12:27
ditto
horo
2014/07/18 09:12:18
Done.
|
+ return m_fetchManager->fetch(scriptState, r->request()); |
} |
ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const String& urlstring) |
{ |
- KURL url = completeURL(urlstring); |
- if (!url.isValid()) |
- return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("Invalid URL", scriptState->isolate())); |
- OwnPtr<ResourceRequest> resourceRequest = adoptPtr(new ResourceRequest(url)); |
- resourceRequest->setRequestContext(blink::WebURLRequest::RequestContextFetch); |
- resourceRequest->setHTTPMethod("GET"); |
- return m_fetchManager->fetch(scriptState, resourceRequest.release()); |
+ if (!m_fetchManager) |
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("ServiceWorkerGlobalScope is shutting down.", scriptState->isolate())); |
+ // "Let |r| be the associated request of the result of invoking the initial |
+ // value of Request as constructor with |input| and |init| as arguments. If |
+ // this throws an exception, reject |p| with it." |
+ TrackExceptionState exceptionState; |
+ RefPtr<Request> r = Request::create(this, urlstring, exceptionState); |
+ if (exceptionState.hadException()) |
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(exceptionState.message(), scriptState->isolate())); |
yhirano
2014/07/16 13:12:27
ditto
horo
2014/07/18 09:12:18
Done.
|
+ return m_fetchManager->fetch(scriptState, r->request()); |
+} |
+ |
+ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const String& urlstring, const Dictionary& requestInit) |
+{ |
+ if (!m_fetchManager) |
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("ServiceWorkerGlobalScope is shutting down.", scriptState->isolate())); |
+ // "Let |r| be the associated request of the result of invoking the initial |
+ // value of Request as constructor with |input| and |init| as arguments. If |
+ // this throws an exception, reject |p| with it." |
+ TrackExceptionState exceptionState; |
+ RefPtr<Request> r = Request::create(this, urlstring, requestInit, exceptionState); |
+ if (exceptionState.hadException()) |
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(exceptionState.message(), scriptState->isolate())); |
yhirano
2014/07/16 13:12:27
ditto
horo
2014/07/18 09:12:18
Done.
|
+ return m_fetchManager->fetch(scriptState, r->request()); |
} |
PassRefPtrWillBeRawPtr<ServiceWorkerClients> ServiceWorkerGlobalScope::clients() |