Index: Source/modules/serviceworkers/ServiceWorkerRegistration.cpp |
diff --git a/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp b/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp |
index 6675a7cf4192f6e98f672c846e24f22791b1909a..a1931de787191456eefd1d3fa9804697c8f95441 100644 |
--- a/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp |
+++ b/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp |
@@ -12,6 +12,7 @@ |
#include "core/dom/DOMException.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/dom/ExecutionContext.h" |
+#include "core/events/Event.h" |
#include "modules/EventTargetModules.h" |
#include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
#include "modules/serviceworkers/ServiceWorkerError.h" |
@@ -40,11 +41,49 @@ private: |
UndefinedValue(); |
}; |
+static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker) |
+{ |
+ if (serviceWorker && !serviceWorker->proxy()) |
+ delete serviceWorker; |
+} |
+ |
const AtomicString& ServiceWorkerRegistration::interfaceName() const |
{ |
return EventTargetNames::ServiceWorkerRegistration; |
} |
+void ServiceWorkerRegistration::dispatchUpdateFoundEvent() |
+{ |
+ dispatchEvent(Event::create(EventTypeNames::updatefound)); |
+} |
+ |
+void ServiceWorkerRegistration::setInstalling(WebServiceWorker* serviceWorker) |
+{ |
+ if (!executionContext()) { |
+ deleteIfNoExistingOwner(serviceWorker); |
+ return; |
+ } |
+ m_installing = ServiceWorker::from(executionContext(), serviceWorker); |
+} |
+ |
+void ServiceWorkerRegistration::setWaiting(WebServiceWorker* serviceWorker) |
+{ |
+ if (!executionContext()) { |
+ deleteIfNoExistingOwner(serviceWorker); |
+ return; |
+ } |
+ m_waiting = ServiceWorker::from(executionContext(), serviceWorker); |
+} |
+ |
+void ServiceWorkerRegistration::setActive(WebServiceWorker* serviceWorker) |
+{ |
+ if (!executionContext()) { |
+ deleteIfNoExistingOwner(serviceWorker); |
+ return; |
+ } |
+ m_active = ServiceWorker::from(executionContext(), serviceWorker); |
+} |
+ |
PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::take(ScriptPromiseResolver* resolver, WebType* registration) |
{ |
if (!registration) |
@@ -52,6 +91,11 @@ PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::tak |
return create(resolver->scriptState()->executionContext(), adoptPtr(registration)); |
} |
+void ServiceWorkerRegistration::dispose(WebType* registration) |
+{ |
+ delete registration; |
+} |
+ |
String ServiceWorkerRegistration::scope() const |
{ |
return m_outerRegistration->scope().string(); |
@@ -98,6 +142,7 @@ ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* execution |
return; |
if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(executionContext)) |
m_provider = client->provider(); |
+ m_outerRegistration->setProxy(this); |
} |
} // namespace blink |