Chromium Code Reviews| Index: Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp |
| diff --git a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp |
| index 4771751dd060588b57c8a95cb9f3b9291980abde..ada701fdd4b24805a1d40974262ce149170f1ed8 100644 |
| --- a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp |
| +++ b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp |
| @@ -33,6 +33,8 @@ |
| #include "core/workers/WorkerClients.h" |
| #include "core/workers/WorkerThreadStartupData.h" |
| #include "modules/EventTargetModules.h" |
| +#include "modules/serviceworkers/FetchManager.h" |
| +#include "modules/serviceworkers/Request.h" |
| #include "modules/serviceworkers/ServiceWorkerClients.h" |
| #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| #include "modules/serviceworkers/ServiceWorkerThread.h" |
| @@ -52,6 +54,7 @@ PassRefPtrWillBeRawPtr<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::creat |
| ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const KURL& url, const String& userAgent, ServiceWorkerThread* thread, double timeOrigin, PassOwnPtrWillBeRawPtr<WorkerClients> workerClients) |
| : WorkerGlobalScope(url, userAgent, thread, timeOrigin, workerClients) |
| + , m_fetchManager(adoptPtr(new FetchManager(this))) |
| { |
| ScriptWrappable::init(this); |
| } |
| @@ -60,11 +63,34 @@ ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() |
| { |
| } |
| +void ServiceWorkerGlobalScope::stopFetch() |
| +{ |
| + m_fetchManager = 0; |
| +} |
| + |
| String ServiceWorkerGlobalScope::scope(ExecutionContext* context) |
| { |
| return ServiceWorkerGlobalScopeClient::from(context)->scope().string(); |
| } |
| +ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, Request* request) |
| +{ |
| + OwnPtr<ResourceRequest> resourceRequest(request->createResourceRequest()); |
| + return m_fetchManager->fetch(scriptState, resourceRequest.release()); |
| +} |
| + |
| +ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const String& urlstring, ExceptionState& exceptionState) |
| +{ |
| + KURL url = completeURL(urlstring); |
| + if (!url.isValid()) { |
|
yhirano
2014/06/11 06:51:30
I think returning ScriptPromise::reject(V8ThrowExc
horo
2014/06/11 09:06:23
Done.
|
| + exceptionState.throwTypeError("Invalid URL"); |
| + return ScriptPromise(); |
| + } |
| + OwnPtr<ResourceRequest> resourceRequest = adoptPtr(new ResourceRequest(url)); |
| + resourceRequest->setHTTPMethod("GET"); |
| + return m_fetchManager->fetch(scriptState, resourceRequest.release()); |
| +} |
| + |
| PassRefPtr<ServiceWorkerClients> ServiceWorkerGlobalScope::clients() |
| { |
| if (!m_clients) |