| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2013 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/html/parser/BackgroundHTMLParser.h" | 27 #include "core/html/parser/BackgroundHTMLParser.h" |
| 28 | 28 |
| 29 #include "core/html/parser/HTMLDocumentParser.h" | 29 #include "core/html/parser/HTMLDocumentParser.h" |
| 30 #include "core/html/parser/TextResourceDecoder.h" | 30 #include "core/html/parser/TextResourceDecoder.h" |
| 31 #include "core/html/parser/XSSAuditor.h" | 31 #include "core/html/parser/XSSAuditor.h" |
| 32 #include "platform/scheduler/Scheduler.h" |
| 32 #include "wtf/MainThread.h" | 33 #include "wtf/MainThread.h" |
| 33 #include "wtf/text/TextPosition.h" | 34 #include "wtf/text/TextPosition.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 // On a network with high latency and high bandwidth, using a device | 38 // On a network with high latency and high bandwidth, using a device |
| 38 // with a fast CPU, we could end up speculatively tokenizing | 39 // with a fast CPU, we could end up speculatively tokenizing |
| 39 // the whole document, well ahead of when the main-thread actually needs it. | 40 // the whole document, well ahead of when the main-thread actually needs it. |
| 40 // This is a waste of memory (and potentially time if the speculation fails). | 41 // This is a waste of memory (and potentially time if the speculation fails). |
| 41 // So we limit our outstanding tokens arbitrarily to 10,000. | 42 // So we limit our outstanding tokens arbitrarily to 10,000. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentPar
ser::ParsedChunk); | 261 OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentPar
ser::ParsedChunk); |
| 261 chunk->preloads.swap(m_pendingPreloads); | 262 chunk->preloads.swap(m_pendingPreloads); |
| 262 chunk->xssInfos.swap(m_pendingXSSInfos); | 263 chunk->xssInfos.swap(m_pendingXSSInfos); |
| 263 chunk->tokenizerState = m_tokenizer->state(); | 264 chunk->tokenizerState = m_tokenizer->state(); |
| 264 chunk->treeBuilderState = m_treeBuilderSimulator.state(); | 265 chunk->treeBuilderState = m_treeBuilderSimulator.state(); |
| 265 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); | 266 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); |
| 266 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); | 267 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); |
| 267 chunk->tokens = m_pendingTokens.release(); | 268 chunk->tokens = m_pendingTokens.release(); |
| 268 chunk->startingScript = m_startingScript; | 269 chunk->startingScript = m_startingScript; |
| 269 m_startingScript = false; | 270 m_startingScript = false; |
| 270 callOnMainThread(bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgrou
ndParser, m_parser, chunk.release())); | 271 |
| 272 Scheduler::shared()->postLoadingTask( |
| 273 FROM_HERE, bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackground
Parser, m_parser, chunk.release())); |
| 271 | 274 |
| 272 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); | 275 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); |
| 273 } | 276 } |
| 274 | 277 |
| 275 } | 278 } |
| OLD | NEW |