OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/timing/DOMWindowPerformance.h" | 5 #include "core/timing/DOMWindowPerformance.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 "core/timing/Performance.h" | 9 #include "core/timing/Performance.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 DOMWindowPerformance::DOMWindowPerformance(LocalDOMWindow& window) | 13 DOMWindowPerformance::DOMWindowPerformance(LocalDOMWindow& window) |
14 : DOMWindowProperty(window.frame()) | 14 : DOMWindowProperty(window.frame()) |
15 , m_window(&window) | 15 , m_window(&window) |
16 { | 16 { |
17 } | 17 } |
18 | 18 |
19 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DOMWindowPerformance); | |
20 | |
21 DEFINE_TRACE(DOMWindowPerformance) | 19 DEFINE_TRACE(DOMWindowPerformance) |
22 { | 20 { |
23 visitor->trace(m_window); | 21 visitor->trace(m_window); |
24 visitor->trace(m_performance); | 22 visitor->trace(m_performance); |
25 WillBeHeapSupplement<LocalDOMWindow>::trace(visitor); | 23 HeapSupplement<LocalDOMWindow>::trace(visitor); |
26 DOMWindowProperty::trace(visitor); | 24 DOMWindowProperty::trace(visitor); |
27 } | 25 } |
28 | 26 |
29 // static | 27 // static |
30 const char* DOMWindowPerformance::supplementName() | 28 const char* DOMWindowPerformance::supplementName() |
31 { | 29 { |
32 return "DOMWindowPerformance"; | 30 return "DOMWindowPerformance"; |
33 } | 31 } |
34 | 32 |
35 // static | 33 // static |
36 DOMWindowPerformance& DOMWindowPerformance::from(LocalDOMWindow& window) | 34 DOMWindowPerformance& DOMWindowPerformance::from(LocalDOMWindow& window) |
37 { | 35 { |
38 DOMWindowPerformance* supplement = static_cast<DOMWindowPerformance*>(WillBe
HeapSupplement<LocalDOMWindow>::from(window, supplementName())); | 36 DOMWindowPerformance* supplement = static_cast<DOMWindowPerformance*>(HeapSu
pplement<LocalDOMWindow>::from(window, supplementName())); |
39 if (!supplement) { | 37 if (!supplement) { |
40 supplement = new DOMWindowPerformance(window); | 38 supplement = new DOMWindowPerformance(window); |
41 provideTo(window, supplementName(), adoptPtrWillBeNoop(supplement)); | 39 provideTo(window, supplementName(), adoptPtrWillBeNoop(supplement)); |
42 } | 40 } |
43 return *supplement; | 41 return *supplement; |
44 } | 42 } |
45 | 43 |
46 // static | 44 // static |
47 Performance* DOMWindowPerformance::performance(DOMWindow& window) | 45 Performance* DOMWindowPerformance::performance(DOMWindow& window) |
48 { | 46 { |
49 return from(toLocalDOMWindow(window)).performance(); | 47 return from(toLocalDOMWindow(window)).performance(); |
50 } | 48 } |
51 | 49 |
52 Performance* DOMWindowPerformance::performance() | 50 Performance* DOMWindowPerformance::performance() |
53 { | 51 { |
54 if (!m_performance) | 52 if (!m_performance) |
55 m_performance = Performance::create(m_window->frame()); | 53 m_performance = Performance::create(m_window->frame()); |
56 return m_performance.get(); | 54 return m_performance.get(); |
57 } | 55 } |
58 | 56 |
59 } // namespace blink | 57 } // namespace blink |
OLD | NEW |