Chromium Code Reviews| 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 |
|
Nate Chapin
2016/04/07 16:29:31
I'm an old-timey WebKit curmudgeon, so I think thi
| |
| 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. Note | |
| 67 // that some uncommon cases are not currently covered by this method. See | |
| 68 // crbug/600711 for details. | |
| 69 double parserBlockedOnScriptLoadFromDocumentWriteDuration() const { return m _parserBlockedOnScriptLoadFromDocumentWriteDuration; } | |
| 70 | |
| 62 DECLARE_VIRTUAL_TRACE(); | 71 DECLARE_VIRTUAL_TRACE(); |
| 63 | 72 |
| 64 private: | 73 private: |
| 65 explicit DocumentParserTiming(Document&); | 74 explicit DocumentParserTiming(Document&); |
| 66 void notifyDocumentParserTimingChanged(); | 75 void notifyDocumentParserTimingChanged(); |
| 67 | 76 |
| 68 double m_parserStart = 0.0; | 77 double m_parserStart = 0.0; |
| 69 double m_parserStop = 0.0; | 78 double m_parserStop = 0.0; |
| 70 double m_parserBlockedOnScriptLoadDuration = 0.0; | 79 double m_parserBlockedOnScriptLoadDuration = 0.0; |
| 80 double m_parserBlockedOnScriptLoadFromDocumentWriteDuration = 0.0; | |
| 71 bool m_parserDetached = false; | 81 bool m_parserDetached = false; |
| 72 | 82 |
| 73 Member<Document> m_document; | 83 Member<Document> m_document; |
| 74 }; | 84 }; |
| 75 | 85 |
| 76 } // namespace blink | 86 } // namespace blink |
| 77 | 87 |
| 78 #endif | 88 #endif |
| OLD | NEW |