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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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() |
Sami
2015/09/29 11:22:47
nit: might be worth adding a loadingTaskRunner() g
alex clarke (OOO till 29th)
2015/09/29 16:37:38
Done.
| |
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(fragment->document().frame() ? fragment->document().fr ame()->frameScheduler()->loadingTaskRunner() | |
173 : Platform::current()->currentThread()->scheduler()->loadingTaskRunner() ) | |
169 , m_xssAuditorDelegate(&fragment->document()) | 174 , m_xssAuditorDelegate(&fragment->document()) |
170 , m_weakFactory(this) | 175 , m_weakFactory(this) |
171 , m_shouldUseThreading(false) | 176 , m_shouldUseThreading(false) |
172 , m_endWasDelayed(false) | 177 , m_endWasDelayed(false) |
173 , m_haveBackgroundParser(false) | 178 , m_haveBackgroundParser(false) |
174 , m_tasksWereSuspended(false) | 179 , m_tasksWereSuspended(false) |
175 , m_pumpSessionNestingLevel(0) | 180 , m_pumpSessionNestingLevel(0) |
176 , m_pumpSpeculationsSessionNestingLevel(0) | 181 , m_pumpSpeculationsSessionNestingLevel(0) |
177 { | 182 { |
178 bool reportErrors = false; // For now document fragment parsing never report s errors. | 183 bool reportErrors = false; // For now document fragment parsing never report s errors. |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 if (document()->settings()) { | 799 if (document()->settings()) { |
795 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) | 800 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) |
796 config->outstandingTokenLimit = document()->settings()->backgroundHt mlParserOutstandingTokenLimit(); | 801 config->outstandingTokenLimit = document()->settings()->backgroundHt mlParserOutstandingTokenLimit(); |
797 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) | 802 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) |
798 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa rserPendingTokenLimit(); | 803 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa rserPendingTokenLimit(); |
799 } | 804 } |
800 | 805 |
801 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); | 806 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); |
802 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); | 807 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); |
803 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s tart, reference.release(), config.release(), | 808 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s tart, reference.release(), config.release(), |
804 AllowCrossThreadAccess(Platform::current()->currentThread()->scheduler() ))); | 809 AllowCrossThreadAccess(m_loadingTaskRunner))); |
805 } | 810 } |
806 | 811 |
807 void HTMLDocumentParser::stopBackgroundParser() | 812 void HTMLDocumentParser::stopBackgroundParser() |
808 { | 813 { |
809 ASSERT(shouldUseThreading()); | 814 ASSERT(shouldUseThreading()); |
810 ASSERT(m_haveBackgroundParser); | 815 ASSERT(m_haveBackgroundParser); |
811 m_haveBackgroundParser = false; | 816 m_haveBackgroundParser = false; |
812 | 817 |
813 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s top, AllowCrossThreadAccess(m_backgroundParser))); | 818 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s top, AllowCrossThreadAccess(m_backgroundParser))); |
814 m_weakFactory.revokeAll(); | 819 m_weakFactory.revokeAll(); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1127 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
1123 { | 1128 { |
1124 ASSERT(decoder); | 1129 ASSERT(decoder); |
1125 DecodedDataDocumentParser::setDecoder(decoder); | 1130 DecodedDataDocumentParser::setDecoder(decoder); |
1126 | 1131 |
1127 if (m_haveBackgroundParser) | 1132 if (m_haveBackgroundParser) |
1128 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); | 1133 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); |
1129 } | 1134 } |
1130 | 1135 |
1131 } | 1136 } |
OLD | NEW |