OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 11 matching lines...) Expand all Loading... |
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #ifndef Performance_h | 32 #ifndef PerformanceBase_h |
33 #define Performance_h | 33 #define PerformanceBase_h |
34 | 34 |
35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
36 #include "core/events/EventTarget.h" | 36 #include "core/events/EventTarget.h" |
37 #include "core/frame/DOMWindowProperty.h" | |
38 #include "core/timing/MemoryInfo.h" | |
39 #include "core/timing/PerformanceEntry.h" | 37 #include "core/timing/PerformanceEntry.h" |
40 #include "core/timing/PerformanceNavigation.h" | |
41 #include "core/timing/PerformanceTiming.h" | |
42 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
43 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
44 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
45 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
46 | 42 |
47 namespace blink { | 43 namespace blink { |
48 | 44 |
49 class Document; | 45 class Document; |
50 class ExceptionState; | 46 class ExceptionState; |
| 47 class PerformanceTiming; |
51 class ResourceTimingInfo; | 48 class ResourceTimingInfo; |
52 class UserTiming; | 49 class UserTiming; |
53 | 50 |
54 using PerformanceEntryVector = HeapVector<Member<PerformanceEntry>>; | 51 using PerformanceEntryVector = HeapVector<Member<PerformanceEntry>>; |
55 | 52 |
56 class CORE_EXPORT Performance final : public RefCountedGarbageCollectedEventTarg
etWithInlineData<Performance>, public DOMWindowProperty { | 53 class CORE_EXPORT PerformanceBase : public RefCountedGarbageCollectedEventTarget
WithInlineData<PerformanceBase> { |
57 DEFINE_WRAPPERTYPEINFO(); | 54 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PerformanceBase); |
58 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(Performance); | 55 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PerformanceBase); |
59 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Performance); | |
60 public: | 56 public: |
61 static Performance* create(LocalFrame* frame) | 57 virtual ~PerformanceBase(); |
62 { | |
63 return new Performance(frame); | |
64 } | |
65 virtual ~Performance(); | |
66 | 58 |
67 virtual const AtomicString& interfaceName() const override; | 59 virtual const AtomicString& interfaceName() const override; |
68 virtual ExecutionContext* executionContext() const override; | |
69 | 60 |
70 MemoryInfo* memory(); | 61 virtual PerformanceTiming* timing() const; |
71 PerformanceNavigation* navigation() const; | |
72 PerformanceTiming* timing() const; | |
73 double now() const; | 62 double now() const; |
74 | 63 |
| 64 double timeOrigin() const { return m_timeOrigin; } |
| 65 |
75 PerformanceEntryVector getEntries() const; | 66 PerformanceEntryVector getEntries() const; |
76 PerformanceEntryVector getEntriesByType(const String& entryType); | 67 PerformanceEntryVector getEntriesByType(const String& entryType); |
77 PerformanceEntryVector getEntriesByName(const String& name, const String& en
tryType); | 68 PerformanceEntryVector getEntriesByName(const String& name, const String& en
tryType); |
78 | 69 |
79 void webkitClearResourceTimings(); | 70 void webkitClearResourceTimings(); |
80 void webkitSetResourceTimingBufferSize(unsigned); | 71 void webkitSetResourceTimingBufferSize(unsigned); |
81 | 72 |
82 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull); | 73 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitresourcetimingbufferfull); |
83 | 74 |
84 void clearFrameTimings(); | 75 void clearFrameTimings(); |
85 void setFrameTimingBufferSize(unsigned); | 76 void setFrameTimingBufferSize(unsigned); |
86 | 77 |
87 DEFINE_ATTRIBUTE_EVENT_LISTENER(frametimingbufferfull); | 78 DEFINE_ATTRIBUTE_EVENT_LISTENER(frametimingbufferfull); |
88 | 79 |
89 void addResourceTiming(const ResourceTimingInfo&, Document*); | 80 void addResourceTiming(const ResourceTimingInfo&, Document*); |
90 | 81 |
91 void addRenderTiming(Document*, unsigned, double, double); | 82 void addRenderTiming(Document*, unsigned, double, double); |
92 | 83 |
93 void addCompositeTiming(Document*, unsigned, double); | 84 void addCompositeTiming(Document*, unsigned, double); |
94 | 85 |
95 void mark(const String& markName, ExceptionState&); | 86 void mark(const String& markName, ExceptionState&); |
96 void clearMarks(const String& markName); | 87 void clearMarks(const String& markName); |
97 | 88 |
98 void measure(const String& measureName, const String& startMark, const Strin
g& endMark, ExceptionState&); | 89 void measure(const String& measureName, const String& startMark, const Strin
g& endMark, ExceptionState&); |
99 void clearMeasures(const String& measureName); | 90 void clearMeasures(const String& measureName); |
100 | 91 |
101 DECLARE_VIRTUAL_TRACE(); | 92 DECLARE_VIRTUAL_TRACE(); |
102 | 93 |
103 private: | 94 protected: |
104 explicit Performance(LocalFrame*); | 95 explicit PerformanceBase(double timeOrigin); |
105 | |
106 bool isResourceTimingBufferFull(); | 96 bool isResourceTimingBufferFull(); |
107 void addResourceTimingBuffer(PerformanceEntry*); | 97 void addResourceTimingBuffer(PerformanceEntry*); |
108 | 98 |
109 mutable Member<PerformanceNavigation> m_navigation; | |
110 mutable Member<PerformanceTiming> m_timing; | |
111 | |
112 bool isFrameTimingBufferFull(); | 99 bool isFrameTimingBufferFull(); |
113 void addFrameTimingBuffer(PerformanceEntry*); | 100 void addFrameTimingBuffer(PerformanceEntry*); |
114 | 101 |
115 PerformanceEntryVector m_frameTimingBuffer; | 102 PerformanceEntryVector m_frameTimingBuffer; |
116 unsigned m_frameTimingBufferSize; | 103 unsigned m_frameTimingBufferSize; |
117 PerformanceEntryVector m_resourceTimingBuffer; | 104 PerformanceEntryVector m_resourceTimingBuffer; |
118 unsigned m_resourceTimingBufferSize; | 105 unsigned m_resourceTimingBufferSize; |
119 double m_referenceTime; | 106 double m_timeOrigin; |
120 | 107 |
121 Member<MemoryInfo> m_memoryInfo; | |
122 Member<UserTiming> m_userTiming; | 108 Member<UserTiming> m_userTiming; |
123 }; | 109 }; |
124 | 110 |
125 } // namespace blink | 111 } // namespace blink |
126 | 112 |
127 #endif // Performance_h | 113 #endif // PerformanceBase_h |
OLD | NEW |