| 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 ASSERT(m_tokenizer->getState() == HTMLTokenizer::DataState); | 606 ASSERT(m_tokenizer->getState() == HTMLTokenizer::DataState); |
| 607 | 607 |
| 608 ASSERT(m_preloader); | 608 ASSERT(m_preloader); |
| 609 // TODO(kouhei): m_preloader should be always available for synchronous
parsing case, | 609 // TODO(kouhei): m_preloader should be always available for synchronous
parsing case, |
| 610 // adding paranoia if for speculative crash fix for crbug.com/465478 | 610 // adding paranoia if for speculative crash fix for crbug.com/465478 |
| 611 if (m_preloader) { | 611 if (m_preloader) { |
| 612 if (!m_preloadScanner) { | 612 if (!m_preloadScanner) { |
| 613 m_preloadScanner = createPreloadScanner(); | 613 m_preloadScanner = createPreloadScanner(); |
| 614 m_preloadScanner->appendToEnd(m_input.current()); | 614 m_preloadScanner->appendToEnd(m_input.current()); |
| 615 } | 615 } |
| 616 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->base
ElementURL(), nullptr); | 616 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->vali
dBaseElementURL(), nullptr); |
| 617 } | 617 } |
| 618 } | 618 } |
| 619 | 619 |
| 620 TRACE_EVENT_END1("devtools.timeline", "ParseHTML", "endData", InspectorParse
HtmlEvent::endData(m_input.current().currentLine().zeroBasedInt() - 1)); | 620 TRACE_EVENT_END1("devtools.timeline", "ParseHTML", "endData", InspectorParse
HtmlEvent::endData(m_input.current().currentLine().zeroBasedInt() - 1)); |
| 621 } | 621 } |
| 622 | 622 |
| 623 void HTMLDocumentParser::constructTreeFromHTMLToken() | 623 void HTMLDocumentParser::constructTreeFromHTMLToken() |
| 624 { | 624 { |
| 625 AtomicHTMLToken atomicToken(token()); | 625 AtomicHTMLToken atomicToken(token()); |
| 626 | 626 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 excludedLineNumberSource.setExcludeLineNumbers(); | 683 excludedLineNumberSource.setExcludeLineNumbers(); |
| 684 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); | 684 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); |
| 685 pumpTokenizerIfPossible(); | 685 pumpTokenizerIfPossible(); |
| 686 | 686 |
| 687 if (isWaitingForScripts()) { | 687 if (isWaitingForScripts()) { |
| 688 // Check the document.write() output with a separate preload scanner as | 688 // Check the document.write() output with a separate preload scanner as |
| 689 // the main scanner can't deal with insertions. | 689 // the main scanner can't deal with insertions. |
| 690 if (!m_insertionPreloadScanner) | 690 if (!m_insertionPreloadScanner) |
| 691 m_insertionPreloadScanner = createPreloadScanner(); | 691 m_insertionPreloadScanner = createPreloadScanner(); |
| 692 m_insertionPreloadScanner->appendToEnd(source); | 692 m_insertionPreloadScanner->appendToEnd(source); |
| 693 m_insertionPreloadScanner->scanAndPreload(m_preloader.get(), document()-
>baseElementURL(), nullptr); | 693 m_insertionPreloadScanner->scanAndPreload(m_preloader.get(), document()-
>validBaseElementURL(), nullptr); |
| 694 } | 694 } |
| 695 | 695 |
| 696 endIfDelayed(); | 696 endIfDelayed(); |
| 697 } | 697 } |
| 698 | 698 |
| 699 void HTMLDocumentParser::startBackgroundParser() | 699 void HTMLDocumentParser::startBackgroundParser() |
| 700 { | 700 { |
| 701 ASSERT(!isStopped()); | 701 ASSERT(!isStopped()); |
| 702 ASSERT(shouldUseThreading()); | 702 ASSERT(shouldUseThreading()); |
| 703 ASSERT(!m_haveBackgroundParser); | 703 ASSERT(!m_haveBackgroundParser); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.clear(); |
| 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()->
validBaseElementURL(), 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()) { |
| 777 // We've gotten data off the network in a nested write. | 777 // We've gotten data off the network in a nested write. |
| 778 // We don't want to consume any more of the input stream now. Do | 778 // We don't want to consume any more of the input stream now. Do |
| 779 // not worry. We'll consume this data in a less-nested write(). | 779 // not worry. We'll consume this data in a less-nested write(). |
| 780 return; | 780 return; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 | 935 |
| 936 m_insertionPreloadScanner.clear(); | 936 m_insertionPreloadScanner.clear(); |
| 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()->validBaseEle
mentURL(), nullptr); |
| 946 } | 946 } |
| 947 | 947 |
| 948 void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource) | 948 void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource) |
| 949 { | 949 { |
| 950 ASSERT(m_scriptRunner); | 950 ASSERT(m_scriptRunner); |
| 951 ASSERT(!isExecutingScript()); | 951 ASSERT(!isExecutingScript()); |
| 952 | 952 |
| 953 if (isStopped()) { | 953 if (isStopped()) { |
| 954 return; | 954 return; |
| 955 } | 955 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 bool neededInitialization = m_evaluator->ensureEvaluationContext(); | 1091 bool neededInitialization = m_evaluator->ensureEvaluationContext(); |
| 1092 double initializationDuration = monotonicallyIncreasingTimeMS() - initialize
StartTime; | 1092 double initializationDuration = monotonicallyIncreasingTimeMS() - initialize
StartTime; |
| 1093 | 1093 |
| 1094 double startTime = monotonicallyIncreasingTimeMS(); | 1094 double startTime = monotonicallyIncreasingTimeMS(); |
| 1095 String writtenSource = m_evaluator->evaluateAndEmitWrittenSource(source); | 1095 String writtenSource = m_evaluator->evaluateAndEmitWrittenSource(source); |
| 1096 double duration = monotonicallyIncreasingTimeMS() - startTime; | 1096 double duration = monotonicallyIncreasingTimeMS() - startTime; |
| 1097 | 1097 |
| 1098 int currentPreloadCount = document()->loader()->fetcher()->countPreloads(); | 1098 int currentPreloadCount = document()->loader()->fetcher()->countPreloads(); |
| 1099 OwnPtr<HTMLPreloadScanner> scanner = createPreloadScanner(); | 1099 OwnPtr<HTMLPreloadScanner> scanner = createPreloadScanner(); |
| 1100 scanner->appendToEnd(SegmentedString(writtenSource)); | 1100 scanner->appendToEnd(SegmentedString(writtenSource)); |
| 1101 scanner->scanAndPreload(m_preloader.get(), document()->baseElementURL(), nul
lptr); | 1101 scanner->scanAndPreload(m_preloader.get(), document()->validBaseElementURL()
, nullptr); |
| 1102 int numPreloads = document()->loader()->fetcher()->countPreloads() - current
PreloadCount; | 1102 int numPreloads = document()->loader()->fetcher()->countPreloads() - current
PreloadCount; |
| 1103 | 1103 |
| 1104 TRACE_EVENT_INSTANT2("blink", "HTMLDocumentParser::evaluateAndPreloadScriptF
orDocumentWrite.data", TRACE_EVENT_SCOPE_THREAD, "numPreloads", numPreloads, "sc
riptLength", source.length()); | 1104 TRACE_EVENT_INSTANT2("blink", "HTMLDocumentParser::evaluateAndPreloadScriptF
orDocumentWrite.data", TRACE_EVENT_SCOPE_THREAD, "numPreloads", numPreloads, "sc
riptLength", source.length()); |
| 1105 | 1105 |
| 1106 if (neededInitialization) { | 1106 if (neededInitialization) { |
| 1107 DEFINE_STATIC_LOCAL(CustomCountHistogram, initializeHistograms, ("Preloa
dScanner.DocumentWrite.InitializationTime", 1, 10000, 50)); | 1107 DEFINE_STATIC_LOCAL(CustomCountHistogram, initializeHistograms, ("Preloa
dScanner.DocumentWrite.InitializationTime", 1, 10000, 50)); |
| 1108 initializeHistograms.count(initializationDuration); | 1108 initializeHistograms.count(initializationDuration); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 if (numPreloads) { | 1111 if (numPreloads) { |
| 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 |