| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/workers/Worklet.h" | 5 #include "core/workers/Worklet.h" |
| 6 | 6 |
| 7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/workers/WorkletGlobalScopeProxy.h" | 10 #include "core/workers/WorkletGlobalScopeProxy.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 Worklet::Worklet(LocalFrame* frame) | 14 Worklet::Worklet(LocalFrame* frame) |
| 15 : ContextLifecycleObserver(frame->GetDocument()), frame_(frame) { | 15 : ContextLifecycleObserver(frame->GetDocument()), frame_(frame) { |
| 16 DCHECK(IsMainThread()); | 16 DCHECK(IsMainThread()); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void Worklet::ContextDestroyed(ExecutionContext*) { | 19 void Worklet::ContextDestroyed(ExecutionContext*) { |
| 20 DCHECK(IsMainThread()); | 20 DCHECK(IsMainThread()); |
| 21 if (IsInitialized()) | |
| 22 GetWorkletGlobalScopeProxy()->TerminateWorkletGlobalScope(); | |
| 23 frame_ = nullptr; | 21 frame_ = nullptr; |
| 24 } | 22 } |
| 25 | 23 |
| 26 DEFINE_TRACE(Worklet) { | 24 DEFINE_TRACE(Worklet) { |
| 27 visitor->Trace(frame_); | 25 visitor->Trace(frame_); |
| 28 ContextLifecycleObserver::Trace(visitor); | 26 ContextLifecycleObserver::Trace(visitor); |
| 29 } | 27 } |
| 30 | 28 |
| 31 } // namespace blink | 29 } // namespace blink |
| OLD | NEW |