Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp

Issue 2160503002: Use Document::validBaseElementURL to init preloadscanner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 ASSERT(m_tokenizer->getState() == HTMLTokenizer::DataState); 624 ASSERT(m_tokenizer->getState() == HTMLTokenizer::DataState);
625 625
626 ASSERT(m_preloader); 626 ASSERT(m_preloader);
627 // TODO(kouhei): m_preloader should be always available for synchronous parsing case, 627 // TODO(kouhei): m_preloader should be always available for synchronous parsing case,
628 // adding paranoia if for speculative crash fix for crbug.com/465478 628 // adding paranoia if for speculative crash fix for crbug.com/465478
629 if (m_preloader) { 629 if (m_preloader) {
630 if (!m_preloadScanner) { 630 if (!m_preloadScanner) {
631 m_preloadScanner = createPreloadScanner(); 631 m_preloadScanner = createPreloadScanner();
632 m_preloadScanner->appendToEnd(m_input.current()); 632 m_preloadScanner->appendToEnd(m_input.current());
633 } 633 }
634 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->base ElementURL(), nullptr); 634 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->vali dBaseElementURL(), nullptr);
635 } 635 }
636 } 636 }
637 637
638 TRACE_EVENT_END1("devtools.timeline", "ParseHTML", "endData", InspectorParse HtmlEvent::endData(m_input.current().currentLine().zeroBasedInt() - 1)); 638 TRACE_EVENT_END1("devtools.timeline", "ParseHTML", "endData", InspectorParse HtmlEvent::endData(m_input.current().currentLine().zeroBasedInt() - 1));
639 } 639 }
640 640
641 void HTMLDocumentParser::constructTreeFromHTMLToken() 641 void HTMLDocumentParser::constructTreeFromHTMLToken()
642 { 642 {
643 AtomicHTMLToken atomicToken(token()); 643 AtomicHTMLToken atomicToken(token());
644 644
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 excludedLineNumberSource.setExcludeLineNumbers(); 701 excludedLineNumberSource.setExcludeLineNumbers();
702 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); 702 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource);
703 pumpTokenizerIfPossible(); 703 pumpTokenizerIfPossible();
704 704
705 if (isWaitingForScripts()) { 705 if (isWaitingForScripts()) {
706 // Check the document.write() output with a separate preload scanner as 706 // Check the document.write() output with a separate preload scanner as
707 // the main scanner can't deal with insertions. 707 // the main scanner can't deal with insertions.
708 if (!m_insertionPreloadScanner) 708 if (!m_insertionPreloadScanner)
709 m_insertionPreloadScanner = createPreloadScanner(); 709 m_insertionPreloadScanner = createPreloadScanner();
710 m_insertionPreloadScanner->appendToEnd(source); 710 m_insertionPreloadScanner->appendToEnd(source);
711 m_insertionPreloadScanner->scanAndPreload(m_preloader.get(), document()- >baseElementURL(), nullptr); 711 m_insertionPreloadScanner->scanAndPreload(m_preloader.get(), document()- >validBaseElementURL(), nullptr);
712 } 712 }
713 713
714 endIfDelayed(); 714 endIfDelayed();
715 } 715 }
716 716
717 void HTMLDocumentParser::startBackgroundParser() 717 void HTMLDocumentParser::startBackgroundParser()
718 { 718 {
719 ASSERT(!isStopped()); 719 ASSERT(!isStopped());
720 ASSERT(shouldUseThreading()); 720 ASSERT(shouldUseThreading());
721 ASSERT(!m_haveBackgroundParser); 721 ASSERT(!m_haveBackgroundParser);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 const SegmentedString source(inputSource); 782 const SegmentedString source(inputSource);
783 783
784 if (m_preloadScanner) { 784 if (m_preloadScanner) {
785 if (m_input.current().isEmpty() && !isWaitingForScripts()) { 785 if (m_input.current().isEmpty() && !isWaitingForScripts()) {
786 // We have parsed until the end of the current input and so are now moving ahead of the preload scanner. 786 // We have parsed until the end of the current input and so are now moving ahead of the preload scanner.
787 // Clear the scanner so we know to scan starting from the current in put point if we block again. 787 // Clear the scanner so we know to scan starting from the current in put point if we block again.
788 m_preloadScanner.reset(); 788 m_preloadScanner.reset();
789 } else { 789 } else {
790 m_preloadScanner->appendToEnd(source); 790 m_preloadScanner->appendToEnd(source);
791 if (isWaitingForScripts()) 791 if (isWaitingForScripts())
792 m_preloadScanner->scanAndPreload(m_preloader.get(), document()-> baseElementURL(), nullptr); 792 m_preloadScanner->scanAndPreload(m_preloader.get(), document()-> validBaseElementURL(), nullptr);
793 } 793 }
794 } 794 }
795 795
796 m_input.appendToEnd(source); 796 m_input.appendToEnd(source);
797 797
798 if (inPumpSession()) { 798 if (inPumpSession()) {
799 // We've gotten data off the network in a nested write. 799 // We've gotten data off the network in a nested write.
800 // We don't want to consume any more of the input stream now. Do 800 // We don't want to consume any more of the input stream now. Do
801 // not worry. We'll consume this data in a less-nested write(). 801 // not worry. We'll consume this data in a less-nested write().
802 return; 802 return;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 957
958 m_insertionPreloadScanner.reset(); 958 m_insertionPreloadScanner.reset();
959 pumpTokenizerIfPossible(); 959 pumpTokenizerIfPossible();
960 endIfDelayed(); 960 endIfDelayed();
961 } 961 }
962 962
963 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() 963 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan()
964 { 964 {
965 ASSERT(m_preloadScanner); 965 ASSERT(m_preloadScanner);
966 m_preloadScanner->appendToEnd(m_input.current()); 966 m_preloadScanner->appendToEnd(m_input.current());
967 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->baseElementU RL(), nullptr); 967 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->validBaseEle mentURL(), nullptr);
968 } 968 }
969 969
970 void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource) 970 void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource)
971 { 971 {
972 ASSERT(m_scriptRunner); 972 ASSERT(m_scriptRunner);
973 ASSERT(!isExecutingScript()); 973 ASSERT(!isExecutingScript());
974 974
975 if (isStopped()) { 975 if (isStopped()) {
976 return; 976 return;
977 } 977 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 bool neededInitialization = m_evaluator->ensureEvaluationContext(); 1115 bool neededInitialization = m_evaluator->ensureEvaluationContext();
1116 double initializationDuration = monotonicallyIncreasingTimeMS() - initialize StartTime; 1116 double initializationDuration = monotonicallyIncreasingTimeMS() - initialize StartTime;
1117 1117
1118 double startTime = monotonicallyIncreasingTimeMS(); 1118 double startTime = monotonicallyIncreasingTimeMS();
1119 String writtenSource = m_evaluator->evaluateAndEmitWrittenSource(source); 1119 String writtenSource = m_evaluator->evaluateAndEmitWrittenSource(source);
1120 double duration = monotonicallyIncreasingTimeMS() - startTime; 1120 double duration = monotonicallyIncreasingTimeMS() - startTime;
1121 1121
1122 int currentPreloadCount = document()->loader()->fetcher()->countPreloads(); 1122 int currentPreloadCount = document()->loader()->fetcher()->countPreloads();
1123 std::unique_ptr<HTMLPreloadScanner> scanner = createPreloadScanner(); 1123 std::unique_ptr<HTMLPreloadScanner> scanner = createPreloadScanner();
1124 scanner->appendToEnd(SegmentedString(writtenSource)); 1124 scanner->appendToEnd(SegmentedString(writtenSource));
1125 scanner->scanAndPreload(m_preloader.get(), document()->baseElementURL(), nul lptr); 1125 scanner->scanAndPreload(m_preloader.get(), document()->validBaseElementURL() , nullptr);
1126 int numPreloads = document()->loader()->fetcher()->countPreloads() - current PreloadCount; 1126 int numPreloads = document()->loader()->fetcher()->countPreloads() - current PreloadCount;
1127 1127
1128 TRACE_EVENT_INSTANT2("blink", "HTMLDocumentParser::evaluateAndPreloadScriptF orDocumentWrite.data", TRACE_EVENT_SCOPE_THREAD, "numPreloads", numPreloads, "sc riptLength", source.length()); 1128 TRACE_EVENT_INSTANT2("blink", "HTMLDocumentParser::evaluateAndPreloadScriptF orDocumentWrite.data", TRACE_EVENT_SCOPE_THREAD, "numPreloads", numPreloads, "sc riptLength", source.length());
1129 1129
1130 if (neededInitialization) { 1130 if (neededInitialization) {
1131 DEFINE_STATIC_LOCAL(CustomCountHistogram, initializeHistograms, ("Preloa dScanner.DocumentWrite.InitializationTime", 1, 10000, 50)); 1131 DEFINE_STATIC_LOCAL(CustomCountHistogram, initializeHistograms, ("Preloa dScanner.DocumentWrite.InitializationTime", 1, 10000, 50));
1132 initializeHistograms.count(initializationDuration); 1132 initializeHistograms.count(initializationDuration);
1133 } 1133 }
1134 1134
1135 if (numPreloads) { 1135 if (numPreloads) {
(...skipping 20 matching lines...) Expand all
1156 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); 1156 (*WTF::bind(function, std::forward<Ps>(parameters)...))();
1157 return; 1157 return;
1158 case Asynchronous: 1158 case Asynchronous:
1159 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std:: forward<Ps>(parameters)...)); 1159 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std:: forward<Ps>(parameters)...));
1160 return; 1160 return;
1161 } 1161 }
1162 NOTREACHED(); 1162 NOTREACHED();
1163 } 1163 }
1164 1164
1165 } // namespace blink 1165 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698