Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1773)

Unified Diff: Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp

Issue 318393002: Initial implementation of ServiceWorkerGlobalScope.fetch() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incoroporated dominicc's comment Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
index 4771751dd060588b57c8a95cb9f3b9291980abde..d7b12591409ec4c0513b257b9247311eff4f270b 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,30 @@ 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)
+{
+ KURL url = completeURL(urlstring);
tyoshino (SeeGerritForStatus) 2014/06/10 05:18:38 if (!url.isValid()) throw TypeError
horo 2014/06/10 06:44:59 Done.
+ OwnPtr<ResourceRequest> resourceRequest = adoptPtr(new ResourceRequest(url));
+ resourceRequest->setHTTPMethod("GET");
+ return m_fetchManager->fetch(scriptState, resourceRequest.release());
+}
+
PassRefPtr<ServiceWorkerClients> ServiceWorkerGlobalScope::clients()
{
if (!m_clients)
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerGlobalScope.h ('k') | Source/modules/serviceworkers/ServiceWorkerGlobalScope.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698