Chromium Code Reviews| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 m_queuedDocumentWriteScripts.append(token.data()); | 308 m_queuedDocumentWriteScripts.append(token.data()); |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 } else { | 311 } else { |
| 312 // We can safely assume that there are no queued preloads request after | 312 // We can safely assume that there are no queued preloads request after |
| 313 // the document element is available, as we empty the queue immediately | 313 // the document element is available, as we empty the queue immediately |
| 314 // after the document element is created in documentElementAvailable(). | 314 // after the document element is created in documentElementAvailable(). |
| 315 ASSERT(m_queuedPreloads.isEmpty()); | 315 ASSERT(m_queuedPreloads.isEmpty()); |
| 316 ASSERT(m_queuedDocumentWriteScripts.isEmpty()); | 316 ASSERT(m_queuedDocumentWriteScripts.isEmpty()); |
| 317 for (auto& chunk : pendingChunks) { | 317 for (auto& chunk : pendingChunks) { |
| 318 m_preloader->takeAndPreload(chunk->preloads); | |
|
kouhei (in TOK)
2016/07/13 01:01:28
Makes sense. Can we have a comment re: why we need
Charlie Harrison
2016/07/13 03:13:45
Done.
| |
| 319 } | |
| 320 for (auto& chunk : pendingChunks) { | |
| 318 for (auto& index : chunk->likelyDocumentWriteScriptIndices) { | 321 for (auto& index : chunk->likelyDocumentWriteScriptIndices) { |
| 319 const CompactHTMLToken& token = chunk->tokens->at(index); | 322 const CompactHTMLToken& token = chunk->tokens->at(index); |
| 320 ASSERT(token.type() == HTMLToken::TokenType::Character); | 323 ASSERT(token.type() == HTMLToken::TokenType::Character); |
| 321 evaluateAndPreloadScriptForDocumentWrite(token.data()); | 324 evaluateAndPreloadScriptForDocumentWrite(token.data()); |
| 322 } | 325 } |
| 323 m_preloader->takeAndPreload(chunk->preloads); | |
| 324 } | 326 } |
| 325 } | 327 } |
| 326 | 328 |
| 327 for (auto& chunk : pendingChunks) | 329 for (auto& chunk : pendingChunks) |
| 328 m_speculations.append(std::move(chunk)); | 330 m_speculations.append(std::move(chunk)); |
| 329 | 331 |
| 330 if (!isWaitingForScripts() && !isScheduledForResume()) { | 332 if (!isWaitingForScripts() && !isScheduledForResume()) { |
| 331 if (m_tasksWereSuspended) | 333 if (m_tasksWereSuspended) |
| 332 m_parserScheduler->forceResumeAfterYield(); | 334 m_parserScheduler->forceResumeAfterYield(); |
| 333 else | 335 else |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 DecodedDataDocumentParser::setDecoder(std::move(decoder)); | 1063 DecodedDataDocumentParser::setDecoder(std::move(decoder)); |
| 1062 | 1064 |
| 1063 if (m_haveBackgroundParser) | 1065 if (m_haveBackgroundParser) |
| 1064 postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, passed(takeDecoder()))); | 1066 postTaskToLookaheadParser(crossThreadBind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, passed(takeDecoder()))); |
| 1065 } | 1067 } |
| 1066 | 1068 |
| 1067 void HTMLDocumentParser::documentElementAvailable() | 1069 void HTMLDocumentParser::documentElementAvailable() |
| 1068 { | 1070 { |
| 1069 TRACE_EVENT0("blink,loader", "HTMLDocumentParser::documentElementAvailable") ; | 1071 TRACE_EVENT0("blink,loader", "HTMLDocumentParser::documentElementAvailable") ; |
| 1070 DCHECK(document()->documentElement()); | 1072 DCHECK(document()->documentElement()); |
| 1073 if (!m_queuedPreloads.isEmpty()) | |
| 1074 m_preloader->takeAndPreload(m_queuedPreloads); | |
| 1075 | |
| 1071 for (const String& scriptSource : m_queuedDocumentWriteScripts) { | 1076 for (const String& scriptSource : m_queuedDocumentWriteScripts) { |
| 1072 evaluateAndPreloadScriptForDocumentWrite(scriptSource); | 1077 evaluateAndPreloadScriptForDocumentWrite(scriptSource); |
| 1073 } | 1078 } |
| 1074 | 1079 |
| 1075 m_queuedDocumentWriteScripts.clear(); | 1080 m_queuedDocumentWriteScripts.clear(); |
| 1076 if (!m_queuedPreloads.isEmpty()) | |
| 1077 m_preloader->takeAndPreload(m_queuedPreloads); | |
| 1078 } | 1081 } |
| 1079 | 1082 |
| 1080 std::unique_ptr<HTMLPreloadScanner> HTMLDocumentParser::createPreloadScanner() | 1083 std::unique_ptr<HTMLPreloadScanner> HTMLDocumentParser::createPreloadScanner() |
| 1081 { | 1084 { |
| 1082 return HTMLPreloadScanner::create( | 1085 return HTMLPreloadScanner::create( |
| 1083 m_options, | 1086 m_options, |
| 1084 document()->url(), | 1087 document()->url(), |
| 1085 CachedDocumentParameters::create(document()), | 1088 CachedDocumentParameters::create(document()), |
| 1086 MediaValuesCached::MediaValuesCachedData(*document())); | 1089 MediaValuesCached::MediaValuesCachedData(*document())); |
| 1087 } | 1090 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1139 (*closure)(); | 1142 (*closure)(); |
| 1140 return; | 1143 return; |
| 1141 case Asynchronous: | 1144 case Asynchronous: |
| 1142 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure)); | 1145 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure)); |
| 1143 return; | 1146 return; |
| 1144 } | 1147 } |
| 1145 NOTREACHED(); | 1148 NOTREACHED(); |
| 1146 } | 1149 } |
| 1147 | 1150 |
| 1148 } // namespace blink | 1151 } // namespace blink |
| OLD | NEW |