| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef DocumentParserTiming_h | 5 #ifndef DocumentParserTiming_h |
| 6 #define DocumentParserTiming_h | 6 #define DocumentParserTiming_h |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "platform/Supplementable.h" | 9 #include "platform/Supplementable.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // document. A single document may have multiple parsers, if e.g. the | 37 // document. A single document may have multiple parsers, if e.g. the |
| 38 // document is re-opened using document.write. DocumentParserTiming only | 38 // document is re-opened using document.write. DocumentParserTiming only |
| 39 // wants to record parser start and stop time for the first parser. To avoid | 39 // wants to record parser start and stop time for the first parser. To avoid |
| 40 // recording parser start and stop times for re-opened documents, we keep | 40 // recording parser start and stop times for re-opened documents, we keep |
| 41 // track of whether a parser has been detached, and avoid recording | 41 // track of whether a parser has been detached, and avoid recording |
| 42 // start/stop times for subsequent parsers, after the first parser has been | 42 // start/stop times for subsequent parsers, after the first parser has been |
| 43 // detached. | 43 // detached. |
| 44 void markParserDetached(); | 44 void markParserDetached(); |
| 45 | 45 |
| 46 // Record a duration of time that the parser yielded due to loading a | 46 // Record a duration of time that the parser yielded due to loading a |
| 47 // script, in seconds. This may be called multiple times, once for each time | 47 // script, in seconds. scriptInsertedViaDocumentWrite indicates whether the |
| 48 // the parser yields on a script load. | 48 // script causing blocking was inserted via document.write. This may be |
| 49 void recordParserBlockedOnScriptLoadDuration(double duration); | 49 // called multiple times, once for each time the parser yields on a script |
| 50 // load. |
| 51 void recordParserBlockedOnScriptLoadDuration( |
| 52 double duration, bool scriptInsertedViaDocumentWrite); |
| 50 | 53 |
| 51 // The getters below return monotonically-increasing seconds, or zero if the | 54 // The getters below return monotonically-increasing seconds, or zero if the |
| 52 // given parser event has not yet occurred. See the comments for | 55 // given parser event has not yet occurred. See the comments for |
| 53 // monotonicallyIncreasingTime in wtf/CurrentTime.h for additional details. | 56 // monotonicallyIncreasingTime in wtf/CurrentTime.h for additional details. |
| 54 | 57 |
| 55 double parserStart() const { return m_parserStart; } | 58 double parserStart() const { return m_parserStart; } |
| 56 double parserStop() const { return m_parserStop; } | 59 double parserStop() const { return m_parserStop; } |
| 57 | 60 |
| 58 // Returns the sum of all blocking script load durations reported via | 61 // Returns the sum of all blocking script load durations reported via |
| 59 // recordParseBlockedOnScriptLoadDuration. | 62 // recordParseBlockedOnScriptLoadDuration. |
| 60 double parserBlockedOnScriptLoadDuration() const { return m_parserBlockedOnS
criptLoadDuration; } | 63 double parserBlockedOnScriptLoadDuration() const { return m_parserBlockedOnS
criptLoadDuration; } |
| 61 | 64 |
| 65 // Returns the sum of all blocking script load durations due to |
| 66 // document.write reported via recordParseBlockedOnScriptLoadDuration. |
| 67 double parserBlockedOnScriptLoadDueToDocumentWriteDuration() const { return
m_parserBlockedOnScriptLoadDueToDocumentWriteDuration; } |
| 68 |
| 62 DECLARE_VIRTUAL_TRACE(); | 69 DECLARE_VIRTUAL_TRACE(); |
| 63 | 70 |
| 64 private: | 71 private: |
| 65 explicit DocumentParserTiming(Document&); | 72 explicit DocumentParserTiming(Document&); |
| 66 void notifyDocumentParserTimingChanged(); | 73 void notifyDocumentParserTimingChanged(); |
| 67 | 74 |
| 68 double m_parserStart = 0.0; | 75 double m_parserStart = 0.0; |
| 69 double m_parserStop = 0.0; | 76 double m_parserStop = 0.0; |
| 70 double m_parserBlockedOnScriptLoadDuration = 0.0; | 77 double m_parserBlockedOnScriptLoadDuration = 0.0; |
| 78 double m_parserBlockedOnScriptLoadDueToDocumentWriteDuration = 0.0; |
| 71 bool m_parserDetached = false; | 79 bool m_parserDetached = false; |
| 72 | 80 |
| 73 Member<Document> m_document; | 81 Member<Document> m_document; |
| 74 }; | 82 }; |
| 75 | 83 |
| 76 } // namespace blink | 84 } // namespace blink |
| 77 | 85 |
| 78 #endif | 86 #endif |
| OLD | NEW |