| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 visitor->trace(m_parserScheduler); | 151 visitor->trace(m_parserScheduler); |
| 152 visitor->trace(m_xssAuditorDelegate); | 152 visitor->trace(m_xssAuditorDelegate); |
| 153 visitor->trace(m_scriptRunner); | 153 visitor->trace(m_scriptRunner); |
| 154 visitor->trace(m_preloader); | 154 visitor->trace(m_preloader); |
| 155 ScriptableDocumentParser::trace(visitor); | 155 ScriptableDocumentParser::trace(visitor); |
| 156 HTMLScriptRunnerHost::trace(visitor); | 156 HTMLScriptRunnerHost::trace(visitor); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void HTMLDocumentParser::detach() | 159 void HTMLDocumentParser::detach() |
| 160 { | 160 { |
| 161 if (!isParsingFragment() && m_parsedChunkQueue.get() && m_parsedChunkQueue->
peakPendingChunkCount()) { |
| 162 DEFINE_STATIC_LOCAL(CustomCountHistogram, peakPendingChunkHistogram, ("P
arser.PeakPendingChunkCount", 1, 1000, 50)); |
| 163 peakPendingChunkHistogram.count(m_parsedChunkQueue->peakPendingChunkCoun
t()); |
| 164 DEFINE_STATIC_LOCAL(CustomCountHistogram, peakPendingTokenHistogram, ("P
arser.PeakPendingTokenCount", 1, 100000, 50)); |
| 165 peakPendingTokenHistogram.count(m_parsedChunkQueue->peakPendingTokenCoun
t()); |
| 166 } |
| 167 |
| 161 if (m_haveBackgroundParser) | 168 if (m_haveBackgroundParser) |
| 162 stopBackgroundParser(); | 169 stopBackgroundParser(); |
| 163 DocumentParser::detach(); | 170 DocumentParser::detach(); |
| 164 if (m_scriptRunner) | 171 if (m_scriptRunner) |
| 165 m_scriptRunner->detach(); | 172 m_scriptRunner->detach(); |
| 166 m_treeBuilder->detach(); | 173 m_treeBuilder->detach(); |
| 167 // FIXME: It seems wrong that we would have a preload scanner here. | 174 // FIXME: It seems wrong that we would have a preload scanner here. |
| 168 // Yet during fast/dom/HTMLScriptElement/script-load-events.html we do. | 175 // Yet during fast/dom/HTMLScriptElement/script-load-events.html we do. |
| 169 m_preloadScanner.reset(); | 176 m_preloadScanner.reset(); |
| 170 m_insertionPreloadScanner.reset(); | 177 m_insertionPreloadScanner.reset(); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 ASSERT(token->isUninitialized()); | 385 ASSERT(token->isUninitialized()); |
| 379 return; | 386 return; |
| 380 } | 387 } |
| 381 | 388 |
| 382 discardSpeculationsAndResumeFrom(std::move(chunk), std::move(token), std::mo
ve(tokenizer)); | 389 discardSpeculationsAndResumeFrom(std::move(chunk), std::move(token), std::mo
ve(tokenizer)); |
| 383 } | 390 } |
| 384 | 391 |
| 385 void HTMLDocumentParser::discardSpeculationsAndResumeFrom(std::unique_ptr<Parsed
Chunk> lastChunkBeforeScript, std::unique_ptr<HTMLToken> token, std::unique_ptr<
HTMLTokenizer> tokenizer) | 392 void HTMLDocumentParser::discardSpeculationsAndResumeFrom(std::unique_ptr<Parsed
Chunk> lastChunkBeforeScript, std::unique_ptr<HTMLToken> token, std::unique_ptr<
HTMLTokenizer> tokenizer) |
| 386 { | 393 { |
| 387 m_weakFactory.revokeAll(); | 394 m_weakFactory.revokeAll(); |
| 395 |
| 396 size_t discardedTokenCount = 0; |
| 397 for (const auto& speculation : m_speculations) { |
| 398 discardedTokenCount += speculation->tokens->size(); |
| 399 } |
| 400 DEFINE_STATIC_LOCAL(CustomCountHistogram, discardedTokenCountHistogram, ("Pa
rser.DiscardedTokenCount", 1, 100000, 50)); |
| 401 discardedTokenCountHistogram.count(discardedTokenCount); |
| 402 |
| 388 m_speculations.clear(); | 403 m_speculations.clear(); |
| 389 | 404 |
| 390 std::unique_ptr<BackgroundHTMLParser::Checkpoint> checkpoint = wrapUnique(ne
w BackgroundHTMLParser::Checkpoint); | 405 std::unique_ptr<BackgroundHTMLParser::Checkpoint> checkpoint = wrapUnique(ne
w BackgroundHTMLParser::Checkpoint); |
| 391 checkpoint->parser = m_weakFactory.createWeakPtr(); | 406 checkpoint->parser = m_weakFactory.createWeakPtr(); |
| 392 checkpoint->token = std::move(token); | 407 checkpoint->token = std::move(token); |
| 393 checkpoint->tokenizer = std::move(tokenizer); | 408 checkpoint->tokenizer = std::move(tokenizer); |
| 394 checkpoint->treeBuilderState = HTMLTreeBuilderSimulator::stateFor(m_treeBuil
der.get()); | 409 checkpoint->treeBuilderState = HTMLTreeBuilderSimulator::stateFor(m_treeBuil
der.get()); |
| 395 checkpoint->inputCheckpoint = lastChunkBeforeScript->inputCheckpoint; | 410 checkpoint->inputCheckpoint = lastChunkBeforeScript->inputCheckpoint; |
| 396 checkpoint->preloadScannerCheckpoint = lastChunkBeforeScript->preloadScanner
Checkpoint; | 411 checkpoint->preloadScannerCheckpoint = lastChunkBeforeScript->preloadScanner
Checkpoint; |
| 397 checkpoint->unparsedInput = m_input.current().toString().isolatedCopy(); | 412 checkpoint->unparsedInput = m_input.current().toString().isolatedCopy(); |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 DEFINE_STATIC_LOCAL(CustomCountHistogram, successHistogram, ("PreloadSca
nner.DocumentWrite.ExecutionTime.Success", 1, 10000, 50)); | 1126 DEFINE_STATIC_LOCAL(CustomCountHistogram, successHistogram, ("PreloadSca
nner.DocumentWrite.ExecutionTime.Success", 1, 10000, 50)); |
| 1112 successHistogram.count(duration); | 1127 successHistogram.count(duration); |
| 1113 } else { | 1128 } else { |
| 1114 DEFINE_STATIC_LOCAL(CustomCountHistogram, failureHistogram, ("PreloadSca
nner.DocumentWrite.ExecutionTime.Failure", 1, 10000, 50)); | 1129 DEFINE_STATIC_LOCAL(CustomCountHistogram, failureHistogram, ("PreloadSca
nner.DocumentWrite.ExecutionTime.Failure", 1, 10000, 50)); |
| 1115 failureHistogram.count(duration); | 1130 failureHistogram.count(duration); |
| 1116 } | 1131 } |
| 1117 | 1132 |
| 1118 } | 1133 } |
| 1119 | 1134 |
| 1120 } // namespace blink | 1135 } // namespace blink |
| OLD | NEW |