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

Side by Side Diff: third_party/WebKit/Source/core/workers/Worklet.cpp

Issue 2845533002: Worklet: Move Worklet::Initialize() into ThreadedWorklet for cleanup (Closed)
Patch Set: fix test failures Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698