ServiceWorkerThread's m_extendedEvents gets destroyed on the wrong thread
https://bugs.webkit.org/show_bug.cgi?id=180216

Reviewed by Brady Eidson.

ServiceWorkerThread's m_extendedEvents gets destroyed on the wrong thread. Those events live on the worker
thread so we should destroy them on the worker thread, not the main thread. To address the issue, m_extendedEvents
was moved to ServiceWorkerGlobalScope, which actually lives on the right thread.

* workers/service/ServiceWorkerGlobalScope.cpp:
(WebCore::ServiceWorkerGlobalScope::updateExtendedEventsSet):
* workers/service/ServiceWorkerGlobalScope.h:
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::postFetchTask):
(WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope):
(WebCore::ServiceWorkerThread::updateExtendedEventsSet): Deleted.
* workers/service/context/ServiceWorkerThread.h:
(WebCore::ServiceWorkerThread::hasPendingEvents const): Deleted.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@225351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/bindings/js/JSDOMGuardedObject.cpp b/Source/WebCore/bindings/js/JSDOMGuardedObject.cpp
index ed8dbd1..a835903 100644
--- a/Source/WebCore/bindings/js/JSDOMGuardedObject.cpp
+++ b/Source/WebCore/bindings/js/JSDOMGuardedObject.cpp
@@ -53,6 +53,7 @@
         m_globalObject->guardedObjects(locker).remove(this);
     }
     m_guarded.clear();
+    m_globalObject.clear();
 }
 
 void DOMGuardedObject::contextDestroyed()