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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) | 123 , m_shouldUseThreading(syncPolicy == AllowAsynchronousParsing) |
124 , m_endWasDelayed(false) | 124 , m_endWasDelayed(false) |
125 , m_haveBackgroundParser(false) | 125 , m_haveBackgroundParser(false) |
126 , m_tasksWereSuspended(false) | 126 , m_tasksWereSuspended(false) |
127 , m_pumpSessionNestingLevel(0) | 127 , m_pumpSessionNestingLevel(0) |
128 , m_pumpSpeculationsSessionNestingLevel(0) | 128 , m_pumpSpeculationsSessionNestingLevel(0) |
129 , m_isParsingAtLineNumber(false) | 129 , m_isParsingAtLineNumber(false) |
130 , m_triedLoadingLinkHeaders(false) | 130 , m_triedLoadingLinkHeaders(false) |
131 { | 131 { |
132 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); | 132 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); |
| 133 // Threading is not allowed in prefetch mode. |
| 134 DCHECK(!document.isPrefetchOnly() || !shouldUseThreading()); |
| 135 |
133 ThreadState::current()->registerPreFinalizer(this); | 136 ThreadState::current()->registerPreFinalizer(this); |
134 } | 137 } |
135 | 138 |
136 HTMLDocumentParser::~HTMLDocumentParser() | 139 HTMLDocumentParser::~HTMLDocumentParser() |
137 { | 140 { |
138 } | 141 } |
139 | 142 |
140 void HTMLDocumentParser::dispose() | 143 void HTMLDocumentParser::dispose() |
141 { | 144 { |
142 // In Oilpan, HTMLDocumentParser can die together with Document, and | 145 // In Oilpan, HTMLDocumentParser can die together with Document, and |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 if (isStopped()) | 793 if (isStopped()) |
791 return; | 794 return; |
792 | 795 |
793 // We should never reach this point if we're using a parser thread, | 796 // We should never reach this point if we're using a parser thread, |
794 // as appendBytes() will directly ship the data to the thread. | 797 // as appendBytes() will directly ship the data to the thread. |
795 ASSERT(!shouldUseThreading()); | 798 ASSERT(!shouldUseThreading()); |
796 | 799 |
797 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::
append", "size", inputSource.length()); | 800 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::
append", "size", inputSource.length()); |
798 const SegmentedString source(inputSource); | 801 const SegmentedString source(inputSource); |
799 | 802 |
| 803 if (document()->isPrefetchOnly()) { |
| 804 if (!m_preloadScanner) |
| 805 m_preloadScanner = createPreloadScanner(); |
| 806 |
| 807 m_preloadScanner->appendToEnd(source); |
| 808 // TODO(droger): Set the LOAD_PREFETCH flags on the requests. |
| 809 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->validBas
eElementURL(), nullptr); |
| 810 |
| 811 // Return after the preload scanner, do not actually parse the document. |
| 812 return; |
| 813 } |
| 814 |
800 if (m_preloadScanner) { | 815 if (m_preloadScanner) { |
801 if (m_input.current().isEmpty() && !isWaitingForScripts()) { | 816 if (m_input.current().isEmpty() && !isWaitingForScripts()) { |
802 // We have parsed until the end of the current input and so are now
moving ahead of the preload scanner. | 817 // We have parsed until the end of the current input and so are now
moving ahead of the preload scanner. |
803 // Clear the scanner so we know to scan starting from the current in
put point if we block again. | 818 // Clear the scanner so we know to scan starting from the current in
put point if we block again. |
804 m_preloadScanner.reset(); | 819 m_preloadScanner.reset(); |
805 } else { | 820 } else { |
806 m_preloadScanner->appendToEnd(source); | 821 m_preloadScanner->appendToEnd(source); |
807 if (isWaitingForScripts()) | 822 if (isWaitingForScripts()) |
808 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->
validBaseElementURL(), nullptr); | 823 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->
validBaseElementURL(), nullptr); |
809 } | 824 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); | 1187 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); |
1173 return; | 1188 return; |
1174 case Asynchronous: | 1189 case Asynchronous: |
1175 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::
forward<Ps>(parameters)...)); | 1190 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::
forward<Ps>(parameters)...)); |
1176 return; | 1191 return; |
1177 } | 1192 } |
1178 NOTREACHED(); | 1193 NOTREACHED(); |
1179 } | 1194 } |
1180 | 1195 |
1181 } // namespace blink | 1196 } // namespace blink |
OLD | NEW |