| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 void HTMLDocumentParser::detach() | 157 void HTMLDocumentParser::detach() |
| 158 { | 158 { |
| 159 if (m_haveBackgroundParser) | 159 if (m_haveBackgroundParser) |
| 160 stopBackgroundParser(); | 160 stopBackgroundParser(); |
| 161 DocumentParser::detach(); | 161 DocumentParser::detach(); |
| 162 if (m_scriptRunner) | 162 if (m_scriptRunner) |
| 163 m_scriptRunner->detach(); | 163 m_scriptRunner->detach(); |
| 164 m_treeBuilder->detach(); | 164 m_treeBuilder->detach(); |
| 165 // FIXME: It seems wrong that we would have a preload scanner here. | 165 // FIXME: It seems wrong that we would have a preload scanner here. |
| 166 // Yet during fast/dom/HTMLScriptElement/script-load-events.html we do. | 166 // Yet during fast/dom/HTMLScriptElement/script-load-events.html we do. |
| 167 m_preloadScanner.clear(); | 167 m_preloadScanner.reset(); |
| 168 m_insertionPreloadScanner.clear(); | 168 m_insertionPreloadScanner.reset(); |
| 169 if (m_parserScheduler) { | 169 if (m_parserScheduler) { |
| 170 m_parserScheduler->detach(); | 170 m_parserScheduler->detach(); |
| 171 m_parserScheduler.clear(); | 171 m_parserScheduler.clear(); |
| 172 } | 172 } |
| 173 // Oilpan: It is important to clear m_token to deallocate backing memory of | 173 // Oilpan: It is important to clear m_token to deallocate backing memory of |
| 174 // HTMLToken::m_data and let the allocator reuse the memory for | 174 // HTMLToken::m_data and let the allocator reuse the memory for |
| 175 // HTMLToken::m_data of a next HTMLDocumentParser. We need to clear | 175 // HTMLToken::m_data of a next HTMLDocumentParser. We need to clear |
| 176 // m_tokenizer first because m_tokenizer has a raw pointer to m_token. | 176 // m_tokenizer first because m_tokenizer has a raw pointer to m_token. |
| 177 m_tokenizer.clear(); | 177 m_tokenizer.reset(); |
| 178 m_token.clear(); | 178 m_token.reset(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void HTMLDocumentParser::stopParsing() | 181 void HTMLDocumentParser::stopParsing() |
| 182 { | 182 { |
| 183 DocumentParser::stopParsing(); | 183 DocumentParser::stopParsing(); |
| 184 if (m_parserScheduler) { | 184 if (m_parserScheduler) { |
| 185 m_parserScheduler->detach(); | 185 m_parserScheduler->detach(); |
| 186 m_parserScheduler.clear(); | 186 m_parserScheduler.clear(); |
| 187 } | 187 } |
| 188 if (m_haveBackgroundParser) | 188 if (m_haveBackgroundParser) |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // as appendBytes() will directly ship the data to the thread. | 756 // as appendBytes() will directly ship the data to the thread. |
| 757 ASSERT(!shouldUseThreading()); | 757 ASSERT(!shouldUseThreading()); |
| 758 | 758 |
| 759 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::
append", "size", inputSource.length()); | 759 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::
append", "size", inputSource.length()); |
| 760 const SegmentedString source(inputSource); | 760 const SegmentedString source(inputSource); |
| 761 | 761 |
| 762 if (m_preloadScanner) { | 762 if (m_preloadScanner) { |
| 763 if (m_input.current().isEmpty() && !isWaitingForScripts()) { | 763 if (m_input.current().isEmpty() && !isWaitingForScripts()) { |
| 764 // We have parsed until the end of the current input and so are now
moving ahead of the preload scanner. | 764 // We have parsed until the end of the current input and so are now
moving ahead of the preload scanner. |
| 765 // Clear the scanner so we know to scan starting from the current in
put point if we block again. | 765 // Clear the scanner so we know to scan starting from the current in
put point if we block again. |
| 766 m_preloadScanner.clear(); | 766 m_preloadScanner.reset(); |
| 767 } else { | 767 } else { |
| 768 m_preloadScanner->appendToEnd(source); | 768 m_preloadScanner->appendToEnd(source); |
| 769 if (isWaitingForScripts()) | 769 if (isWaitingForScripts()) |
| 770 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->
baseElementURL(), nullptr); | 770 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->
baseElementURL(), nullptr); |
| 771 } | 771 } |
| 772 } | 772 } |
| 773 | 773 |
| 774 m_input.appendToEnd(source); | 774 m_input.appendToEnd(source); |
| 775 | 775 |
| 776 if (inPumpSession()) { | 776 if (inPumpSession()) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 ASSERT(!isExecutingScript()); | 926 ASSERT(!isExecutingScript()); |
| 927 ASSERT(!isWaitingForScripts()); | 927 ASSERT(!isWaitingForScripts()); |
| 928 | 928 |
| 929 if (m_haveBackgroundParser) { | 929 if (m_haveBackgroundParser) { |
| 930 validateSpeculations(std::move(m_lastChunkBeforeScript)); | 930 validateSpeculations(std::move(m_lastChunkBeforeScript)); |
| 931 ASSERT(!m_lastChunkBeforeScript); | 931 ASSERT(!m_lastChunkBeforeScript); |
| 932 pumpPendingSpeculations(); | 932 pumpPendingSpeculations(); |
| 933 return; | 933 return; |
| 934 } | 934 } |
| 935 | 935 |
| 936 m_insertionPreloadScanner.clear(); | 936 m_insertionPreloadScanner.reset(); |
| 937 pumpTokenizerIfPossible(); | 937 pumpTokenizerIfPossible(); |
| 938 endIfDelayed(); | 938 endIfDelayed(); |
| 939 } | 939 } |
| 940 | 940 |
| 941 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() | 941 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() |
| 942 { | 942 { |
| 943 ASSERT(m_preloadScanner); | 943 ASSERT(m_preloadScanner); |
| 944 m_preloadScanner->appendToEnd(m_input.current()); | 944 m_preloadScanner->appendToEnd(m_input.current()); |
| 945 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->baseElementU
RL(), nullptr); | 945 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->baseElementU
RL(), nullptr); |
| 946 } | 946 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 DEFINE_STATIC_LOCAL(CustomCountHistogram, successHistogram, ("PreloadSca
nner.DocumentWrite.ExecutionTime.Success", 1, 10000, 50)); | 1112 DEFINE_STATIC_LOCAL(CustomCountHistogram, successHistogram, ("PreloadSca
nner.DocumentWrite.ExecutionTime.Success", 1, 10000, 50)); |
| 1113 successHistogram.count(duration); | 1113 successHistogram.count(duration); |
| 1114 } else { | 1114 } else { |
| 1115 DEFINE_STATIC_LOCAL(CustomCountHistogram, failureHistogram, ("PreloadSca
nner.DocumentWrite.ExecutionTime.Failure", 1, 10000, 50)); | 1115 DEFINE_STATIC_LOCAL(CustomCountHistogram, failureHistogram, ("PreloadSca
nner.DocumentWrite.ExecutionTime.Failure", 1, 10000, 50)); |
| 1116 failureHistogram.count(duration); | 1116 failureHistogram.count(duration); |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 } // namespace blink | 1121 } // namespace blink |
| OLD | NEW |