OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "modules/worklet/DOMWindowWorklet.h" |
| 7 |
| 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "modules/worklet/Worklet.h" |
| 10 #include "modules/worklet/WorkletGlobalScope.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 DOMWindowWorklet::DOMWindowWorklet(LocalDOMWindow& window) |
| 15 : DOMWindowProperty(window.frame()) |
| 16 { |
| 17 } |
| 18 |
| 19 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DOMWindowWorklet); |
| 20 |
| 21 const char* DOMWindowWorklet::supplementName() |
| 22 { |
| 23 return "DOMWindowWorklet"; |
| 24 } |
| 25 |
| 26 // static |
| 27 DOMWindowWorklet& DOMWindowWorklet::from(LocalDOMWindow& window) |
| 28 { |
| 29 DOMWindowWorklet* supplement = static_cast<DOMWindowWorklet*>(WillBeHeapSupp
lement<LocalDOMWindow>::from(window, supplementName())); |
| 30 if (!supplement) { |
| 31 supplement = new DOMWindowWorklet(window); |
| 32 provideTo(window, supplementName(), adoptPtrWillBeNoop(supplement)); |
| 33 } |
| 34 return *supplement; |
| 35 } |
| 36 |
| 37 // static |
| 38 Worklet* DOMWindowWorklet::worklet(ExecutionContext* executionContext, DOMWindow
& window) |
| 39 { |
| 40 return DOMWindowWorklet::from(toLocalDOMWindow(window)).worklet(executionCon
text); |
| 41 } |
| 42 |
| 43 Worklet* DOMWindowWorklet::worklet(ExecutionContext* executionContext) const |
| 44 { |
| 45 if (!m_worklet && frame()) |
| 46 m_worklet = Worklet::create(executionContext); |
| 47 return m_worklet.get(); |
| 48 } |
| 49 |
| 50 DEFINE_TRACE(DOMWindowWorklet) |
| 51 { |
| 52 visitor->trace(m_worklet); |
| 53 WillBeHeapSupplement<LocalDOMWindow>::trace(visitor); |
| 54 DOMWindowProperty::trace(visitor); |
| 55 } |
| 56 |
| 57 } // namespace blink |
OLD | NEW |