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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp

Issue 1765493002: Revert of Make AbstractWorker a ContextLifecycleObserver rather than an ActiveDOMObject (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
index 16d287892bc8d21b2b1d550f3473cf21fe7da29f..9ad3c6ac88a5eae82d28cba638de552633bc5e8b 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
@@ -111,9 +111,16 @@
bool ServiceWorker::hasPendingActivity() const
{
- if (!executionContext())
+ if (AbstractWorker::hasPendingActivity())
+ return true;
+ if (m_wasStopped)
return false;
return m_handle->serviceWorker()->state() != WebServiceWorkerStateRedundant;
+}
+
+void ServiceWorker::stop()
+{
+ m_wasStopped = true;
}
ServiceWorker* ServiceWorker::getOrCreate(ExecutionContext* executionContext, PassOwnPtr<WebServiceWorker::Handle> handle)
@@ -127,12 +134,15 @@
return existingWorker;
}
- return new ServiceWorker(executionContext, handle);
+ ServiceWorker* newWorker = new ServiceWorker(executionContext, handle);
+ newWorker->suspendIfNeeded();
+ return newWorker;
}
ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebServiceWorker::Handle> handle)
: AbstractWorker(executionContext)
, m_handle(handle)
+ , m_wasStopped(false)
{
ASSERT(m_handle);
m_handle->serviceWorker()->setProxy(this);
« no previous file with comments | « third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698