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

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

Issue 313553002: Add the navigator.serviceWorker.waiting property. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bring patch to head. 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/ServiceWorkerContainer.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index db1d58c50849453cb2407ac75f58c31cae1d33fa..762c527fbab3cb98a7f6a78af31936a30fc2057f 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -160,13 +160,31 @@ void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se
setController(serviceWorker);
}
+// If the WebServiceWorker is up for adoption (does not have a
+// WebServiceWorkerProxy owner), rejects the adoption by deleting the
+// WebServiceWorker.
+static void deleteIfNoExistingOwner(blink::WebServiceWorker* serviceWorker)
+{
+ if (serviceWorker && !serviceWorker->proxy())
+ delete serviceWorker;
+}
+
+void ServiceWorkerContainer::setWaiting(blink::WebServiceWorker* serviceWorker)
+{
+ if (!executionContext()) {
+ deleteIfNoExistingOwner(serviceWorker);
+ return;
+ }
+ m_waiting = ServiceWorker::from(executionContext(), serviceWorker);
+}
+
void ServiceWorkerContainer::setController(blink::WebServiceWorker* serviceWorker)
{
if (!executionContext()) {
- delete serviceWorker;
+ deleteIfNoExistingOwner(serviceWorker);
return;
}
- m_controller = ServiceWorker::create(executionContext(), adoptPtr(serviceWorker));
+ m_controller = ServiceWorker::from(executionContext(), serviceWorker);
}
void ServiceWorkerContainer::dispatchMessageEvent(const blink::WebString& message, const blink::WebMessagePortChannelArray& webChannels)
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | Source/modules/serviceworkers/ServiceWorkerContainer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698