Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / core / timing / DOMWindowPerformance.cpp
blobb7180dea467ca7df57a687c19530420ac44f9244
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.
5 #include "config.h"
6 #include "core/timing/DOMWindowPerformance.h"
8 #include "core/frame/LocalDOMWindow.h"
9 #include "core/frame/LocalFrame.h"
10 #include "core/timing/Performance.h"
12 namespace blink {
14 DOMWindowPerformance::DOMWindowPerformance(LocalDOMWindow& window)
15 : DOMWindowProperty(window.frame())
16 , m_window(&window)
20 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DOMWindowPerformance);
22 DEFINE_TRACE(DOMWindowPerformance)
24 visitor->trace(m_window);
25 visitor->trace(m_performance);
26 WillBeHeapSupplement<LocalDOMWindow>::trace(visitor);
27 DOMWindowProperty::trace(visitor);
30 // static
31 const char* DOMWindowPerformance::supplementName()
33 return "DOMWindowPerformance";
36 // static
37 DOMWindowPerformance& DOMWindowPerformance::from(LocalDOMWindow& window)
39 DOMWindowPerformance* supplement = static_cast<DOMWindowPerformance*>(WillBeHeapSupplement<LocalDOMWindow>::from(window, supplementName()));
40 if (!supplement) {
41 supplement = new DOMWindowPerformance(window);
42 provideTo(window, supplementName(), adoptPtrWillBeNoop(supplement));
44 return *supplement;
47 // static
48 Performance* DOMWindowPerformance::performance(DOMWindow& window)
50 return from(toLocalDOMWindow(window)).performance();
53 Performance* DOMWindowPerformance::performance()
55 if (!m_performance)
56 m_performance = Performance::create(m_window->frame());
57 return m_performance.get();
60 } // namespace blink