| 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 "modules/worklet/DOMWindowWorklet.h" | 5 #include "modules/worklet/DOMWindowWorklet.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalDOMWindow.h" | 7 #include "core/frame/LocalDOMWindow.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "modules/worklet/Worklet.h" | 9 #include "modules/worklet/Worklet.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 DOMWindowWorklet::DOMWindowWorklet(LocalDOMWindow& window) | 13 DOMWindowWorklet::DOMWindowWorklet(LocalDOMWindow& window) |
| 14 : DOMWindowProperty(window.frame()) | 14 : DOMWindowProperty(window.frame()) |
| 15 { | 15 { |
| 16 } | 16 } |
| 17 | 17 |
| 18 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DOMWindowWorklet); | |
| 19 | |
| 20 const char* DOMWindowWorklet::supplementName() | 18 const char* DOMWindowWorklet::supplementName() |
| 21 { | 19 { |
| 22 return "DOMWindowWorklet"; | 20 return "DOMWindowWorklet"; |
| 23 } | 21 } |
| 24 | 22 |
| 25 // static | 23 // static |
| 26 DOMWindowWorklet& DOMWindowWorklet::from(LocalDOMWindow& window) | 24 DOMWindowWorklet& DOMWindowWorklet::from(LocalDOMWindow& window) |
| 27 { | 25 { |
| 28 DOMWindowWorklet* supplement = static_cast<DOMWindowWorklet*>(WillBeHeapSupp
lement<LocalDOMWindow>::from(window, supplementName())); | 26 DOMWindowWorklet* supplement = static_cast<DOMWindowWorklet*>(HeapSupplement
<LocalDOMWindow>::from(window, supplementName())); |
| 29 if (!supplement) { | 27 if (!supplement) { |
| 30 supplement = new DOMWindowWorklet(window); | 28 supplement = new DOMWindowWorklet(window); |
| 31 provideTo(window, supplementName(), adoptPtrWillBeNoop(supplement)); | 29 provideTo(window, supplementName(), (supplement)); |
| 32 } | 30 } |
| 33 return *supplement; | 31 return *supplement; |
| 34 } | 32 } |
| 35 | 33 |
| 36 // static | 34 // static |
| 37 Worklet* DOMWindowWorklet::renderWorklet(ExecutionContext* executionContext, DOM
Window& window) | 35 Worklet* DOMWindowWorklet::renderWorklet(ExecutionContext* executionContext, DOM
Window& window) |
| 38 { | 36 { |
| 39 return from(toLocalDOMWindow(window)).renderWorklet(executionContext); | 37 return from(toLocalDOMWindow(window)).renderWorklet(executionContext); |
| 40 } | 38 } |
| 41 | 39 |
| 42 Worklet* DOMWindowWorklet::renderWorklet(ExecutionContext* executionContext) con
st | 40 Worklet* DOMWindowWorklet::renderWorklet(ExecutionContext* executionContext) con
st |
| 43 { | 41 { |
| 44 if (!m_renderWorklet && frame()) | 42 if (!m_renderWorklet && frame()) |
| 45 m_renderWorklet = Worklet::create(executionContext); | 43 m_renderWorklet = Worklet::create(executionContext); |
| 46 return m_renderWorklet.get(); | 44 return m_renderWorklet.get(); |
| 47 } | 45 } |
| 48 | 46 |
| 49 DEFINE_TRACE(DOMWindowWorklet) | 47 DEFINE_TRACE(DOMWindowWorklet) |
| 50 { | 48 { |
| 51 visitor->trace(m_renderWorklet); | 49 visitor->trace(m_renderWorklet); |
| 52 WillBeHeapSupplement<LocalDOMWindow>::trace(visitor); | 50 HeapSupplement<LocalDOMWindow>::trace(visitor); |
| 53 DOMWindowProperty::trace(visitor); | 51 DOMWindowProperty::trace(visitor); |
| 54 } | 52 } |
| 55 | 53 |
| 56 } // namespace blink | 54 } // namespace blink |
| OLD | NEW |