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

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

Issue 1366883002: [Reland] Post loading tasks on the appropriate WebFrameScheduler's queue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 2 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/inspector/InspectorInstrumentation.h" 43 #include "core/inspector/InspectorInstrumentation.h"
44 #include "core/inspector/InspectorTraceEvents.h" 44 #include "core/inspector/InspectorTraceEvents.h"
45 #include "core/loader/DocumentLoader.h" 45 #include "core/loader/DocumentLoader.h"
46 #include "core/loader/NavigationScheduler.h" 46 #include "core/loader/NavigationScheduler.h"
47 #include "platform/SharedBuffer.h" 47 #include "platform/SharedBuffer.h"
48 #include "platform/ThreadSafeFunctional.h" 48 #include "platform/ThreadSafeFunctional.h"
49 #include "platform/ThreadedDataReceiver.h" 49 #include "platform/ThreadedDataReceiver.h"
50 #include "platform/TraceEvent.h" 50 #include "platform/TraceEvent.h"
51 #include "platform/heap/Handle.h" 51 #include "platform/heap/Handle.h"
52 #include "public/platform/Platform.h" 52 #include "public/platform/Platform.h"
53 #include "public/platform/WebFrameScheduler.h"
53 #include "public/platform/WebScheduler.h" 54 #include "public/platform/WebScheduler.h"
54 #include "public/platform/WebThread.h" 55 #include "public/platform/WebThread.h"
55 #include "wtf/RefCounted.h" 56 #include "wtf/RefCounted.h"
56 #include "wtf/TemporaryChange.h" 57 #include "wtf/TemporaryChange.h"
57 58
58 namespace blink { 59 namespace blink {
59 60
60 using namespace HTMLNames; 61 using namespace HTMLNames;
61 62
62 // This is a direct transcription of step 4 from: 63 // This is a direct transcription of step 4 from:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 WeakPtr<BackgroundHTMLParser> m_backgroundParser; 137 WeakPtr<BackgroundHTMLParser> m_backgroundParser;
137 }; 138 };
138 139
139 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors , ParserSynchronizationPolicy syncPolicy) 140 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors , ParserSynchronizationPolicy syncPolicy)
140 : ScriptableDocumentParser(document) 141 : ScriptableDocumentParser(document)
141 , m_options(&document) 142 , m_options(&document)
142 , m_token(syncPolicy == ForceSynchronousParsing ? adoptPtr(new HTMLToken) : nullptr) 143 , m_token(syncPolicy == ForceSynchronousParsing ? adoptPtr(new HTMLToken) : nullptr)
143 , m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create( m_options) : nullptr) 144 , m_tokenizer(syncPolicy == ForceSynchronousParsing ? HTMLTokenizer::create( m_options) : nullptr)
144 , m_scriptRunner(HTMLScriptRunner::create(&document, this)) 145 , m_scriptRunner(HTMLScriptRunner::create(&document, this))
145 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, parserContentPolicy (), reportErrors, m_options)) 146 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, parserContentPolicy (), reportErrors, m_options))
146 , m_parserScheduler(HTMLParserScheduler::create(this)) 147 , m_loadingTaskRunner(document.frame() ? document.frame()->frameScheduler()- >loadingTaskRunner()
148 : Platform::current()->currentThread()->scheduler()->loadingTaskRunner() )
149 , m_parserScheduler(HTMLParserScheduler::create(this, m_loadingTaskRunner))
147 , m_xssAuditorDelegate(&document) 150 , m_xssAuditorDelegate(&document)
148 , m_weakFactory(this) 151 , m_weakFactory(this)
149 , m_preloader(HTMLResourcePreloader::create(document)) 152 , m_preloader(HTMLResourcePreloader::create(document))
150 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) 153 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing)
151 , m_endWasDelayed(false) 154 , m_endWasDelayed(false)
152 , m_haveBackgroundParser(false) 155 , m_haveBackgroundParser(false)
153 , m_tasksWereSuspended(false) 156 , m_tasksWereSuspended(false)
154 , m_pumpSessionNestingLevel(0) 157 , m_pumpSessionNestingLevel(0)
155 , m_pumpSpeculationsSessionNestingLevel(0) 158 , m_pumpSpeculationsSessionNestingLevel(0)
156 , m_isParsingAtLineNumber(false) 159 , m_isParsingAtLineNumber(false)
157 { 160 {
158 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); 161 ASSERT(shouldUseThreading() || (m_token && m_tokenizer));
159 } 162 }
160 163
161 // FIXME: Member variables should be grouped into self-initializing structs to 164 // FIXME: Member variables should be grouped into self-initializing structs to
162 // minimize code duplication between these constructors. 165 // minimize code duplication between these constructors.
163 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement, ParserContentPolicy parserContentPolicy) 166 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement, ParserContentPolicy parserContentPolicy)
164 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) 167 : ScriptableDocumentParser(fragment->document(), parserContentPolicy)
165 , m_options(&fragment->document()) 168 , m_options(&fragment->document())
166 , m_token(adoptPtr(new HTMLToken)) 169 , m_token(adoptPtr(new HTMLToken))
167 , m_tokenizer(HTMLTokenizer::create(m_options)) 170 , m_tokenizer(HTMLTokenizer::create(m_options))
168 , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this ->parserContentPolicy(), m_options)) 171 , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this ->parserContentPolicy(), m_options))
172 , m_loadingTaskRunner(Platform::current()->currentThread()->scheduler()->loa dingTaskRunner())
Sami 2015/09/25 13:31:27 I'm guessing this isn't used anymore after the doc
alex clarke (OOO till 29th) 2015/09/28 17:24:53 I think that's correct, m_loadingTaskRunner is pas
169 , m_xssAuditorDelegate(&fragment->document()) 173 , m_xssAuditorDelegate(&fragment->document())
170 , m_weakFactory(this) 174 , m_weakFactory(this)
171 , m_shouldUseThreading(false) 175 , m_shouldUseThreading(false)
172 , m_endWasDelayed(false) 176 , m_endWasDelayed(false)
173 , m_haveBackgroundParser(false) 177 , m_haveBackgroundParser(false)
174 , m_tasksWereSuspended(false) 178 , m_tasksWereSuspended(false)
175 , m_pumpSessionNestingLevel(0) 179 , m_pumpSessionNestingLevel(0)
176 , m_pumpSpeculationsSessionNestingLevel(0) 180 , m_pumpSpeculationsSessionNestingLevel(0)
177 { 181 {
178 bool reportErrors = false; // For now document fragment parsing never report s errors. 182 bool reportErrors = false; // For now document fragment parsing never report s errors.
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 if (document()->settings()) { 798 if (document()->settings()) {
795 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) 799 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit())
796 config->outstandingTokenLimit = document()->settings()->backgroundHt mlParserOutstandingTokenLimit(); 800 config->outstandingTokenLimit = document()->settings()->backgroundHt mlParserOutstandingTokenLimit();
797 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) 801 if (document()->settings()->backgroundHtmlParserPendingTokenLimit())
798 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa rserPendingTokenLimit(); 802 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa rserPendingTokenLimit();
799 } 803 }
800 804
801 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); 805 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread());
802 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); 806 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread());
803 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s tart, reference.release(), config.release(), 807 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s tart, reference.release(), config.release(),
804 AllowCrossThreadAccess(Platform::current()->currentThread()->scheduler() ))); 808 AllowCrossThreadAccess(m_loadingTaskRunner)));
805 } 809 }
806 810
807 void HTMLDocumentParser::stopBackgroundParser() 811 void HTMLDocumentParser::stopBackgroundParser()
808 { 812 {
809 ASSERT(shouldUseThreading()); 813 ASSERT(shouldUseThreading());
810 ASSERT(m_haveBackgroundParser); 814 ASSERT(m_haveBackgroundParser);
811 m_haveBackgroundParser = false; 815 m_haveBackgroundParser = false;
812 816
813 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s top, AllowCrossThreadAccess(m_backgroundParser))); 817 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s top, AllowCrossThreadAccess(m_backgroundParser)));
814 m_weakFactory.revokeAll(); 818 m_weakFactory.revokeAll();
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) 1126 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder)
1123 { 1127 {
1124 ASSERT(decoder); 1128 ASSERT(decoder);
1125 DecodedDataDocumentParser::setDecoder(decoder); 1129 DecodedDataDocumentParser::setDecoder(decoder);
1126 1130
1127 if (m_haveBackgroundParser) 1131 if (m_haveBackgroundParser)
1128 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); 1132 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder()));
1129 } 1133 }
1130 1134
1131 } 1135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698