| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "platform/Timer.h" | 42 #include "platform/Timer.h" |
| 43 #include "platform/heap/Handle.h" | 43 #include "platform/heap/Handle.h" |
| 44 #include "wtf/Forward.h" | 44 #include "wtf/Forward.h" |
| 45 #include "wtf/HashSet.h" | 45 #include "wtf/HashSet.h" |
| 46 #include "wtf/ListHashSet.h" | 46 #include "wtf/ListHashSet.h" |
| 47 #include "wtf/Vector.h" | 47 #include "wtf/Vector.h" |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 class ExceptionState; | 51 class ExceptionState; |
| 52 class LocalFrame; | |
| 53 class PerformanceObserver; | 52 class PerformanceObserver; |
| 54 class PerformanceTiming; | 53 class PerformanceTiming; |
| 55 class ResourceResponse; | 54 class ResourceResponse; |
| 56 class ResourceTimingInfo; | 55 class ResourceTimingInfo; |
| 57 class UserTiming; | 56 class UserTiming; |
| 58 | 57 |
| 59 using PerformanceEntryVector = HeapVector<Member<PerformanceEntry>>; | 58 using PerformanceEntryVector = HeapVector<Member<PerformanceEntry>>; |
| 60 using PerformanceObservers = HeapListHashSet<Member<PerformanceObserver>>; | 59 using PerformanceObservers = HeapListHashSet<Member<PerformanceObserver>>; |
| 61 | 60 |
| 62 class CORE_EXPORT PerformanceBase : public EventTargetWithInlineData { | 61 class CORE_EXPORT PerformanceBase : public EventTargetWithInlineData { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 | 80 |
| 82 // Translate given platform monotonic time in seconds into a high resolution | 81 // Translate given platform monotonic time in seconds into a high resolution |
| 83 // DOMHighResTimeStamp in milliseconds. The result timestamp is relative to | 82 // DOMHighResTimeStamp in milliseconds. The result timestamp is relative to |
| 84 // document's time origin and has a time resolution that is safe for | 83 // document's time origin and has a time resolution that is safe for |
| 85 // exposing to web. | 84 // exposing to web. |
| 86 DOMHighResTimeStamp monotonicTimeToDOMHighResTimeStamp(double) const; | 85 DOMHighResTimeStamp monotonicTimeToDOMHighResTimeStamp(double) const; |
| 87 DOMHighResTimeStamp now() const; | 86 DOMHighResTimeStamp now() const; |
| 88 | 87 |
| 89 double timeOrigin() const { return m_timeOrigin; } | 88 double timeOrigin() const { return m_timeOrigin; } |
| 90 | 89 |
| 91 PerformanceEntryVector getEntries() const; | 90 PerformanceEntryVector getEntries(); |
| 92 PerformanceEntryVector getEntriesByType(const String& entryType); | 91 PerformanceEntryVector getEntriesByType(const String& entryType); |
| 93 PerformanceEntryVector getEntriesByName(const String& name, | 92 PerformanceEntryVector getEntriesByName(const String& name, |
| 94 const String& entryType); | 93 const String& entryType); |
| 95 | 94 |
| 96 void clearResourceTimings(); | 95 void clearResourceTimings(); |
| 97 void setResourceTimingBufferSize(unsigned); | 96 void setResourceTimingBufferSize(unsigned); |
| 98 | 97 |
| 99 DEFINE_ATTRIBUTE_EVENT_LISTENER(resourcetimingbufferfull); | 98 DEFINE_ATTRIBUTE_EVENT_LISTENER(resourcetimingbufferfull); |
| 100 | 99 |
| 101 void clearFrameTimings(); | 100 void clearFrameTimings(); |
| 102 void setFrameTimingBufferSize(unsigned); | 101 void setFrameTimingBufferSize(unsigned); |
| 103 | 102 |
| 104 DEFINE_ATTRIBUTE_EVENT_LISTENER(frametimingbufferfull); | 103 DEFINE_ATTRIBUTE_EVENT_LISTENER(frametimingbufferfull); |
| 105 | 104 |
| 106 void addLongTaskTiming(double startTime, | 105 void addLongTaskTiming(double startTime, |
| 107 double endTime, | 106 double endTime, |
| 108 const String& name, | 107 const String& name, |
| 109 const String& culpritFrameSrc, | 108 const String& culpritFrameSrc, |
| 110 const String& culpritFrameId, | 109 const String& culpritFrameId, |
| 111 const String& culpritFrameName); | 110 const String& culpritFrameName); |
| 112 | 111 |
| 113 void addResourceTiming(const ResourceTimingInfo&); | 112 void addResourceTiming(const ResourceTimingInfo&); |
| 114 | 113 |
| 115 void addNavigationTiming(LocalFrame*); | 114 void notifyNavigationTimingToObservers(); |
| 116 | 115 |
| 117 void addFirstPaintTiming(double startTime); | 116 void addFirstPaintTiming(double startTime); |
| 118 | 117 |
| 119 void addFirstContentfulPaintTiming(double startTime); | 118 void addFirstContentfulPaintTiming(double startTime); |
| 120 | 119 |
| 121 void mark(const String& markName, ExceptionState&); | 120 void mark(const String& markName, ExceptionState&); |
| 122 void clearMarks(const String& markName); | 121 void clearMarks(const String& markName); |
| 123 | 122 |
| 124 void measure(const String& measureName, | 123 void measure(const String& measureName, |
| 125 const String& startMark, | 124 const String& startMark, |
| 126 const String& endMark, | 125 const String& endMark, |
| 127 ExceptionState&); | 126 ExceptionState&); |
| 128 void clearMeasures(const String& measureName); | 127 void clearMeasures(const String& measureName); |
| 129 | 128 |
| 130 void unregisterPerformanceObserver(PerformanceObserver&); | 129 void unregisterPerformanceObserver(PerformanceObserver&); |
| 131 void registerPerformanceObserver(PerformanceObserver&); | 130 void registerPerformanceObserver(PerformanceObserver&); |
| 132 void updatePerformanceObserverFilterOptions(); | 131 void updatePerformanceObserverFilterOptions(); |
| 133 void activateObserver(PerformanceObserver&); | 132 void activateObserver(PerformanceObserver&); |
| 134 void resumeSuspendedObservers(); | 133 void resumeSuspendedObservers(); |
| 135 | 134 |
| 136 DECLARE_VIRTUAL_TRACE(); | |
| 137 | |
| 138 private: | |
| 139 static PerformanceNavigationTiming::NavigationType getNavigationType( | |
| 140 NavigationType, | |
| 141 const Document*); | |
| 142 | |
| 143 static bool allowsTimingRedirect(const Vector<ResourceResponse>&, | 135 static bool allowsTimingRedirect(const Vector<ResourceResponse>&, |
| 144 const ResourceResponse&, | 136 const ResourceResponse&, |
| 145 const SecurityOrigin&, | 137 const SecurityOrigin&, |
| 146 ExecutionContext*); | 138 ExecutionContext*); |
| 147 | 139 |
| 140 DECLARE_VIRTUAL_TRACE(); |
| 141 |
| 142 private: |
| 148 static bool passesTimingAllowCheck(const ResourceResponse&, | 143 static bool passesTimingAllowCheck(const ResourceResponse&, |
| 149 const SecurityOrigin&, | 144 const SecurityOrigin&, |
| 150 const AtomicString&, | 145 const AtomicString&, |
| 151 ExecutionContext*); | 146 ExecutionContext*); |
| 152 | 147 |
| 153 void addPaintTiming(PerformancePaintTiming::PaintType, double startTime); | 148 void addPaintTiming(PerformancePaintTiming::PaintType, double startTime); |
| 154 | 149 |
| 155 protected: | 150 protected: |
| 156 explicit PerformanceBase(double timeOrigin, RefPtr<WebTaskRunner>); | 151 explicit PerformanceBase(double timeOrigin, RefPtr<WebTaskRunner>); |
| 157 | 152 |
| 153 // Expect Performance to override this method, |
| 154 // WorkerPerformance doesn't have to override this. |
| 155 virtual PerformanceNavigationTiming* createNavigationTimingInstance() { |
| 156 return nullptr; |
| 157 } |
| 158 |
| 158 bool isResourceTimingBufferFull(); | 159 bool isResourceTimingBufferFull(); |
| 159 void addResourceTimingBuffer(PerformanceEntry&); | 160 void addResourceTimingBuffer(PerformanceEntry&); |
| 160 | 161 |
| 161 bool isFrameTimingBufferFull(); | 162 bool isFrameTimingBufferFull(); |
| 162 void addFrameTimingBuffer(PerformanceEntry&); | 163 void addFrameTimingBuffer(PerformanceEntry&); |
| 163 | 164 |
| 164 void notifyObserversOfEntry(PerformanceEntry&); | 165 void notifyObserversOfEntry(PerformanceEntry&); |
| 165 bool hasObserverFor(PerformanceEntry::EntryType) const; | 166 bool hasObserverFor(PerformanceEntry::EntryType) const; |
| 166 | 167 |
| 167 void deliverObservationsTimerFired(TimerBase*); | 168 void deliverObservationsTimerFired(TimerBase*); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 178 PerformanceEntryTypeMask m_observerFilterOptions; | 179 PerformanceEntryTypeMask m_observerFilterOptions; |
| 179 PerformanceObservers m_observers; | 180 PerformanceObservers m_observers; |
| 180 PerformanceObservers m_activeObservers; | 181 PerformanceObservers m_activeObservers; |
| 181 PerformanceObservers m_suspendedObservers; | 182 PerformanceObservers m_suspendedObservers; |
| 182 TaskRunnerTimer<PerformanceBase> m_deliverObservationsTimer; | 183 TaskRunnerTimer<PerformanceBase> m_deliverObservationsTimer; |
| 183 }; | 184 }; |
| 184 | 185 |
| 185 } // namespace blink | 186 } // namespace blink |
| 186 | 187 |
| 187 #endif // PerformanceBase_h | 188 #endif // PerformanceBase_h |
| OLD | NEW |