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 16 matching lines...) Expand all Loading... |
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 #include "core/timing/PerformanceBase.h" | 32 #include "core/timing/PerformanceBase.h" |
33 | 33 |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
35 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
36 #include "core/frame/UseCounter.h" | 36 #include "core/frame/UseCounter.h" |
37 #include "core/timing/PerformanceCompositeTiming.h" | |
38 #include "core/timing/PerformanceLongTaskTiming.h" | 37 #include "core/timing/PerformanceLongTaskTiming.h" |
39 #include "core/timing/PerformanceObserver.h" | 38 #include "core/timing/PerformanceObserver.h" |
40 #include "core/timing/PerformanceRenderTiming.h" | |
41 #include "core/timing/PerformanceResourceTiming.h" | 39 #include "core/timing/PerformanceResourceTiming.h" |
42 #include "core/timing/PerformanceUserTiming.h" | 40 #include "core/timing/PerformanceUserTiming.h" |
43 #include "platform/network/ResourceTimingInfo.h" | 41 #include "platform/network/ResourceTimingInfo.h" |
44 #include "platform/weborigin/SecurityOrigin.h" | 42 #include "platform/weborigin/SecurityOrigin.h" |
45 #include "wtf/CurrentTime.h" | 43 #include "wtf/CurrentTime.h" |
46 #include <algorithm> | 44 #include <algorithm> |
47 | 45 |
48 namespace blink { | 46 namespace blink { |
49 | 47 |
50 using PerformanceObserverVector = HeapVector<Member<PerformanceObserver>>; | 48 using PerformanceObserverVector = HeapVector<Member<PerformanceObserver>>; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 dispatchEvent(Event::create(EventTypeNames::resourcetimingbufferfull)); | 299 dispatchEvent(Event::create(EventTypeNames::resourcetimingbufferfull)); |
302 dispatchEvent( | 300 dispatchEvent( |
303 Event::create(EventTypeNames::webkitresourcetimingbufferfull)); | 301 Event::create(EventTypeNames::webkitresourcetimingbufferfull)); |
304 } | 302 } |
305 } | 303 } |
306 | 304 |
307 bool PerformanceBase::isResourceTimingBufferFull() { | 305 bool PerformanceBase::isResourceTimingBufferFull() { |
308 return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize; | 306 return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize; |
309 } | 307 } |
310 | 308 |
311 void PerformanceBase::addRenderTiming(Document* initiatorDocument, | |
312 unsigned sourceFrame, | |
313 double startTime, | |
314 double finishTime) { | |
315 if (isFrameTimingBufferFull() && !hasObserverFor(PerformanceEntry::Render)) | |
316 return; | |
317 | |
318 PerformanceEntry* entry = PerformanceRenderTiming::create( | |
319 initiatorDocument, sourceFrame, startTime, finishTime); | |
320 notifyObserversOfEntry(*entry); | |
321 if (!isFrameTimingBufferFull()) | |
322 addFrameTimingBuffer(*entry); | |
323 } | |
324 | |
325 void PerformanceBase::addCompositeTiming(Document* initiatorDocument, | |
326 unsigned sourceFrame, | |
327 double startTime) { | |
328 if (isFrameTimingBufferFull() && !hasObserverFor(PerformanceEntry::Composite)) | |
329 return; | |
330 | |
331 PerformanceEntry* entry = PerformanceCompositeTiming::create( | |
332 initiatorDocument, sourceFrame, startTime); | |
333 notifyObserversOfEntry(*entry); | |
334 if (!isFrameTimingBufferFull()) | |
335 addFrameTimingBuffer(*entry); | |
336 } | |
337 | |
338 void PerformanceBase::addFrameTimingBuffer(PerformanceEntry& entry) { | 309 void PerformanceBase::addFrameTimingBuffer(PerformanceEntry& entry) { |
339 m_frameTimingBuffer.append(&entry); | 310 m_frameTimingBuffer.append(&entry); |
340 | 311 |
341 if (isFrameTimingBufferFull()) | 312 if (isFrameTimingBufferFull()) |
342 dispatchEvent(Event::create(EventTypeNames::frametimingbufferfull)); | 313 dispatchEvent(Event::create(EventTypeNames::frametimingbufferfull)); |
343 } | 314 } |
344 | 315 |
345 bool PerformanceBase::isFrameTimingBufferFull() { | 316 bool PerformanceBase::isFrameTimingBufferFull() { |
346 return m_frameTimingBuffer.size() >= m_frameTimingBufferSize; | 317 return m_frameTimingBuffer.size() >= m_frameTimingBufferSize; |
347 } | 318 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 visitor->trace(m_frameTimingBuffer); | 465 visitor->trace(m_frameTimingBuffer); |
495 visitor->trace(m_resourceTimingBuffer); | 466 visitor->trace(m_resourceTimingBuffer); |
496 visitor->trace(m_userTiming); | 467 visitor->trace(m_userTiming); |
497 visitor->trace(m_observers); | 468 visitor->trace(m_observers); |
498 visitor->trace(m_activeObservers); | 469 visitor->trace(m_activeObservers); |
499 visitor->trace(m_suspendedObservers); | 470 visitor->trace(m_suspendedObservers); |
500 EventTargetWithInlineData::trace(visitor); | 471 EventTargetWithInlineData::trace(visitor); |
501 } | 472 } |
502 | 473 |
503 } // namespace blink | 474 } // namespace blink |
OLD | NEW |