Chromium Code Reviews| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "core/timing/PerformanceResourceTiming.h" | 44 #include "core/timing/PerformanceResourceTiming.h" |
| 45 #include "core/timing/PerformanceUserTiming.h" | 45 #include "core/timing/PerformanceUserTiming.h" |
| 46 #include "platform/RuntimeEnabledFeatures.h" | 46 #include "platform/RuntimeEnabledFeatures.h" |
| 47 #include "platform/network/ResourceTimingInfo.h" | 47 #include "platform/network/ResourceTimingInfo.h" |
| 48 #include "platform/weborigin/SecurityOrigin.h" | 48 #include "platform/weborigin/SecurityOrigin.h" |
| 49 #include "wtf/CurrentTime.h" | 49 #include "wtf/CurrentTime.h" |
| 50 #include <algorithm> | 50 #include <algorithm> |
| 51 | 51 |
| 52 namespace blink { | 52 namespace blink { |
| 53 | 53 |
| 54 namespace { | |
|
panicker
2016/11/18 21:01:05
nit: add blank line
sunjian
2016/11/18 21:17:58
Done.
| |
| 55 PerformanceNavigationTiming::PerformanceNavigationType getNavigationType(Navigat ionType type, | |
| 56 Document* document) { | |
| 57 if (document && | |
| 58 document->pageVisibilityState() == PageVisibilityStatePrerender) { | |
| 59 return PerformanceNavigationTiming::KTypePrerender; | |
| 60 } | |
| 61 switch (type) { | |
| 62 case NavigationTypeReload: | |
| 63 return PerformanceNavigationTiming::KTypeReload; | |
| 64 case NavigationTypeBackForward: | |
| 65 return PerformanceNavigationTiming::KTypeBackForward; | |
| 66 default: | |
| 67 return PerformanceNavigationTiming::KTypeNavigate; | |
| 68 } | |
| 69 } | |
| 70 } | |
| 71 | |
| 54 using PerformanceObserverVector = HeapVector<Member<PerformanceObserver>>; | 72 using PerformanceObserverVector = HeapVector<Member<PerformanceObserver>>; |
| 55 | 73 |
| 56 static const size_t defaultResourceTimingBufferSize = 150; | 74 static const size_t defaultResourceTimingBufferSize = 150; |
| 57 static const size_t defaultFrameTimingBufferSize = 150; | 75 static const size_t defaultFrameTimingBufferSize = 150; |
| 58 | 76 |
| 59 PerformanceBase::PerformanceBase(double timeOrigin) | 77 PerformanceBase::PerformanceBase(double timeOrigin) |
| 60 : m_frameTimingBufferSize(defaultFrameTimingBufferSize), | 78 : m_frameTimingBufferSize(defaultFrameTimingBufferSize), |
| 61 m_resourceTimingBufferSize(defaultResourceTimingBufferSize), | 79 m_resourceTimingBufferSize(defaultResourceTimingBufferSize), |
| 62 m_userTiming(nullptr), | 80 m_userTiming(nullptr), |
| 63 m_timeOrigin(timeOrigin), | 81 m_timeOrigin(timeOrigin), |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 if (!resourceLoadTiming) | 346 if (!resourceLoadTiming) |
| 329 return; | 347 return; |
| 330 double lastRedirectEndTime = documentLoadTiming.redirectEnd(); | 348 double lastRedirectEndTime = documentLoadTiming.redirectEnd(); |
| 331 double finishTime = documentLoadTiming.loadEventEnd(); | 349 double finishTime = documentLoadTiming.loadEventEnd(); |
| 332 | 350 |
| 333 // TODO(sunjian) Implement transfer size. crbug/663187 | 351 // TODO(sunjian) Implement transfer size. crbug/663187 |
| 334 unsigned long long transferSize = 0; | 352 unsigned long long transferSize = 0; |
| 335 unsigned long long encodedBodyLength = finalResponse.encodedBodyLength(); | 353 unsigned long long encodedBodyLength = finalResponse.encodedBodyLength(); |
| 336 unsigned long long decodedBodyLength = finalResponse.decodedBodyLength(); | 354 unsigned long long decodedBodyLength = finalResponse.decodedBodyLength(); |
| 337 bool didReuseConnection = finalResponse.connectionReused(); | 355 bool didReuseConnection = finalResponse.connectionReused(); |
| 356 PerformanceNavigationTiming::PerformanceNavigationType type = | |
| 357 getNavigationType(documentLoader->getNavigationType(), frame->document()); | |
| 338 | 358 |
| 339 m_navigationTiming = new PerformanceNavigationTiming( | 359 m_navigationTiming = new PerformanceNavigationTiming( |
| 340 timeOrigin(), documentLoadTiming.unloadEventStart(), | 360 timeOrigin(), documentLoadTiming.unloadEventStart(), |
| 341 documentLoadTiming.unloadEventEnd(), documentLoadTiming.loadEventStart(), | 361 documentLoadTiming.unloadEventEnd(), documentLoadTiming.loadEventStart(), |
| 342 documentLoadTiming.loadEventEnd(), documentLoadTiming.redirectCount(), | 362 documentLoadTiming.loadEventEnd(), documentLoadTiming.redirectCount(), |
| 343 documentTiming ? documentTiming->domInteractive() : 0, | 363 documentTiming ? documentTiming->domInteractive() : 0, |
| 344 documentTiming ? documentTiming->domContentLoadedEventStart() : 0, | 364 documentTiming ? documentTiming->domContentLoadedEventStart() : 0, |
| 345 documentTiming ? documentTiming->domContentLoadedEventEnd() : 0, | 365 documentTiming ? documentTiming->domContentLoadedEventEnd() : 0, |
| 346 documentTiming ? documentTiming->domComplete() : 0, | 366 documentTiming ? documentTiming->domComplete() : 0, type, |
| 347 documentLoader->getNavigationType(), documentLoadTiming.redirectStart(), | 367 documentLoadTiming.redirectStart(), documentLoadTiming.redirectEnd(), |
| 348 documentLoadTiming.redirectEnd(), documentLoadTiming.fetchStart(), | 368 documentLoadTiming.fetchStart(), documentLoadTiming.responseEnd(), |
| 349 documentLoadTiming.responseEnd(), | |
| 350 documentLoadTiming.hasCrossOriginRedirect(), | 369 documentLoadTiming.hasCrossOriginRedirect(), |
| 351 documentLoadTiming.hasSameOriginAsPreviousDocument(), resourceLoadTiming, | 370 documentLoadTiming.hasSameOriginAsPreviousDocument(), resourceLoadTiming, |
| 352 lastRedirectEndTime, finishTime, transferSize, encodedBodyLength, | 371 lastRedirectEndTime, finishTime, transferSize, encodedBodyLength, |
| 353 decodedBodyLength, didReuseConnection); | 372 decodedBodyLength, didReuseConnection); |
| 354 notifyObserversOfEntry(*m_navigationTiming); | 373 notifyObserversOfEntry(*m_navigationTiming); |
| 355 } | 374 } |
| 356 | 375 |
| 357 void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) { | 376 void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) { |
| 358 m_resourceTimingBuffer.append(&entry); | 377 m_resourceTimingBuffer.append(&entry); |
| 359 | 378 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 visitor->trace(m_resourceTimingBuffer); | 547 visitor->trace(m_resourceTimingBuffer); |
| 529 visitor->trace(m_navigationTiming); | 548 visitor->trace(m_navigationTiming); |
| 530 visitor->trace(m_userTiming); | 549 visitor->trace(m_userTiming); |
| 531 visitor->trace(m_observers); | 550 visitor->trace(m_observers); |
| 532 visitor->trace(m_activeObservers); | 551 visitor->trace(m_activeObservers); |
| 533 visitor->trace(m_suspendedObservers); | 552 visitor->trace(m_suspendedObservers); |
| 534 EventTargetWithInlineData::trace(visitor); | 553 EventTargetWithInlineData::trace(visitor); |
| 535 } | 554 } |
| 536 | 555 |
| 537 } // namespace blink | 556 } // namespace blink |
| OLD | NEW |