| Index: third_party/WebKit/Source/modules/worklet/DOMWindowWorklet.cpp
|
| diff --git a/third_party/WebKit/Source/modules/worklet/DOMWindowWorklet.cpp b/third_party/WebKit/Source/modules/worklet/DOMWindowWorklet.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..db992c7ca2ad627b2cb85ac4726175a9747b78c1
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/modules/worklet/DOMWindowWorklet.cpp
|
| @@ -0,0 +1,57 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "config.h"
|
| +#include "modules/worklet/DOMWindowWorklet.h"
|
| +
|
| +#include "core/frame/LocalDOMWindow.h"
|
| +#include "modules/worklet/Worklet.h"
|
| +#include "modules/worklet/WorkletGlobalScope.h"
|
| +
|
| +namespace blink {
|
| +
|
| +DOMWindowWorklet::DOMWindowWorklet(LocalDOMWindow& window)
|
| + : DOMWindowProperty(window.frame())
|
| +{
|
| +}
|
| +
|
| +DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DOMWindowWorklet);
|
| +
|
| +const char* DOMWindowWorklet::supplementName()
|
| +{
|
| + return "DOMWindowWorklet";
|
| +}
|
| +
|
| +// static
|
| +DOMWindowWorklet& DOMWindowWorklet::from(LocalDOMWindow& window)
|
| +{
|
| + DOMWindowWorklet* supplement = static_cast<DOMWindowWorklet*>(WillBeHeapSupplement<LocalDOMWindow>::from(window, supplementName()));
|
| + if (!supplement) {
|
| + supplement = new DOMWindowWorklet(window);
|
| + provideTo(window, supplementName(), adoptPtrWillBeNoop(supplement));
|
| + }
|
| + return *supplement;
|
| +}
|
| +
|
| +// static
|
| +Worklet* DOMWindowWorklet::worklet(ExecutionContext* executionContext, DOMWindow& window)
|
| +{
|
| + return DOMWindowWorklet::from(toLocalDOMWindow(window)).worklet(executionContext);
|
| +}
|
| +
|
| +Worklet* DOMWindowWorklet::worklet(ExecutionContext* executionContext) const
|
| +{
|
| + if (!m_worklet && frame())
|
| + m_worklet = Worklet::create(executionContext);
|
| + return m_worklet.get();
|
| +}
|
| +
|
| +DEFINE_TRACE(DOMWindowWorklet)
|
| +{
|
| + visitor->trace(m_worklet);
|
| + WillBeHeapSupplement<LocalDOMWindow>::trace(visitor);
|
| + DOMWindowProperty::trace(visitor);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|