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

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

Issue 424693004: ServiceWorker: Add 'updatefound' and version attributes on SWRegistration (Blink) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address tkent's comments Created 6 years, 4 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/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
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerRegistration.h ('k') | Source/modules/serviceworkers/ServiceWorkerRegistration.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698