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

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

Issue 723923002: ServiceWorker: Add support for .skipWaiting and controllerchange event(1/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: split the CL Created 6 years 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 de303bdd0bf4f82395dc551d46bed571962cab29..44d8a0e00bb39f0aa7a100edacc7d744bfce976a 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -42,6 +42,7 @@
#include "core/dom/MessagePort.h"
#include "core/events/MessageEvent.h"
#include "core/frame/LocalDOMWindow.h"
+#include "modules/EventTargetModules.h"
#include "modules/serviceworkers/ServiceWorker.h"
#include "modules/serviceworkers/ServiceWorkerContainerClient.h"
#include "modules/serviceworkers/ServiceWorkerError.h"
@@ -100,6 +101,8 @@ void ServiceWorkerContainer::trace(Visitor* visitor)
visitor->trace(m_controller);
visitor->trace(m_readyRegistration);
visitor->trace(m_ready);
+ EventTargetWithInlineData::trace(visitor);
+ HeapSupplementable<ServiceWorkerContainer>::trace(visitor);
}
ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptState, const String& url, const RegistrationOptions& options)
@@ -232,13 +235,15 @@ static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker)
delete serviceWorker;
}
-void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker)
+void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker, bool shouldNotifyControllerChange)
{
if (!executionContext()) {
deleteIfNoExistingOwner(serviceWorker);
return;
}
m_controller = ServiceWorker::from(executionContext(), serviceWorker);
+ if (shouldNotifyControllerChange)
+ dispatchEvent(Event::create(EventTypeNames::controllerchange));
tkent 2014/12/01 07:57:13 Is it possible to cause use-after-free by JavaScri
xiang 2014/12/02 02:31:48 I don't know in which case the event object will b
tkent 2014/12/02 02:37:07 A web page can run any JavaScript code as a |contr
}
void ServiceWorkerContainer::setReadyRegistration(WebServiceWorkerRegistration* registration)
@@ -271,6 +276,11 @@ void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons
executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(ports.release(), value));
}
+const AtomicString& ServiceWorkerContainer::interfaceName() const
+{
+ return EventTargetNames::ServiceWorkerContainer;
+}
+
ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContext)
: ContextLifecycleObserver(executionContext)
, m_provider(0)

Powered by Google App Engine
This is Rietveld 408576698