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

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

Issue 214413004: Dispatch the ServiceWorker "activate" event during activation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Workers, activate! Created 6 years, 9 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/WaitUntilObserver.cpp
diff --git a/Source/modules/serviceworkers/WaitUntilObserver.cpp b/Source/modules/serviceworkers/WaitUntilObserver.cpp
index c5a4d4e1c14edc6df99dc01057de445bd133f8c1..bb8cc22aa84e9e3c963ddd7595652a5a96454616 100644
--- a/Source/modules/serviceworkers/WaitUntilObserver.cpp
+++ b/Source/modules/serviceworkers/WaitUntilObserver.cpp
@@ -53,9 +53,9 @@ private:
ResolveType m_resolveType;
};
-PassRefPtr<WaitUntilObserver> WaitUntilObserver::create(ExecutionContext* context, int eventID)
+PassRefPtr<WaitUntilObserver> WaitUntilObserver::create(ExecutionContext* context, EventType type, int eventID)
{
- return adoptRef(new WaitUntilObserver(context, eventID));
+ return adoptRef(new WaitUntilObserver(context, type, eventID));
}
WaitUntilObserver::~WaitUntilObserver()
@@ -81,8 +81,9 @@ void WaitUntilObserver::waitUntil(const ScriptValue& value)
ThenFunction::create(this, ThenFunction::Rejected));
}
-WaitUntilObserver::WaitUntilObserver(ExecutionContext* context, int eventID)
+WaitUntilObserver::WaitUntilObserver(ExecutionContext* context, EventType type, int eventID)
: ContextLifecycleObserver(context)
+ , m_type(type)
, m_eventID(eventID)
, m_pendingActivity(0)
, m_hasError(false)
@@ -108,8 +109,16 @@ void WaitUntilObserver::decrementPendingActivity()
if (--m_pendingActivity || !executionContext())
return;
+ ServiceWorkerGlobalScopeClient* client = ServiceWorkerGlobalScopeClient::from(executionContext());
blink::WebServiceWorkerEventResult result = m_hasError ? blink::WebServiceWorkerEventResultRejected : blink::WebServiceWorkerEventResultCompleted;
- ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleInstallEvent(m_eventID, result);
+ switch (m_type) {
+ case Activate:
+ client->didHandleActivateEvent(m_eventID, result);
+ break;
+ case Install:
+ client->didHandleInstallEvent(m_eventID, result);
+ break;
+ }
observeContext(0);
}

Powered by Google App Engine
This is Rietveld 408576698